Merge pull request #8434 from donaldsharp/python_bullshit

Python pylint stuff
This commit is contained in:
Martin Winter 2021-04-16 23:17:04 +02:00 committed by GitHub
commit 6e0368f61a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 493 deletions

View File

@ -287,272 +287,6 @@ def next_hop_per_address_family(
return next_hop
def test_BGP_GR_TC_46_p1(request):
"""
Test Objective : transition from Peer-level helper to Global Restarting
Global Mode : GR Restarting
PerPeer Mode : GR Helper
GR Mode effective : GR Helper
"""
tgen = get_topogen()
tc_name = request.node.name
write_test_header(tc_name)
# Check router status
check_router_status(tgen)
# Don't run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
# Creating configuration from JSON
reset_config_on_routers(tgen)
step(
"Configure R1 and R2 as GR restarting node in global"
" and helper in per-Peer-level"
)
input_dict = {
"r1": {
"bgp": {
"graceful-restart": {
"graceful-restart": True,
},
"address_family": {
"ipv4": {
"unicast": {
"neighbor": {
"r2": {
"dest_link": {
"r1-link1": {"graceful-restart-helper": True}
}
}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
"r2": {
"dest_link": {
"r1-link1": {"graceful-restart-helper": True}
}
}
}
}
},
},
}
},
"r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
}
configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2")
step("Verify on R2 that R1 advertises GR capabilities as a restarting node")
for addr_type in ADDR_TYPES:
result = verify_graceful_restart(
tgen, topo, addr_type, input_dict, dut="r1", peer="r2"
)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
for addr_type in ADDR_TYPES:
protocol = "bgp"
next_hop = next_hop_per_address_family(
tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1
)
input_topo = {"r1": topo["routers"]["r1"]}
result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
for addr_type in ADDR_TYPES:
next_hop = next_hop_per_address_family(
tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2
)
input_topo = {"r2": topo["routers"]["r2"]}
result = verify_bgp_rib(tgen, addr_type, "r1", input_topo, next_hop)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
step("Kill BGP on R2")
kill_router_daemons(tgen, "r2", ["bgpd"])
step(
"Verify that R1 keeps the stale entries in RIB & FIB and R2 keeps stale entries in FIB using"
)
for addr_type in ADDR_TYPES:
protocol = "bgp"
next_hop = next_hop_per_address_family(
tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1
)
input_topo = {"r1": topo["routers"]["r1"]}
result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
for addr_type in ADDR_TYPES:
next_hop = next_hop_per_address_family(
tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2
)
input_topo = {"r2": topo["routers"]["r2"]}
result = verify_bgp_rib(tgen, addr_type, "r1", input_topo, next_hop)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
step(
"Bring up BGP on R1 and remove Peer-level GR config"
" from R1 following by a session reset"
)
start_router_daemons(tgen, "r2", ["bgpd"])
input_dict = {
"r1": {
"bgp": {
"address_family": {
"ipv4": {
"unicast": {
"neighbor": {
"r2": {
"dest_link": {
"r1-link1": {"graceful-restart-helper": False}
}
}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
"r2": {
"dest_link": {
"r1-link1": {"graceful-restart-helper": False}
}
}
}
}
},
}
}
}
}
result = create_router_bgp(tgen, topo, input_dict)
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
step("Verify on R2 that R1 advertises GR capabilities as a restarting node")
input_dict = {
"r1": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
"r2": {"bgp": {"graceful-restart": {"graceful-restart": True}}},
}
for addr_type in ADDR_TYPES:
result = verify_graceful_restart(
tgen, topo, addr_type, input_dict, dut="r1", peer="r2"
)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
for addr_type in ADDR_TYPES:
protocol = "bgp"
next_hop = next_hop_per_address_family(
tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2
)
input_topo = {"r2": topo["routers"]["r2"]}
result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol)
assert (
result is True
), "Testcase {} : Failed \n Routes are still present \n Error {}".format(
tc_name, result
)
for addr_type in ADDR_TYPES:
next_hop = next_hop_per_address_family(
tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1
)
input_topo = {"r1": topo["routers"]["r1"]}
result = verify_bgp_rib(tgen, addr_type, "r2", input_topo, next_hop)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol)
assert (
result is True
), "Testcase {} : Failed \n Routes are still present \n Error {}".format(
tc_name, result
)
step("Kill BGP on R1")
kill_router_daemons(tgen, "r1", ["bgpd"])
step(
"Verify that R1 keeps the stale entries in FIB command and R2 keeps stale entries in RIB & FIB"
)
for addr_type in ADDR_TYPES:
protocol = "bgp"
next_hop = next_hop_per_address_family(
tgen, "r1", "r2", addr_type, NEXT_HOP_IP_2
)
input_topo = {"r2": topo["routers"]["r2"]}
result = verify_rib(tgen, addr_type, "r1", input_topo, next_hop, protocol)
assert (
result is True
), "Testcase {} : Failed \n Routes are still present \n Error {}".format(
tc_name, result
)
for addr_type in ADDR_TYPES:
next_hop = next_hop_per_address_family(
tgen, "r2", "r1", addr_type, NEXT_HOP_IP_1
)
input_topo = {"r1": topo["routers"]["r1"]}
result = verify_bgp_rib(tgen, addr_type, "r2", input_topo, next_hop)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
result = verify_rib(tgen, addr_type, "r2", input_topo, next_hop, protocol)
assert (
result is True
), "Testcase {} : Failed \n Routes are still present \n Error {}".format(
tc_name, result
)
step("Start BGP on R1")
start_router_daemons(tgen, "r1", ["bgpd"])
write_test_footer(tc_name)
def BGP_GR_TC_50_p1(request):
"""
Test Objective : Transition from Peer-level helper to Global inherit helper
@ -1979,198 +1713,6 @@ def test_BGP_GR_TC_8_p1(request):
write_test_footer(tc_name)
def test_BGP_GR_TC_17_p1(request):
"""
Test Objective : Verify that only GR helper routers keep the stale
route entries, not any GR disabled router.
"""
tgen = get_topogen()
tc_name = request.node.name
write_test_header(tc_name)
# Check router status
check_router_status(tgen)
# Don't run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
# Creating configuration from JSON
reset_config_on_routers(tgen)
logger.info("[Phase 1] : Test Setup [Disable]R1-----R2[Restart] initialized ")
# Configure graceful-restart
input_dict = {
"r1": {
"bgp": {
"graceful-restart": {
"graceful-restart": True,
"preserve-fw-state": True,
},
"address_family": {
"ipv4": {
"unicast": {
"neighbor": {
"r2": {
"dest_link": {
"r1-link1": {"graceful-restart-disable": True}
}
}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
"r2": {
"dest_link": {
"r1-link1": {"graceful-restart-disable": True}
}
}
}
}
},
},
}
},
"r2": {
"bgp": {
"address_family": {
"ipv4": {
"unicast": {
"neighbor": {
"r1": {
"dest_link": {
"r2-link1": {"graceful-restart": True}
}
}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
"r1": {
"dest_link": {
"r2-link1": {"graceful-restart": True}
}
}
}
}
},
}
}
},
}
configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2")
for addr_type in ADDR_TYPES:
result = verify_graceful_restart(
tgen, topo, addr_type, input_dict, dut="r1", peer="r2"
)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
# Verifying BGP RIB routes
dut = "r1"
peer = "r2"
next_hop = next_hop_per_address_family(
tgen, dut, peer, addr_type, NEXT_HOP_IP_2
)
input_topo = {key: topo["routers"][key] for key in ["r2"]}
result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
# Verifying RIB routes
protocol = "bgp"
result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
logger.info("[Phase 2] : R2 goes for reload ")
kill_router_daemons(tgen, "r2", ["bgpd"])
logger.info(
"[Phase 3] : R2 is still down, restart time 120 sec."
" So time verify the routes are present in BGP RIB and ZEBRA "
)
for addr_type in ADDR_TYPES:
# Verifying BGP RIB routes
next_hop = next_hop_per_address_family(
tgen, dut, peer, addr_type, NEXT_HOP_IP_2
)
input_topo = {key: topo["routers"][key] for key in ["r2"]}
result = verify_bgp_rib(
tgen, addr_type, dut, input_topo, next_hop, expected=False
)
assert result is not True, (
"Testcase {} : Failed \n "
"r1: routes are still present in BGP RIB\n Error: {}".format(
tc_name, result
)
)
logger.info(" Expected behavior: {}".format(result))
# Verifying RIB routes
result = verify_rib(
tgen, addr_type, dut, input_topo, next_hop, protocol, expected=False
)
assert result is not True, (
"Testcase {} : Failed \n "
"r1: routes are still present in ZEBRA\n Error: {}".format(tc_name, result)
)
logger.info(" Expected behavior: {}".format(result))
logger.info("[Phase 5] : R2 is about to come up now ")
start_router_daemons(tgen, "r2", ["bgpd"])
logger.info("[Phase 4] : R2 is UP now, so time to collect GR stats ")
for addr_type in ADDR_TYPES:
result = verify_graceful_restart(
tgen, topo, addr_type, input_dict, dut="r1", peer="r2"
)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
result = verify_r_bit(
tgen, topo, addr_type, input_dict, dut="r1", peer="r2", expected=False
)
assert (
result is not True
), "Testcase {} : Failed \n " "r1: R-bit is set to True\n Error: {}".format(
tc_name, result
)
# Verifying BGP RIB routes
next_hop = next_hop_per_address_family(
tgen, dut, peer, addr_type, NEXT_HOP_IP_2
)
input_topo = {key: topo["routers"][key] for key in ["r2"]}
result = verify_bgp_rib(tgen, addr_type, dut, input_topo, next_hop)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
# Verifying RIB routes
result = verify_rib(tgen, addr_type, dut, input_topo, next_hop, protocol)
assert result is True, "Testcase {} : Failed \n Error {}".format(
tc_name, result
)
write_test_footer(tc_name)
def test_BGP_GR_TC_19_p1(request):
"""
Test Objective : Verify that GR helper routers keeps all the routes received

View File

@ -112,7 +112,7 @@ def test_protocols_convergence():
test_func = partial(
topotest.router_json_cmp,
router,
"show ip route json".format(router.name),
"show ip route json",
expected,
)
_, result = topotest.run_and_expect(test_func, None, count=160, wait=0.5)
@ -131,7 +131,7 @@ def test_protocols_convergence():
test_func = partial(
topotest.router_json_cmp,
router,
"show ipv6 route json".format(router.name),
"show ipv6 route json",
expected,
)
_, result = topotest.run_and_expect(test_func, None, count=160, wait=0.5)

View File

@ -2677,14 +2677,12 @@ def test_route_map_within_vrf_to_alter_bgp_attribute_nexthop_p0(request):
result = verify_rib(tgen, addr_type, dut, input_dict_1, expected=False)
assert (
result is not True
), "Testcase {} : Failed \n Expected Behaviour: Routes are rejected because"
" nexthop-self config is deleted \n Error {}".format(tc_name, result)
), "Testcase {} : Failed \n Expected Behaviour: Routes are rejected because nexthop-self config is deleted \n Error {}".format(tc_name, result)
result = verify_rib(tgen, addr_type, dut, input_dict_2, expected=False)
assert (
result is not True
), "Testcase {} : Failed \n Expected Behaviour: Routes are rejected because"
" nexthop-self config is deleted \n Error {}".format(tc_name, result)
), "Testcase {} : Failed \n Expected Behaviour: Routes are rejected because nexthop-self config is deleted \n Error {}".format(tc_name, result)
write_test_footer(tc_name)
@ -4958,8 +4956,7 @@ def test_prefix_list_to_permit_deny_prefixes_p0(request):
result = verify_rib(tgen, addr_type, dut, denied_routes, expected=False)
assert result is not True, "Testcase {} : Failed \n"
"Expected behaviour: Routes are denied by prefix-list \n"
"Error {}".format(tc_name, result)
"{}:Expected behaviour: Routes are denied by prefix-list \nError {}".format(tc_name, result)
step(
"On router R1, configure prefix-lists to permit 2 "
@ -5169,9 +5166,7 @@ def test_prefix_list_to_permit_deny_prefixes_p0(request):
)
result = verify_rib(tgen, addr_type, dut, denied_routes, expected=False)
assert result is not True, "Testcase {} : Failed \n"
"Expected behaviour: Routes are denied by prefix-list \n"
"Error {}".format(tc_name, result)
assert result is not True, "Testcase {} : Failed \nExpected behaviour: Routes are denied by prefix-list \nError {}".format(tc_name, result)
write_test_footer(tc_name)
@ -5449,8 +5444,7 @@ def test_route_map_set_and_match_tag_p0(request):
result = verify_rib(tgen, addr_type, dut, input_dict_2, expected=False)
assert (
result is not True
), "Testcase {} : Failed \n Expected Behavior: Routes are denied \n"
"Error {}".format(tc_name, result)
), "Testcase {} : Failed \n Expected Behavior: Routes are denied \nError {}".format(tc_name, result)
write_test_footer(tc_name)
@ -5853,8 +5847,7 @@ def test_route_map_set_and_match_metric_p0(request):
result = verify_rib(tgen, addr_type, dut, input_dict_2, expected=False)
assert (
result is not True
), "Testcase {} : Failed \n Expected Behavior: Routes are denied \n"
"Error {}".format(tc_name, result)
), "Testcase {} : Failed \n Expected Behavior: Routes are denied \nError {}".format(tc_name, result)
write_test_footer(tc_name)

View File

@ -1571,9 +1571,7 @@ def test_shut_noshut_p1(request):
sleep(HOLDDOWNTIMER + 1)
result = verify_bgp_convergence(tgen, topo, expected=False)
assert result is not True, "Testcase {} : Failed \n "
"Expected Behaviour: BGP will not be converged \n "
"Error {}".format(tc_name, result)
assert result is not True, "Testcase {} : Failed \nExpected Behaviour: BGP will not be converged \nError {}".format(tc_name, result)
for addr_type in ADDR_TYPES:
dut = "r2"
@ -1616,14 +1614,10 @@ def test_shut_noshut_p1(request):
}
result = verify_rib(tgen, addr_type, dut, input_dict_1, expected=False)
assert result is not True, "Testcase {} : Failed \n "
" Expected Behaviour: Routes are flushed out \n "
"Error {}".format(tc_name, result)
assert result is not True, "Testcase {} : Failed \nExpected Behaviour: Routes are flushed out \nError {}".format(tc_name, result)
result = verify_rib(tgen, addr_type, dut, input_dict_2, expected=False)
assert result is not True, "Testcase {} : Failed \n "
" Expected Behaviour: Routes are flushed out \n "
"Error {}".format(tc_name, result)
assert result is not True, "Testcase {} : Failed \nExpected Behaviour: Routes are flushed out \nError {}".format(tc_name, result)
step("Bring up connecting interface between R1<<>>R2 on R1.")
for intf in interfaces:
@ -1862,8 +1856,7 @@ def test_vrf_vlan_routing_table_p1(request):
result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1, expected=False)
assert (
result is not True
), "Testcase {} : Failed \n Expected Behaviour: Routes are"
" cleaned \n Error {}".format(tc_name, result)
), "Testcase {} : Failed \n Expected Behaviour: Routes are cleaned \n Error {}".format(tc_name, result)
step("Add/reconfigure the same VRF instance again")
@ -2180,7 +2173,7 @@ def test_restart_bgpd_daemon_p1(request):
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
result = verify_bgp_convergence(tgen, topo)
assert result is True, "Testcase () :Failed\n Error {}".format(tc_name, result)
assert result is True, "Testcase {} :Failed\n Error {}".format(tc_name, result)
step("Kill BGPd daemon on R1.")
kill_router_daemons(tgen, "r1", ["bgpd"])
@ -3392,14 +3385,12 @@ def test_vrf_name_significance_p1(request):
result = verify_rib(tgen, addr_type, dut, input_dict_1, expected=False)
assert (
result is not True
), "Testcase {} :Failed \n Expected Behaviour: Routes are not"
" present \n Error {}".format(tc_name, result)
), "Testcase {} :Failed \n Expected Behaviour: Routes are not present \n Error {}".format(tc_name, result)
result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1, expected=False)
assert (
result is not True
), "Testcase {} :Failed \n Expected Behaviour: Routes are not"
" present \n Error {}".format(tc_name, result)
), "Testcase {} :Failed \n Expected Behaviour: Routes are not present \n Error {}".format(tc_name, result)
for addr_type in ADDR_TYPES:
dut = "blue2"
@ -3417,14 +3408,12 @@ def test_vrf_name_significance_p1(request):
result = verify_rib(tgen, addr_type, dut, input_dict_2, expected=False)
assert result is not True, (
"Testcase {} :Failed \n Expected Behaviour: Routes are not"
" present \n Error {}".format(tc_name, result)
"Testcase {} :Failed \n Expected Behaviour: Routes are not present \n Error {}".format(tc_name, result)
)
result = verify_bgp_rib(tgen, addr_type, dut, input_dict_2, expected=False)
assert result is not True, (
"Testcase {} :Failed \n Expected Behaviour: Routes are not"
" present \n Error {}".format(tc_name, result)
"Testcase {} :Failed \n Expected Behaviour: Routes are not present \n Error {}".format(tc_name, result)
)
step("Create 2 new VRFs PINK_A and GREY_A IN R3")

View File

@ -224,6 +224,7 @@ def disable_route_map_to_prefer_global_next_hop(tgen, topo):
"""
tc_name = request.node.name
logger.info("Remove prefer-global rmap applied on neighbors")
input_dict = {
"r1": {