From 914faab594cf04d7ac4e82a63cdf77c621b9259f Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Fri, 9 Apr 2021 12:12:34 -0400 Subject: [PATCH 1/4] tests: fix pylint errors in mcast-pim-static-rp-topo1 Fix pylint errors. Signed-off-by: Mark Stapp --- .../test_multicast_pim_static_rp.py | 387 +++++++++--------- 1 file changed, 199 insertions(+), 188 deletions(-) diff --git a/tests/topotests/multicast-pim-static-rp-topo1/test_multicast_pim_static_rp.py b/tests/topotests/multicast-pim-static-rp-topo1/test_multicast_pim_static_rp.py index e90230eb3b..caa0de3d41 100755 --- a/tests/topotests/multicast-pim-static-rp-topo1/test_multicast_pim_static_rp.py +++ b/tests/topotests/multicast-pim-static-rp-topo1/test_multicast_pim_static_rp.py @@ -101,9 +101,9 @@ import os import sys import json import time -import pytest from time import sleep import datetime +import pytest # Save the Current Working Directory to find configuration files. CWD = os.path.dirname(os.path.realpath(__file__)) @@ -114,9 +114,12 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from lib.topogen import Topogen, get_topogen from mininet.topo import Topo +from lib.topogen import Topogen, get_topogen +from lib.topolog import logger +from lib.topojson import build_topo_from_json, build_config_from_json + from lib.common_config import ( start_topology, write_test_header, @@ -149,16 +152,14 @@ from lib.pim import ( clear_ip_mroute, clear_ip_mroute_verify, ) -from lib.topolog import logger -from lib.topojson import build_topo_from_json, build_config_from_json # Reading the data from JSON File for topology and configuration creation jsonFile = "{}/multicast_pim_static_rp.json".format(CWD) try: with open(jsonFile, "r") as topoJson: - topo = json.load(topoJson) + TOPO = json.load(topoJson) except IOError: - logger.info("Could not read file:", jsonFile) + logger.info("Could not read file: %s", jsonFile) # Global variables GROUP_RANGE_ALL = "224.0.0.0/4" @@ -203,8 +204,11 @@ class CreateTopo(Topo): tgen = get_topogen(self) # Building topology from json file - build_topo_from_json(tgen, topo) + build_topo_from_json(tgen, TOPO) + def dumdum(self): + """ Dummy """ + print("%s", self.name) def setup_module(mod): """ @@ -212,10 +216,9 @@ def setup_module(mod): * `mod`: module name """ - global topo testsuite_run_time = time.asctime(time.localtime(time.time())) - logger.info("Testsuite start time: {}".format(testsuite_run_time)) + logger.info("Testsuite start time: %s", testsuite_run_time) logger.info("=" * 40) topology = """ @@ -229,7 +232,7 @@ def setup_module(mod): r4 """ - logger.info("Master Topology: \n {}".format(topology)) + logger.info("Master Topology: \n %s", topology) logger.info("Running setup_module to create topology") @@ -239,7 +242,7 @@ def setup_module(mod): # ... and here it calls Mininet initialization functions. # get list of daemons needs to be started for this suite. - daemons = topo_daemons(tgen, topo) + daemons = topo_daemons(tgen, TOPO) # Starting topology, create tmp files which are loaded to routers # to start deamons and then start routers @@ -250,10 +253,10 @@ def setup_module(mod): pytest.skip(tgen.errors) # Creating configuration from JSON - build_config_from_json(tgen, topo) + build_config_from_json(tgen, TOPO) # Verify PIM neighbors - result = verify_pim_neighbors(tgen, topo) + result = verify_pim_neighbors(tgen, TOPO) assert result is True, "setup_module :Failed \n Error:" " {}".format(result) logger.info("Running setup_module() done") @@ -270,7 +273,7 @@ def teardown_module(): tgen.stop_topology() logger.info( - "Testsuite end time: {}".format(time.asctime(time.localtime(time.time()))) + "Testsuite end time: %s", time.asctime(time.localtime(time.time())) ) logger.info("=" * 40) @@ -335,9 +338,11 @@ def verify_mroute_repopulated(uptime_before, uptime_after): ) return errormsg - d1 = datetime.datetime.strptime(uptime_before[group][source], "%H:%M:%S") - d2 = datetime.datetime.strptime(uptime_after[group][source], "%H:%M:%S") - if d2 >= d1: + d_1 = datetime.datetime.strptime(uptime_before[group][source], + "%H:%M:%S") + d_2 = datetime.datetime.strptime(uptime_after[group][source], + "%H:%M:%S") + if d_2 >= d_1: errormsg = "mroute (%s, %s) is not " "repopulated [FAILED!!]" % ( source, group, @@ -360,7 +365,7 @@ def verify_state_incremented(state_before, state_after): """ for router, state_data in state_before.items(): - for state, value in state_data.items(): + for state, _ in state_data.items(): if state_before[router][state] >= state_after[router][state]: errormsg = ( "[DUT: %s]: state %s value has not" @@ -422,7 +427,7 @@ def test_add_delete_static_RP_p0(request): step("r1: Verify show ip igmp group without any IGMP join") dut = "r1" interface = "r1-r0-eth0" - result = verify_igmp_groups(tgen, dut, interface, GROUP_ADDRESS, expected=False) + result = verify_igmp_groups(tgen, dut, interface, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: igmp group present without any IGMP join \n Error: {}".format( @@ -436,8 +441,9 @@ def test_add_delete_static_RP_p0(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase {} : Failed \n state_before is not dictionary\n Error: {}".format( + tc_name, result + ) step("r0 : Send IGMP join") result = iperfSendIGMPJoin(tgen, "r0", GROUP_ADDRESS, join_interval=1) @@ -453,7 +459,7 @@ def test_add_delete_static_RP_p0(request): iif = "r1-r2-eth1" rp_address = "1.0.2.17" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -487,13 +493,12 @@ def test_add_delete_static_RP_p0(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify RP info") result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE, expected=False - ) + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE) assert ( result is not True ), "Testcase {} : Failed \n " "r1: RP info present \n Error: {}".format( @@ -501,7 +506,7 @@ def test_add_delete_static_RP_p0(request): ) step("r1: Verify upstream IIF interface") - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False) + result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream IIF interface present \n Error: {}".format(tc_name, result) @@ -509,7 +514,7 @@ def test_add_delete_static_RP_p0(request): step("r1: Verify upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False + tgen, dut, iif, STAR, GROUP_ADDRESS ) assert result is not True, ( "Testcase {} : Failed \n " @@ -519,13 +524,13 @@ def test_add_delete_static_RP_p0(request): ) step("r1: Verify PIM state") - result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS, expected=False) + result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS) assert result is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, result ) step("r1: Verify ip mroutes") - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert ( result is not True ), "Testcase {} : Failed \n " "r1: mroutes are still present \n Error: {}".format( @@ -536,8 +541,9 @@ def test_add_delete_static_RP_p0(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase {} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, result + ) result = verify_state_incremented(state_before, state_after) assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result) @@ -576,7 +582,7 @@ def test_SPT_RPT_path_same_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -604,7 +610,7 @@ def test_SPT_RPT_path_same_p1(request): rp_address = "1.0.2.17" iif = "lo" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -685,8 +691,7 @@ def test_SPT_RPT_path_same_p1(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False - ) + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S, G) upstream join state is up and join timer is running\n Error: {}".format( @@ -732,7 +737,7 @@ def test_not_reachable_static_RP_p0(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -754,7 +759,7 @@ def test_not_reachable_static_RP_p0(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " + ), "Testcase{} : Failed \n state_before is not dictionary \n " \ "Error: {}".format(tc_name, result) step("Enable IGMP on r1 interface and send IGMP " "join (225.1.1.1) to r1") @@ -770,7 +775,7 @@ def test_not_reachable_static_RP_p0(request): iif = "r1-r2-eth1" rp_address = "1.0.2.17" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -810,7 +815,7 @@ def test_not_reachable_static_RP_p0(request): step("r1: Check RP detail using show ip pim rp-info OIF should be unknown") result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, "Unknown", rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, "Unknown", rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -818,7 +823,7 @@ def test_not_reachable_static_RP_p0(request): "r1 : OIL should be same and IIF should be cleared on R1 verify" "using show ip pim state" ) - result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS, expected=False) + result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "OIL is not same and IIF is not cleared on R1 \n Error: {}".format( @@ -827,7 +832,7 @@ def test_not_reachable_static_RP_p0(request): ) step("r1: upstream IIF should be unknown , verify using show ip pim" "upstream") - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False) + result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream IIF is not unknown \n Error: {}".format(tc_name, result) @@ -838,7 +843,7 @@ def test_not_reachable_static_RP_p0(request): "verify using show ip pim upstream" ) result = verify_join_state_and_timer( - tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False + tgen, dut, iif, STAR, GROUP_ADDRESS ) assert result is not True, ( "Testcase {} : Failed \n " @@ -854,21 +859,21 @@ def test_not_reachable_static_RP_p0(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " + ), "Testcase{} : Failed \n state_before is not dictionary \n " \ "Error: {}".format(tc_name, result) result = verify_state_incremented(state_before, state_after) assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result) step("r1: (*, G) cleared from mroute table using show ip mroute") - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r1: (*, G) are not cleared from mroute table \n Error: {}".format( tc_name, result ) ) - logger.info("Expected behavior: {}".format(result)) + logger.info("Expected behavior: %s", result) # Uncomment next line for debugging # tgen.mininet_cli() @@ -898,7 +903,7 @@ def test_add_RP_after_join_received_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -924,7 +929,7 @@ def test_add_RP_after_join_received_p1(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify rp-info") @@ -932,7 +937,7 @@ def test_add_RP_after_join_received_p1(request): rp_address = "1.0.2.17" iif = "r1-r2-eth1" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE, expected=False + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert ( result is not True @@ -945,12 +950,14 @@ def test_add_RP_after_join_received_p1(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " + ), "Testcase{} : Failed \n state_before is not dictionary \n " \ "Error: {}".format(tc_name, result) step("r0 : Send IGMP join (225.1.1.1) to r1, when rp is not configured" "in r1") result = iperfSendIGMPJoin(tgen, "r0", GROUP_ADDRESS, join_interval=1) - 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("r1: IGMP group is received on R1 verify using show ip igmp groups") oif = "r1-r0-eth0" @@ -958,7 +965,7 @@ def test_add_RP_after_join_received_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify upstream IIF interface") - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False) + result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream IFF interface is present \n Error: {}".format(tc_name, result) @@ -967,7 +974,7 @@ def test_add_RP_after_join_received_p1(request): step("r1: Verify upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False + tgen, dut, iif, STAR, GROUP_ADDRESS ) assert result is not True, ( "Testcase {} : Failed \n " @@ -977,7 +984,7 @@ def test_add_RP_after_join_received_p1(request): ) step("r1: Verify PIM state") - result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS, expected=False) + result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS) assert ( result is not True ), "Testcase {} : Failed \n " "r1: PIM state is up\n Error: {}".format( @@ -985,7 +992,7 @@ def test_add_RP_after_join_received_p1(request): ) step("r1: Verify ip mroutes") - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert ( result is not True ), "Testcase {} : Failed \n " "r1: mroutes are still present\n Error: {}".format( @@ -1006,12 +1013,12 @@ def test_add_RP_after_join_received_p1(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify rp-info") result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -1030,12 +1037,12 @@ def test_add_RP_after_join_received_p1(request): step("r1 : Verify ip mroutes") result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - logger.info("Expected behavior: {}".format(result)) + logger.info("Expected behavior: %s", result) state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " + ), "Testcase{} : Failed \n state_before is not dictionary \n " \ "Error: {}".format(tc_name, result) result = verify_state_incremented(state_before, state_after) @@ -1068,7 +1075,7 @@ def test_reachable_static_RP_after_join_p0(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -1083,7 +1090,7 @@ def test_reachable_static_RP_after_join_p0(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " + ), "Testcase{} : Failed \n state_before is not dictionary \n " \ "Error: {}".format(tc_name, result) step("r1: Make RP un-reachable") @@ -1098,7 +1105,7 @@ def test_reachable_static_RP_after_join_p0(request): step("r1: Verify rp-info") rp_address = "1.0.2.17" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_ADDRESS, "Unknown", rp_address, SOURCE + tgen, TOPO, dut, GROUP_ADDRESS, "Unknown", rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -1113,7 +1120,7 @@ def test_reachable_static_RP_after_join_p0(request): step("r1 : Verify upstream IIF interface") iif = "r1-r2-eth1" - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False) + result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream IIF interface is present\n Error: {}".format(tc_name, result) @@ -1121,7 +1128,7 @@ def test_reachable_static_RP_after_join_p0(request): step("r1 : Verify upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False + tgen, dut, iif, STAR, GROUP_ADDRESS ) assert result is not True, ( "Testcase {} : Failed \n " @@ -1131,7 +1138,7 @@ def test_reachable_static_RP_after_join_p0(request): ) step("r1 : Verify PIM state") - result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS, expected=False) + result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS) assert ( result is not True ), "Testcase {} : Failed \n " "r1: PIM state is up\n Error: {}".format( @@ -1139,7 +1146,7 @@ def test_reachable_static_RP_after_join_p0(request): ) step("r1 : Verify ip mroutes") - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert ( result is not True ), "Testcase {} : Failed \n " "r1: mroutes are still present\n Error: {}".format( @@ -1156,7 +1163,7 @@ def test_reachable_static_RP_after_join_p0(request): step("r1 : Verify rp-info") result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -1175,13 +1182,13 @@ def test_reachable_static_RP_after_join_p0(request): step("r1 : Verify ip mroutes") result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - logger.info("Expected behavior: {}".format(result)) + logger.info("Expected behavior: %s", result) step("r1 : Verify pim interface traffic") state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " + ), "Testcase{} : Failed \n state_before is not dictionary \n " \ "Error: {}".format(tc_name, result) result = verify_state_incremented(state_before, state_after) @@ -1235,7 +1242,7 @@ def test_send_join_on_higher_preffered_rp_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -1272,7 +1279,7 @@ def test_send_join_on_higher_preffered_rp_p1(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " + ), "Testcase{} : Failed \n state_before is not dictionary \n " \ "Error: {}".format(tc_name, result) step("r0 : Send IGMP join for 225.1.1.1") @@ -1299,21 +1306,21 @@ def test_send_join_on_higher_preffered_rp_p1(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1 : Verify RP info for group 224.0.0.0/4") rp_address_1 = "1.0.2.17" iif = "r1-r2-eth1" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address_1, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address_1, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1 : Verify RP info for group 225.1.1.1") rp_address_2 = "1.0.4.17" iif = "r1-r4-eth3" - result = verify_pim_rp_info(tgen, topo, dut, GROUP_RANGE, iif, rp_address_2, SOURCE) + result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_RANGE, iif, rp_address_2, SOURCE) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1 : Verify join is sent to higher preferred RP") @@ -1321,7 +1328,7 @@ def test_send_join_on_higher_preffered_rp_p1(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " + ), "Testcase{} : Failed \n state_before is not dictionary \n " \ "Error: {}".format(tc_name, result) result = verify_state_incremented(state_before, state_after) @@ -1344,7 +1351,7 @@ def test_send_join_on_higher_preffered_rp_p1(request): result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("r1 : Verify joinTx, pruneTx count before RP gets deleted") state_dict = {"r1": {"r1-r2-eth1": ["joinTx"], "r1-r4-eth3": ["pruneTx"]}} @@ -1352,7 +1359,7 @@ def test_send_join_on_higher_preffered_rp_p1(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " + ), "Testcase{} : Failed \n state_before is not dictionary \n " \ "Error: {}".format(tc_name, result) step("r1 : Delete RP configuration for 225.1.1.1") @@ -1370,20 +1377,20 @@ def test_send_join_on_higher_preffered_rp_p1(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1 : Verify rp-info for group 224.0.0.0/4") iif = "r1-r2-eth1" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address_1, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address_1, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1 : Verify rp-info for group 225.1.1.1") iif = "r1-r4-eth3" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE, oif, rp_address_2, SOURCE, expected=False + tgen, TOPO, dut, GROUP_RANGE, oif, rp_address_2, SOURCE ) assert result is not True, ( "Testcase {} : Failed \n " @@ -1399,7 +1406,7 @@ def test_send_join_on_higher_preffered_rp_p1(request): iif = "r1-r2-eth1" result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - logger.info("Expected behavior: {}".format(result)) + logger.info("Expected behavior: %s", result) step( "r1 : Verify IIF and OIL in show ip pim state updated when higher" @@ -1433,7 +1440,7 @@ def test_send_join_on_higher_preffered_rp_p1(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " + ), "Testcase{} : Failed \n state_before is not dictionary \n " \ "Error: {}".format(tc_name, result) result = verify_state_incremented(state_before, state_after) @@ -1472,7 +1479,7 @@ def test_RP_configured_as_LHR_1_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -1532,7 +1539,7 @@ def test_RP_configured_as_LHR_1_p1(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Configure r1(LHR) as RP") @@ -1579,7 +1586,7 @@ def test_RP_configured_as_LHR_1_p1(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) shutdown_bringup_interface(tgen, "r1", "lo", False) @@ -1592,7 +1599,7 @@ def test_RP_configured_as_LHR_1_p1(request): rp_address = "1.0.1.17" iif = "lo" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -1642,7 +1649,7 @@ def test_RP_configured_as_LHR_1_p1(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS ) assert result is not True, ( "Testcase {} : Failed \n " @@ -1688,7 +1695,7 @@ def test_RP_configured_as_LHR_2_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -1748,7 +1755,7 @@ def test_RP_configured_as_LHR_2_p1(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1, r2, r3, r4: Configure r1(LHR) as RP") @@ -1795,14 +1802,14 @@ def test_RP_configured_as_LHR_2_p1(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify RP info") dut = "r1" rp_address = "1.0.1.17" iif = "lo" - result = verify_pim_rp_info(tgen, topo, dut, GROUP_ADDRESS, iif, rp_address, SOURCE) + result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_ADDRESS, iif, rp_address, SOURCE) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r5: Send multicast traffic for group 225.1.1.1") @@ -1851,7 +1858,7 @@ def test_RP_configured_as_LHR_2_p1(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS ) assert result is not True, ( "Testcase {} : Failed \n " @@ -1898,7 +1905,7 @@ def test_RP_configured_as_FHR_1_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -1957,7 +1964,7 @@ def test_RP_configured_as_FHR_1_p1(request): } }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1, r2, r3, r4: Configure r3(FHR) as RP") @@ -2004,7 +2011,7 @@ def test_RP_configured_as_FHR_1_p1(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify RP info") @@ -2012,7 +2019,7 @@ def test_RP_configured_as_FHR_1_p1(request): rp_address = "1.0.3.17" iif = "r1-r3-eth2" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -2061,7 +2068,7 @@ def test_RP_configured_as_FHR_1_p1(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS ) assert result is not True, ( "Testcase {} : Failed \n " @@ -2072,8 +2079,12 @@ def test_RP_configured_as_FHR_1_p1(request): step("r3: Verify (S, G) ip mroutes") oif = "r3-r1-eth0" - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif) - assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, + iif, oif) + assert result is True, "Testcase {} :Failed \n Error: {}".format( + tc_name, + result + ) # Uncomment next line for debugging # tgen.mininet_cli() @@ -2107,7 +2118,7 @@ def test_RP_configured_as_FHR_2_p2(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -2167,7 +2178,7 @@ def test_RP_configured_as_FHR_2_p2(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1, r2, r3, r4: Configure r3(FHR) as RP") @@ -2214,7 +2225,7 @@ def test_RP_configured_as_FHR_2_p2(request): }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify RP info") @@ -2222,7 +2233,7 @@ def test_RP_configured_as_FHR_2_p2(request): rp_address = "1.0.3.17" iif = "r1-r3-eth2" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -2272,7 +2283,7 @@ def test_RP_configured_as_FHR_2_p2(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS ) assert result is not True, ( "Testcase {} : Failed \n " @@ -2320,7 +2331,7 @@ def test_SPT_RPT_path_different_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -2335,7 +2346,7 @@ def test_SPT_RPT_path_different_p1(request): dut = "r2" rp_address = "1.0.2.17" iif = "lo" - result = verify_pim_rp_info(tgen, topo, dut, GROUP_ADDRESS, iif, rp_address, SOURCE) + result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_ADDRESS, iif, rp_address, SOURCE) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r0: Send IGMP join") @@ -2401,7 +2412,7 @@ def test_SPT_RPT_path_different_p1(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS ) assert result is not True, ( "Testcase {} : Failed \n " @@ -2425,7 +2436,7 @@ def test_SPT_RPT_path_different_p1(request): step("r2: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS ) assert result is not True, ( "Testcase {} : Failed \n " @@ -2475,7 +2486,7 @@ def test_clear_pim_configuration_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -2492,7 +2503,7 @@ def test_clear_pim_configuration_p1(request): rp_address = "1.0.2.17" oif = "lo" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -2572,7 +2583,7 @@ def test_restart_pimd_process_p2(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -2589,7 +2600,7 @@ def test_restart_pimd_process_p2(request): rp_address = "1.0.2.17" oif = "lo" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -2656,7 +2667,7 @@ def test_restart_pimd_process_p2(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS ) assert result is not True, ( "Testcase {} : Failed \n " @@ -2676,7 +2687,7 @@ def test_restart_pimd_process_p2(request): logger.info("waiting for 10 sec to make sure old mroute time is higher") sleep(10) uptime_before = verify_ip_mroutes( - tgen, dut, STAR, GROUP_ADDRESS, iif, oil, return_uptime=True, wait=60 + tgen, dut, STAR, GROUP_ADDRESS, iif, oil, return_uptime=True, mwait=60 ) assert isinstance(uptime_before, dict), "Testcase{} : Failed Error: {}".format( tc_name, result @@ -2692,7 +2703,7 @@ def test_restart_pimd_process_p2(request): sleep(5) uptime_after = verify_ip_mroutes( - tgen, dut, STAR, GROUP_ADDRESS, iif, oil, return_uptime=True, wait=10 + tgen, dut, STAR, GROUP_ADDRESS, iif, oil, return_uptime=True, mwait=10 ) assert isinstance(uptime_after, dict), "Testcase{} : Failed Error: {}".format( tc_name, result @@ -2731,7 +2742,7 @@ def test_multiple_groups_same_RP_address_p2(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -2754,79 +2765,79 @@ def test_multiple_groups_same_RP_address_p2(request): rp_address = "1.0.2.17" oif = "lo" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - GROUP_ADDRESS_LIST = GROUP_ADDRESS_LIST_1 + GROUP_ADDRESS_LIST_2 + group_address_list = GROUP_ADDRESS_LIST_1 + GROUP_ADDRESS_LIST_2 step("r0: Send IGMP join for 10 groups") - result = iperfSendIGMPJoin(tgen, "r0", GROUP_ADDRESS_LIST, join_interval=1) + result = iperfSendIGMPJoin(tgen, "r0", group_address_list, join_interval=1) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify IGMP groups") dut = "r1" oif = "r1-r0-eth0" - result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS_LIST) + result = verify_igmp_groups(tgen, dut, oif, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r5: Send multicast traffic for group 225.1.1.1") - result = iperfSendTraffic(tgen, "r5", GROUP_ADDRESS_LIST, 32, 2500) + result = iperfSendTraffic(tgen, "r5", group_address_list, 32, 2500) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (*, G) upstream IIF interface") dut = "r1" iif = "r1-r2-eth1" - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (*, G) upstream join state and join timer") - result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (*, G) ip mroutes") oif = "r1-r0-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, STAR, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (S, G) upstream IIF interface") iif = "r1-r3-eth2" - result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST + tgen, dut, iif, SOURCE_ADDRESS, group_address_list ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (S, G) ip mroutes") - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (*, G) upstream IIF interface") dut = "r2" iif = "lo" - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (*, G) upstream join state and join timer") - result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (*, G) ip mroutes") oif = "r2-r1-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, STAR, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream IIF interface") dut = "r3" iif = "r3-r5-eth3" - result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, expected=False + tgen, dut, iif, SOURCE_ADDRESS, group_address_list ) assert result is not True, ( "Testcase {} : Failed \n " @@ -2837,20 +2848,20 @@ def test_multiple_groups_same_RP_address_p2(request): step("r3: Verify (S, G) ip mroutes") oif = "r3-r1-eth0" - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (S, G) upstream IIF interface") dut = "r2" iif = "r2-r3-eth1" result = verify_upstream_iif( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, joinState="NotJoined" + tgen, dut, iif, SOURCE_ADDRESS, group_address_list, joinState="NotJoined" ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, expected=False + tgen, dut, iif, SOURCE_ADDRESS, group_address_list ) assert result is not True, ( "Testcase {} : Failed \n " @@ -2861,7 +2872,7 @@ def test_multiple_groups_same_RP_address_p2(request): step("r2: Verify (S, G) ip mroutes") oif = "none" - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Delete RP configuration") @@ -2879,7 +2890,7 @@ def test_multiple_groups_same_RP_address_p2(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Shut the interface r1-r2-eth1 from R1 to R2") @@ -2905,7 +2916,7 @@ def test_multiple_groups_same_RP_address_p2(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Shut the interface r1-r0-eth0 from R1 to R2") @@ -2919,59 +2930,59 @@ def test_multiple_groups_same_RP_address_p2(request): step("r1: Verify (*, G) upstream IIF interface") dut = "r1" iif = "r1-r2-eth1" - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (*, G) upstream join state and join timer") - result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (*, G) ip mroutes") oif = "r1-r0-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, STAR, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (S, G) upstream IIF interface") iif = "r1-r3-eth2" - result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST + tgen, dut, iif, SOURCE_ADDRESS, group_address_list ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (S, G) ip mroutes") - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (*, G) upstream IIF interface") dut = "r2" iif = "lo" - result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (*, G) upstream join state and join timer") - result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (*, G) ip mroutes") oif = "r2-r1-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, STAR, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (S, G) upstream IIF interface") dut = "r2" iif = "r2-r3-eth1" result = verify_upstream_iif( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, joinState="NotJoined" + tgen, dut, iif, SOURCE_ADDRESS, group_address_list, joinState="NotJoined" ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, expected=False + tgen, dut, iif, SOURCE_ADDRESS, group_address_list ) assert result is not True, ( "Testcase {} : Failed \n " @@ -2982,18 +2993,18 @@ def test_multiple_groups_same_RP_address_p2(request): step("r2: Verify (S, G) ip mroutes") oif = "none" - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream IIF interface") dut = "r3" iif = "r3-r5-eth3" - result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST) + result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, expected=False + tgen, dut, iif, SOURCE_ADDRESS, group_address_list ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3004,7 +3015,7 @@ def test_multiple_groups_same_RP_address_p2(request): step("r3: Verify (S, G) ip mroutes") oif = "r3-r1-eth0" - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST, iif, oif) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) write_test_footer(tc_name) @@ -3040,7 +3051,7 @@ def test_multiple_groups_different_RP_address_p2(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -3060,7 +3071,7 @@ def test_multiple_groups_different_RP_address_p2(request): } } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) input_dict = { @@ -3085,7 +3096,7 @@ def test_multiple_groups_different_RP_address_p2(request): } }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify RP info") @@ -3093,7 +3104,7 @@ def test_multiple_groups_different_RP_address_p2(request): rp_address = "1.0.2.17" oif = "lo" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_LIST_1, oif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_LIST_1, oif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -3101,23 +3112,23 @@ def test_multiple_groups_different_RP_address_p2(request): dut = "r4" rp_address = "1.0.4.17" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_LIST_2, oif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_LIST_2, oif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - GROUP_ADDRESS_LIST = GROUP_ADDRESS_LIST_1 + GROUP_ADDRESS_LIST_2 + group_address_list = GROUP_ADDRESS_LIST_1 + GROUP_ADDRESS_LIST_2 step("r0: Send IGMP join") - result = iperfSendIGMPJoin(tgen, "r0", GROUP_ADDRESS_LIST, join_interval=1) + result = iperfSendIGMPJoin(tgen, "r0", group_address_list, join_interval=1) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify IGMP groups") dut = "r1" oif = "r1-r0-eth0" - result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS_LIST) + result = verify_igmp_groups(tgen, dut, oif, group_address_list) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r5: Send multicast traffic for group 225.1.1.1") - result = iperfSendTraffic(tgen, "r5", GROUP_ADDRESS_LIST, 32, 2500) + result = iperfSendTraffic(tgen, "r5", group_address_list, 32, 2500) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Verify (*, G) upstream IIF interface") @@ -3175,7 +3186,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r2: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3199,7 +3210,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3271,7 +3282,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r4: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3295,7 +3306,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2 ) assert result is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, result @@ -3333,7 +3344,7 @@ def test_multiple_groups_different_RP_address_p2(request): } }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1, r2, r3, r4: Re-configure RP") @@ -3359,7 +3370,7 @@ def test_multiple_groups_different_RP_address_p2(request): } }, } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Shut the interface r1-r2-eth1 from R1 to R2") @@ -3448,7 +3459,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r2: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3472,7 +3483,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3544,7 +3555,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r4: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3568,7 +3579,7 @@ def test_multiple_groups_different_RP_address_p2(request): step("r3: Verify (S, G) upstream join state and join timer") result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, expected=False + tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2 ) assert result is not True, ( "Testcase {} : Failed \n " @@ -3611,7 +3622,7 @@ def test_shutdown_primary_path_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -3630,7 +3641,7 @@ def test_shutdown_primary_path_p1(request): rp_address = "1.0.2.17" iif = "r1-r2-eth1" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -3701,7 +3712,7 @@ def test_shutdown_primary_path_p1(request): dut = "r1" iif = "r1-r3-eth2" oif = "r1-r0-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r1: (*,G) mroutes are not cleared after shut of R1 to R3 link\n Error: {}".format( @@ -3713,7 +3724,7 @@ def test_shutdown_primary_path_p1(request): dut = "r2" iif = "lo" oif = "r2-r3-eth1" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r2: (*,G) mroutes are not cleared after shut of R1 to R3 link\n Error: {}".format( @@ -3725,7 +3736,7 @@ def test_shutdown_primary_path_p1(request): dut = "r3" iif = "r3-r2-eth1" oif = "r3-r1-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r3: (*,G) mroutes are not cleared after shut of R1 to R3 link\n Error: {}".format( @@ -3804,7 +3815,7 @@ def test_delete_RP_shut_noshut_upstream_interface_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -3821,7 +3832,7 @@ def test_delete_RP_shut_noshut_upstream_interface_p1(request): rp_address = "1.0.2.17" iif = "r1-r2-eth1" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -3863,7 +3874,7 @@ def test_delete_RP_shut_noshut_upstream_interface_p1(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r1: Shut the interface r1-r2-eth1 from R1 to R2") @@ -3890,7 +3901,7 @@ def test_delete_RP_shut_noshut_upstream_interface_p1(request): dut = "r1" iif = "r1-r2-eth1" oif = "r1-r0-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r1: (*,G) mroutes are not cleared after shut of R1 to R0 link\n Error: {}".format( @@ -3902,7 +3913,7 @@ def test_delete_RP_shut_noshut_upstream_interface_p1(request): dut = "r2" iif = "lo" oif = "r2-r1-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r2: (*,G) mroutes are not cleared after shut of R1 to R0 link\n Error: {}".format( @@ -3937,7 +3948,7 @@ def test_delete_RP_shut_noshut_RP_interface_p1(request): reset_config_on_routers(tgen) kill_iperf(tgen) clear_ip_mroute(tgen) - clear_ip_pim_interface_traffic(tgen, topo) + clear_ip_pim_interface_traffic(tgen, TOPO) step("pre-configuration to send IGMP join and multicast traffic") result = config_to_send_igmp_join_and_traffic(tgen, tc_name) @@ -3954,7 +3965,7 @@ def test_delete_RP_shut_noshut_RP_interface_p1(request): rp_address = "1.0.2.17" iif = "r1-r2-eth1" result = verify_pim_rp_info( - tgen, topo, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -3995,7 +4006,7 @@ def test_delete_RP_shut_noshut_RP_interface_p1(request): } } - result = create_pim_config(tgen, topo, input_dict) + result = create_pim_config(tgen, TOPO, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Shut the RP interface lo") @@ -4017,7 +4028,7 @@ def test_delete_RP_shut_noshut_RP_interface_p1(request): dut = "r1" iif = "r1-r2-eth1" oif = "r1-r0-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r1: (*,G) mroutes are not cleared after shut of R1 to R2 and R3 link\n Error: {}".format( @@ -4029,7 +4040,7 @@ def test_delete_RP_shut_noshut_RP_interface_p1(request): dut = "r2" iif = "lo" oif = "r2-r1-eth0" - result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False) + result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) assert result is not True, ( "Testcase {} : Failed \n " "r2: (*,G) mroutes are not cleared after shut of R1 to R2 and R3 link\n Error: {}".format( @@ -4041,5 +4052,5 @@ def test_delete_RP_shut_noshut_RP_interface_p1(request): if __name__ == "__main__": - args = ["-s"] + sys.argv[1:] - sys.exit(pytest.main(args)) + ARGS = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(ARGS)) From aa59a7090a17f63656d267da669f2c6496e27411 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Fri, 9 Apr 2021 12:34:18 -0400 Subject: [PATCH 2/4] tests: fix pylint errors in static_routing_with_ebgp tests Fix pylint errors; also enable the test in 'topo4', which has never run. Signed-off-by: Mark Stapp --- .../test_static_routes_topo1_ebgp.py | 234 +++++++++--------- .../test_static_routes_topo2_ebgp.py | 69 +++--- .../test_static_routes_topo3_ebgp.py | 60 ++--- .../test_static_routes_topo4_ebgp.py | 20 +- 4 files changed, 195 insertions(+), 188 deletions(-) diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py index a4cc8e8e7a..99a04d26de 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py @@ -40,10 +40,11 @@ import platform CWD = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(CWD, "../")) sys.path.append(os.path.join(CWD, "../lib/")) + # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo from lib.topogen import Topogen, get_topogen +from mininet.topo import Topo from lib.topotest import version_cmp # Import topoJson from lib, to create topology and initial configuration @@ -68,15 +69,14 @@ from lib.topojson import build_topo_from_json, build_config_from_json pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] # Reading the data from JSON File for topology creation -jsonFile = "{}/static_routes_topo1_ebgp.json".format(CWD) +JSONFILE = "{}/static_routes_topo1_ebgp.json".format(CWD) try: - with open(jsonFile, "r") as topoJson: + with open(JSONFILE, "r") as topoJson: topo = json.load(topoJson) except IOError: - assert False, "Could not read file {}".format(jsonFile) + assert False, "Could not read file {}".format(JSONFILE) # Global variables -BGP_CONVERGENCE = False ADDR_TYPES = check_address_types() NETWORK = {"ipv4": ["11.0.20.1/32", "11.0.20.2/32"], "ipv6": ["2::1/128", "2::2/128"]} NETWORK2 = {"ipv4": "11.0.20.1/32", "ipv6": "2::1/128"} @@ -98,6 +98,10 @@ class CreateTopo(Topo): # Building topology from json file build_topo_from_json(tgen, topo) + def dumdum(self): + """ Dummy """ + print("%s", self.name) + def setup_module(mod): """ @@ -105,7 +109,7 @@ def setup_module(mod): * `mod`: module name """ - global topo + testsuite_run_time = time.asctime(time.localtime(time.time())) logger.info("Testsuite start time: {}".format(testsuite_run_time)) logger.info("=" * 40) @@ -131,15 +135,15 @@ def setup_module(mod): pytest.skip(error_msg) # Checking BGP convergence - global BGP_CONVERGENCE - global ADDR_TYPES + # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) + # Api call verify whether BGP is converged - BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo) - assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error: {}".format( - BGP_CONVERGENCE + converged = verify_bgp_convergence(tgen, topo) + assert converged is True, "setup_module :Failed \n Error: {}".format( + converged ) logger.info("Running setup_module() done") @@ -152,7 +156,7 @@ def teardown_module(mod): * `mod`: module name """ - logger.info("Running teardown_module to delete topology") + logger.info("Running teardown_module to delete topology: %s", mod) tgen = get_topogen() @@ -166,7 +170,11 @@ def teardown_module(mod): def populate_nh(): - NEXT_HOP_IP = { + """ + Populate nexthops. + """ + + next_hop_ip = { "nh1": { "ipv4": topo["routers"]["r1"]["links"]["r2-link0"]["ipv4"].split("/")[0], "ipv6": topo["routers"]["r1"]["links"]["r2-link0"]["ipv6"].split("/")[0], @@ -176,7 +184,7 @@ def populate_nh(): "ipv6": topo["routers"]["r1"]["links"]["r2-link1"]["ipv6"].split("/")[0], }, } - return NEXT_HOP_IP + return next_hop_ip ##################################################### @@ -199,7 +207,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): pytest.skip(tgen.errors) reset_config_on_routers(tgen) - NEXT_HOP_IP = populate_nh() + next_hop_ip = populate_nh() step( "Configure IPv4 static route (10.1.1.1) in R2 with next hop N1" @@ -213,11 +221,11 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], }, { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], }, ] } @@ -233,7 +241,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "On R2, static route installed in RIB using show ip route" " with 2 ECMP next hop " ) - nh = [NEXT_HOP_IP["nh1"][addr_type], NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type], next_hop_ip["nh2"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( @@ -268,7 +276,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "delete": True, } ] @@ -284,7 +292,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "On R2, after removing the static route with N1 , " "route become active with nexthop N2 and vice versa." ) - nh = NEXT_HOP_IP["nh1"][addr_type] + nh = next_hop_ip["nh1"][addr_type] result = verify_rib( tgen, addr_type, @@ -300,11 +308,11 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): tc_name ) - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("Configure the static route with nexthop N1") @@ -314,7 +322,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], } ] } @@ -333,7 +341,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "delete": True, } ] @@ -350,7 +358,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "On R2, after removing the static route with N2 , " "route become active with nexthop N1 and vice versa." ) - nh = NEXT_HOP_IP["nh2"][addr_type] + nh = next_hop_ip["nh2"][addr_type] result = verify_rib( tgen, addr_type, @@ -360,14 +368,14 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is"\ " still present in RIB".format(tc_name) - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("Configure the static route with nexthop N2") @@ -376,7 +384,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], } ] } @@ -395,14 +403,14 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): step("Only one the nexthops should be active in RIB.") - nh = NEXT_HOP_IP["nh2"][addr_type] + nh = next_hop_ip["nh2"][addr_type] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) - nh = NEXT_HOP_IP["nh1"][addr_type] + nh = next_hop_ip["nh1"][addr_type] result = verify_rib( tgen, addr_type, @@ -412,14 +420,14 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" + assert result is not True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) result = verify_rib( @@ -431,26 +439,26 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): next_hop=nh, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Route is" + assert result is not True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) dut = "r2" - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" + assert result is not True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) dut = "r2" @@ -461,12 +469,12 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "after shut of nexthop N1 , route become active " "with nexthop N2 and vice versa." ) - nh = [NEXT_HOP_IP["nh1"][addr_type], NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type], next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("Shut nexthop interface N2") @@ -475,10 +483,10 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): shutdown_bringup_interface(tgen, dut, intf, False) step( - " after shut of nexthop N1 , route become active with " + " after shut of nexthop N1 , route become active with " \ "nexthop N2 and vice versa." ) - nh = NEXT_HOP_IP["nh2"][addr_type] + nh = next_hop_ip["nh2"][addr_type] result = verify_rib( tgen, @@ -489,27 +497,27 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB".format(tc_name) - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" + assert result is not True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) step("No shut nexthop interface N2") @@ -520,23 +528,23 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): "after shut of nexthop N1 , route become active " "with nexthop N2 and vice versa." ) - nh = [NEXT_HOP_IP["nh1"][addr_type], NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type], next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" + assert result is not True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) step("Reload the FRR router") @@ -553,18 +561,18 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" + assert result is not True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) write_test_footer(tc_name) @@ -583,7 +591,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): pytest.skip(tgen.errors) reset_config_on_routers(tgen) - NEXT_HOP_IP = populate_nh() + step( "Configure IPv4 static route (10.1.1.1) in R2 with next hop N1" "(28.1.1.2 ) AD 10 and N2 (29.1.1.2) AD 20 , Static route next-hop" @@ -592,19 +600,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): ) reset_config_on_routers(tgen) - NEXT_HOP_IP = populate_nh() + next_hop_ip = populate_nh() for addr_type in ADDR_TYPES: input_dict_4 = { "r2": { "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, }, { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, }, ] @@ -625,19 +633,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, } ] } } - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ "missing in RIB".format(tc_name) rte2_nh2 = { @@ -645,13 +653,13 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, } ] } } - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( @@ -664,7 +672,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) step("Configure IBGP IPv4 peering between R2 and R3 router.") @@ -673,11 +681,11 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "r3": { "static_routes": [ { - "network": NEXT_HOP_IP["nh1"][addr_type] + "/32", + "network": next_hop_ip["nh1"][addr_type] + "/32", "next_hop": topo["routers"]["r2"]["links"]["r3"][addr_type], }, { - "network": NEXT_HOP_IP["nh2"][addr_type] + "/32", + "network": next_hop_ip["nh2"][addr_type] + "/32", "next_hop": topo["routers"]["r2"]["links"]["r3"][addr_type], }, ] @@ -712,7 +720,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, "delete": True, } @@ -735,13 +743,13 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, } ] } } - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( @@ -754,7 +762,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ "missing in RIB".format(tc_name) rte2_nh2 = { @@ -762,17 +770,17 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, } ] } } - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte2_nh2, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) step("Configure the static route with nexthop N1") @@ -781,7 +789,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, } ] @@ -799,7 +807,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, "delete": True, } @@ -816,7 +824,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "On R2, after removing the static route with N2 , " "route become active with nexthop N1 and vice versa." ) - nh = NEXT_HOP_IP["nh2"][addr_type] + nh = next_hop_ip["nh2"][addr_type] result = verify_rib( tgen, addr_type, @@ -826,14 +834,14 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB".format(tc_name) - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("Configure the static route with nexthop N2") @@ -842,7 +850,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, } ] @@ -862,7 +870,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): step("after shut of nexthop N1 , route become active with nexthop N2") - nh = NEXT_HOP_IP["nh1"][addr_type] + nh = next_hop_ip["nh1"][addr_type] result = verify_rib( tgen, addr_type, @@ -872,14 +880,14 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB".format(tc_name) - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte2_nh2, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("No shut the nexthop interface N1") @@ -889,12 +897,12 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "after shut of nexthop N1 , route become active " "with nexthop N2 and vice versa." ) - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("Shut nexthop interface N2") @@ -906,7 +914,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): " after shut of nexthop N1 , route become active with " "nexthop N2 and vice versa." ) - nh = NEXT_HOP_IP["nh2"][addr_type] + nh = next_hop_ip["nh2"][addr_type] result = verify_rib( tgen, @@ -917,14 +925,14 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB".format(tc_name) - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("No shut nexthop interface N2") @@ -939,19 +947,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, } ] } } - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ "missing in RIB".format(tc_name) rte2_nh2 = { @@ -959,13 +967,13 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, } ] } } - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( @@ -978,7 +986,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) dut = "r3" @@ -994,7 +1002,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) dut = "r2" @@ -1013,25 +1021,25 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh1"][addr_type], + "next_hop": next_hop_ip["nh1"][addr_type], "admin_distance": 10, } ] } } - nh = [NEXT_HOP_IP["nh1"][addr_type]] + nh = [next_hop_ip["nh1"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ "missing in RIB".format(tc_name) dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, rte1_nh1, next_hop=nh) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ "missing in RIB".format(tc_name) rte2_nh2 = { @@ -1039,13 +1047,13 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): "static_routes": [ { "network": NETWORK2[addr_type], - "next_hop": NEXT_HOP_IP["nh2"][addr_type], + "next_hop": next_hop_ip["nh2"][addr_type], "admin_distance": 20, } ] } } - nh = [NEXT_HOP_IP["nh2"][addr_type]] + nh = [next_hop_ip["nh2"][addr_type]] dut = "r2" protocol = "static" result = verify_rib( @@ -1058,13 +1066,13 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, rte2_nh2, next_hop=nh) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) result = verify_rib( @@ -1077,7 +1085,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) write_test_footer(tc_name) @@ -1148,13 +1156,13 @@ def test_same_rte_from_bgp_static_p0_tc5_ebgp(request): step("Verify on R3 , route receive on R3 BGP table ") dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) step("Verify route installed in the RIB and FIB of R3") protocol = "bgp" result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) step( @@ -1206,14 +1214,14 @@ def test_same_rte_from_bgp_static_p0_tc5_ebgp(request): ) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " missing in BGP RIB".format(tc_name) protocol = "bgp" result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " missing in RIB".format(tc_name) step("Remove the static route on R3 configured with active" "interface") @@ -1249,14 +1257,14 @@ def test_same_rte_from_bgp_static_p0_tc5_ebgp(request): ) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " missing in BGP RIB".format(tc_name) protocol = "bgp" result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " missing in RIB".format(tc_name) write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py index 6649915dec..72a6eb9871 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py @@ -314,7 +314,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") @@ -338,7 +338,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step( @@ -384,7 +384,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed\nError: Routes is" + assert result is not True, "Testcase {} : Failed\nError: Routes is" \ " still present in RIB".format(tc_name) step("Configure the static route with nexthop N1 to N8, one by one") @@ -410,7 +410,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed\nError: Routes are" + assert result is True, "Testcase {} : Failed\nError: Routes are" \ " missing in RIB".format(tc_name) protocol = "static" @@ -455,7 +455,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Remove random static route with all the nexthop") @@ -493,7 +493,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) for addr_type in ADDR_TYPES: @@ -546,7 +546,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Remove the redistribute static knob") @@ -580,7 +580,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) write_test_footer(tc_name) @@ -661,7 +661,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) nh = [] @@ -679,7 +679,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " are missing in RIB".format(tc_name) step( @@ -723,7 +723,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) step("Configure the static route with nexthop N1 to N8, one by one") @@ -770,7 +770,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): @@ -787,7 +787,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " are missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") @@ -815,7 +815,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" + assert result is not True, "Testcase {} : Failed \n" \ "Error: Routes are still present in RIB".format(tc_name) step("Random no shut of the nexthop interfaces") @@ -826,7 +826,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" + assert result is True, "Testcase {} : Failed \n" \ "Error: Routes are missing in RIB".format(tc_name) dut = "r2" @@ -955,7 +955,7 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) nh = [] @@ -971,7 +971,7 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " are missing in RIB".format(tc_name) step( @@ -1015,7 +1015,7 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) step("Configure the static route with nexthop N1 to N8, one by one") @@ -1062,7 +1062,7 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): @@ -1077,7 +1077,7 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " are missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") @@ -1105,7 +1105,7 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" + assert result is not True, "Testcase {} : Failed \n" \ "Error: Routes are still present in RIB".format(tc_name) step("Random no shut of the nexthop interfaces") @@ -1116,7 +1116,7 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" + assert result is True, "Testcase {} : Failed \n" \ "Error: Routes are missing in RIB".format(tc_name) dut = "r2" @@ -1230,7 +1230,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Verify that highest AD nexthop are inactive") @@ -1249,7 +1249,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " are missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") @@ -1312,7 +1312,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) step("Configure the static route with nexthop N1 to N8, one by one") @@ -1355,7 +1355,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " + assert result is True, "Testcase {} : Failed \nError: Route with " \ "lowest AD is missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") @@ -1383,7 +1383,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" + assert result is not True, "Testcase {} : Failed \n" \ "Error: Routes are still present in RIB".format(tc_name) step("Random no shut of the nexthop interfaces") @@ -1394,7 +1394,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" + assert result is True, "Testcase {} : Failed \n" \ "Error: Routes are missing in RIB".format(tc_name) step("Remove random static route with all the nexthop") @@ -1434,7 +1434,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Route " + assert result is not True, "Testcase {} : Failed \nError: Route " \ " is still present in RIB".format(tc_name) step("Reconfigure the deleted routes and verify they are installed") @@ -1460,7 +1460,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): protocol = "static" nh = NEXT_HOP_IP["nh1"][addr_type] result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route " + assert result is True, "Testcase {} : Failed \nError: Route " \ " is still present in RIB".format(tc_name) step("Reload the FRR router") @@ -1577,7 +1577,7 @@ def test_static_route_delete_p0_tc11_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Verify that highest AD nexthop are inactive") @@ -1594,7 +1594,7 @@ def test_static_route_delete_p0_tc11_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " are missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") @@ -1647,7 +1647,7 @@ def test_static_route_delete_p0_tc11_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) for addr_type in ADDR_TYPES: @@ -1715,8 +1715,9 @@ def test_static_route_delete_p0_tc11_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still active in RIB".format(tc_name) + write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py index 175a1123d7..6aaa2c0209 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py @@ -297,7 +297,7 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -351,7 +351,7 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) step("Configure the static route with nexthop N1 to N8, one by" "one") @@ -379,7 +379,7 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") @@ -407,7 +407,7 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" + assert result is not True, "Testcase {} : Failed \n" \ "Error: Routes are still present in RIB".format(tc_name) step("Random no shut of the nexthop interfaces") @@ -418,7 +418,7 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" + assert result is True, "Testcase {} : Failed \n" \ "Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") @@ -429,7 +429,7 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) write_test_footer(tc_name) @@ -509,7 +509,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " + assert result is True, "Testcase {} : Failed \nError: Route with " \ " lowest AD is missing in RIB".format(tc_name) nh = [] @@ -525,7 +525,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " with high AD are active in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") @@ -569,7 +569,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " + assert result is True, "Testcase {} : Failed \nError: Route with " \ " lowest AD is missing in RIB".format(tc_name) step( @@ -613,7 +613,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) step("Configure the static route with nexthop N1 to N8, one by" "one") @@ -655,7 +655,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " + assert result is True, "Testcase {} : Failed \nError: Route with " \ " lowest AD is missing in RIB".format(tc_name) nh = [] @@ -671,7 +671,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " with high AD are active in RIB".format(tc_name) step("Random shut of the nexthop interfaces") @@ -699,7 +699,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" + assert result is not True, "Testcase {} : Failed \n" \ "Error: Routes are still present in RIB".format(tc_name) step("Random no shut of the nexthop interfaces") @@ -710,7 +710,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" + assert result is True, "Testcase {} : Failed \n" \ "Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") @@ -740,7 +740,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " + assert result is True, "Testcase {} : Failed \nError: Route with " \ " lowest AD is missing in RIB".format(tc_name) nh = [] @@ -756,7 +756,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " with high AD are active in RIB".format(tc_name) write_test_footer(tc_name) @@ -818,17 +818,17 @@ def test_bgp_local_nexthop_p1_tc14_ebgp(request): step("Verify R2 BGP table has IPv4 route") dut = "r2" result = verify_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB of R2".format(tc_name) step(" Verify route did not install in the R3 BGP table, RIB/FIB") dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4, expected=False) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in BGP RIB of R2".format(tc_name) result = verify_rib(tgen, addr_type, dut, input_dict_4, expected=False) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB of R2".format(tc_name) write_test_footer(tc_name) @@ -889,7 +889,7 @@ def test_frr_intf_name_as_gw_gap_tc4_ebgp_p0(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, next_hop=nh ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) input_dict_nh = { @@ -902,7 +902,7 @@ def test_frr_intf_name_as_gw_gap_tc4_ebgp_p0(request): } } result = verify_ip_nht(tgen, input_dict_nh) - assert result is True, "Testcase {} : Failed \nError: Nexthop is" + assert result is True, "Testcase {} : Failed \nError: Nexthop is" \ " missing in RIB".format(tc_name) step( @@ -925,7 +925,7 @@ def test_frr_intf_name_as_gw_gap_tc4_ebgp_p0(request): next_hop=nh, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) shutdown_bringup_interface(tgen, dut, intf, True) @@ -970,7 +970,7 @@ def test_frr_intf_name_as_gw_gap_tc4_ebgp_p0(request): next_hop=nh, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes" + assert result is not True, "Testcase {} : Failed \nError: Routes" \ " still present in RIB".format(tc_name) write_test_footer(tc_name) @@ -1034,7 +1034,7 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Configure route-map on R2 with allow tag1 and deny tag2") @@ -1116,7 +1116,7 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_0, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route with " + assert result is not True, "Testcase {} : Failed \nError: Route with " \ "tag 4002 is still present in RIB".format(tc_name) dut = "r2" @@ -1125,7 +1125,7 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): } result = verify_rib(tgen, addr_type, dut, input_dict_0, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route with " + assert result is True, "Testcase {} : Failed \nError: Route with " \ "tag 4001 is missing in RIB".format(tc_name) step("Modify the route-map to allow tag2 and deny tag1") @@ -1164,7 +1164,7 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): } result = verify_rib(tgen, addr_type, dut, input_dict_0, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route with " + assert result is True, "Testcase {} : Failed \nError: Route with " \ "tag 4002 is missing in RIB".format(tc_name) input_dict_1 = { @@ -1173,8 +1173,8 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_1, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route with " - "tag 4001 is still present in RIB".format(tc_name, result) + assert result is not True, "Testcase {} : Failed \nError: Route with " \ + "tag 4001 is still present in RIB".format(tc_name) step("Configure one static route with 2 ECMP nexthop N1 and N2") step("For N1 configure tag 1 and for N2 configure tag 2") @@ -1213,7 +1213,7 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("shut/no shut of tag1 and tag2 nexthop") diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py index 5d4950a70e..9a597484d9 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py @@ -88,7 +88,6 @@ NEXT_HOP_IP = {} pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] - class CreateTopo(Topo): """ Test CreateTopo - topology 1. @@ -109,7 +108,7 @@ def setup_module(mod): Set up the pytest environment. * `mod`: module name """ - global topo + testsuite_run_time = time.asctime(time.localtime(time.time())) logger.info("Testsuite start time: {}".format(testsuite_run_time)) logger.info("=" * 40) @@ -135,8 +134,7 @@ def setup_module(mod): pytest.skip(error_msg) # Checking BGP convergence - global BGP_CONVERGENCE - global ADDR_TYPES + # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) @@ -173,7 +171,7 @@ def teardown_module(mod): # Tests starting # ##################################################### -def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): +def test_static_routes_rmap_pfxlist_p0_tc7_ebgp(request): """ Verify static route are blocked from route-map & prefix-list applied in BGP nbrs @@ -200,7 +198,7 @@ def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): ) for addr_type in ADDR_TYPES: - # Api call to modfiy BGP timerse + # Api call to modify BGP timers input_dict = { "r2": { "bgp": { @@ -241,7 +239,7 @@ def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): step(" All BGP nbrs are down as authentication is mismatch on both" " the sides") bgp_convergence = verify_bgp_convergence(tgen, topo, expected=False) - assert bgp_convergence is not True, "Testcase {} : " + assert bgp_convergence is not True, "Testcase {} : " \ "Failed \n BGP nbrs must be down. Error: {}".format(tc_name, bgp_convergence) step( @@ -337,7 +335,7 @@ def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): "show ip prefix list" ) result = verify_prefix_lists(tgen, input_dict_2) - assert result is not True, "Testcase {} : Failed \n" + assert result is not True, "Testcase {} : Failed \n" \ " Error: {}".format(tc_name, result) step("Redistribute all the routes (connected, static)") @@ -588,7 +586,7 @@ def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): result4 = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result4 is not True, "Testcase {} : Failed , VM1 route is " + assert result4 is not True, "Testcase {} : Failed , VM1 route is " \ "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) step( @@ -964,7 +962,7 @@ def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): ) input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}} result4 = verify_rib(tgen, addr_type, dut, input_dict) - assert result4 is True, "Testcase {} : Failed , VM1 route is " + assert result4 is True, "Testcase {} : Failed , VM1 route is " \ "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) step("vm4 should be present in FRR2") @@ -976,7 +974,7 @@ def static_routes_rmap_pfxlist_p0_tc7_ebgp(request): ) input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}} result4 = verify_rib(tgen, addr_type, dut, input_dict) - assert result4 is True, "Testcase {} : Failed , VM1 route is " + assert result4 is True, "Testcase {} : Failed , VM1 route is " \ "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) dut = "r3" From ec3ed7234de72fec58c120ce8195481f668171a9 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Fri, 9 Apr 2021 12:58:34 -0400 Subject: [PATCH 3/4] tests: fix pylint errors in static_routing_with_ibgp Fix pylint errors. Signed-off-by: Mark Stapp --- .../test_static_routes_topo1_ibgp.py | 84 +++++++------- .../test_static_routes_topo2_ibgp.py | 103 +++++++++--------- .../test_static_routes_topo3_ibgp.py | 42 +++---- .../test_static_routes_topo4_ibgp.py | 10 +- 4 files changed, 120 insertions(+), 119 deletions(-) diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py index 8c2fdfca13..790b16bc75 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py @@ -242,7 +242,7 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("Configure IBGP IPv4 peering between R2 and R3 router.") @@ -296,14 +296,14 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB".format(tc_name) nh = [NEXT_HOP_IP["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("Configure the static route with nexthop N1") @@ -359,14 +359,14 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB".format(tc_name) nh = [NEXT_HOP_IP["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("Configure the static route with nexthop N2") @@ -398,7 +398,7 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) nh = NEXT_HOP_IP["nh1"][addr_type] @@ -411,14 +411,14 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" + assert result is not True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) result = verify_rib( @@ -430,7 +430,7 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): next_hop=nh, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Route is" + assert result is not True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) dut = "r2" @@ -438,18 +438,18 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" + assert result is not True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) dut = "r2" @@ -465,7 +465,7 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("Shut nexthop interface N2") @@ -488,7 +488,7 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB".format(tc_name) nh = [NEXT_HOP_IP["nh1"][addr_type]] @@ -497,18 +497,18 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" + assert result is not True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) step("No shut nexthop interface N2") @@ -524,18 +524,18 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" + assert result is not True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) step("Reload the FRR router") @@ -552,18 +552,18 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" + assert result is True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" + assert result is not True, "Testcase {} : Failed \nError: Route is" \ " still present in RIB".format(tc_name) write_test_footer(tc_name) @@ -636,7 +636,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ "missing in RIB".format(tc_name) rte2_nh2 = { @@ -663,7 +663,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) step("Configure IBGP IPv4 peering between R2 and R3 router.") @@ -753,7 +753,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ "missing in RIB".format(tc_name) rte2_nh2 = { @@ -771,7 +771,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte2_nh2, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) step("Configure the static route with nexthop N1") @@ -825,14 +825,14 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB".format(tc_name) nh = [NEXT_HOP_IP["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("Configure the static route with nexthop N2") @@ -871,14 +871,14 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB".format(tc_name) nh = [NEXT_HOP_IP["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte2_nh2, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("No shut the nexthop interface N1") @@ -893,7 +893,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("Shut nexthop interface N2") @@ -916,14 +916,14 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB".format(tc_name) nh = [NEXT_HOP_IP["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB".format(tc_name) step("No shut nexthop interface N2") @@ -950,7 +950,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ "missing in RIB".format(tc_name) rte2_nh2 = { @@ -977,7 +977,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) dut = "r3" @@ -993,7 +993,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) dut = "r2" @@ -1024,13 +1024,13 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ "missing in RIB".format(tc_name) dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, rte1_nh1, next_hop=nh) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ "missing in RIB".format(tc_name) rte2_nh2 = { @@ -1057,13 +1057,13 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, rte2_nh2, next_hop=nh) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) result = verify_rib( @@ -1076,7 +1076,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ "not active in RIB".format(tc_name) write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py index 644ddc02d4..738d1e6e3a 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py @@ -318,7 +318,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") @@ -342,7 +342,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step( @@ -388,7 +388,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed\nError: Routes is" + assert result is not True, "Testcase {} : Failed\nError: Routes is" \ " still present in RIB".format(tc_name) step("Configure the static route with nexthop N1 to N8, one by one") @@ -414,7 +414,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed\nError: Routes are" + assert result is True, "Testcase {} : Failed\nError: Routes are" \ " missing in RIB".format(tc_name) protocol = "static" @@ -423,7 +423,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): # Shutdown interface dut = "r2" step( - " interface which is about to be shut no shut between r1 and r2 is " "%s", + " interface which is about to be shut no shut between r1 and r2 is %s", topo["routers"]["r2"]["links"]["r1-link{}".format(randnum)]["interface"], ) intf = topo["routers"]["r2"]["links"]["r1-link{}".format(randnum)]["interface"] @@ -459,7 +459,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Remove random static route with all the nexthop") @@ -497,7 +497,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) for addr_type in ADDR_TYPES: @@ -550,7 +550,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Remove the redistribute static knob") @@ -584,7 +584,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) write_test_footer(tc_name) @@ -665,7 +665,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) nh = [] @@ -683,7 +683,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " are missing in RIB".format(tc_name) step( @@ -727,7 +727,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) step("Configure the static route with nexthop N1 to N8, one by one") @@ -774,7 +774,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): @@ -791,7 +791,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " are missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") @@ -819,7 +819,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" + assert result is not True, "Testcase {} : Failed \n" \ "Error: Routes are still present in RIB".format(tc_name) step("Random no shut of the nexthop interfaces") @@ -830,7 +830,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" + assert result is True, "Testcase {} : Failed \n" \ "Error: Routes are missing in RIB".format(tc_name) protocol = "bgp" @@ -856,7 +856,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): for addr_type in ADDR_TYPES: input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \n" + assert result is True, "Testcase {} : Failed \n" \ "Error: Routes are missing in RIB".format(tc_name) protocol = "static" @@ -866,7 +866,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {}: Failed \n " "Error: Routes are missing in RIB".format(tc_name) + ), "Testcase {}: Failed \n Error: Routes are missing in RIB".format(tc_name) protocol = "bgp" dut = "r3" @@ -875,7 +875,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {}: Failed \n " "Error: Routes are missing in RIB".format(tc_name) + ), "Testcase {}: Failed \n Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -888,7 +888,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + ), "Testcase {} : Failed \nError: Routes are still present in RIB".format( tc_name ) @@ -912,7 +912,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + ), "Testcase {} : Failed \nError: Routes are still present in RIB".format( tc_name ) @@ -923,7 +923,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + ), "Testcase {} : Failed \nError: Routes are still present in RIB".format( tc_name ) @@ -964,7 +964,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " strill present in RIB of R3".format(tc_name) write_test_footer(tc_name) @@ -1060,7 +1060,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) nh = [] @@ -1076,7 +1076,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " are missing in RIB".format(tc_name) step( @@ -1120,7 +1120,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) step("Configure the static route with nexthop N1 to N8, one by one") @@ -1167,7 +1167,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): @@ -1182,7 +1182,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " are missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") @@ -1210,7 +1210,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" + assert result is not True, "Testcase {} : Failed \n" \ "Error: Routes are still present in RIB".format(tc_name) step("Random no shut of the nexthop interfaces") @@ -1221,7 +1221,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" + assert result is True, "Testcase {} : Failed \n" \ "Error: Routes are missing in RIB".format(tc_name) dut = "r2" @@ -1249,7 +1249,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): for addr_type in ADDR_TYPES: input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \n" + assert result is True, "Testcase {} : Failed \n" \ "Error: Routes are missing in RIB".format(tc_name) protocol = "static" @@ -1259,7 +1259,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {}: Failed \n " "Error: Routes are missing in RIB".format(tc_name) + ), "Testcase {}: Failed \n Error: Routes are missing in RIB".format(tc_name) protocol = "bgp" dut = "r3" @@ -1268,7 +1268,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {}: Failed \n " "Error: Routes are missing in RIB".format(tc_name) + ), "Testcase {}: Failed \n Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -1281,7 +1281,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + ), "Testcase {} : Failed \n Error: Routes are still present in RIB".format( tc_name ) @@ -1305,7 +1305,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + ), "Testcase {} : Failed \n Error: Routes are still present in RIB".format( tc_name ) @@ -1316,7 +1316,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + ), "Testcase {} : Failed \n Error: Routes are still present in RIB".format( tc_name ) @@ -1357,7 +1357,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB of R3".format(tc_name) write_test_footer(tc_name) @@ -1453,7 +1453,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Verify that highest AD nexthop are inactive") @@ -1472,7 +1472,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " are missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") @@ -1535,7 +1535,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) step("Configure the static route with nexthop N1 to N8, one by one") @@ -1578,7 +1578,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " + assert result is True, "Testcase {} : Failed \nError: Route with " \ "lowest AD is missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") @@ -1606,7 +1606,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" + assert result is not True, "Testcase {} : Failed \n" \ "Error: Routes are still present in RIB".format(tc_name) step("Random no shut of the nexthop interfaces") @@ -1617,7 +1617,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" + assert result is True, "Testcase {} : Failed \n" \ "Error: Routes are missing in RIB".format(tc_name) step("Remove random static route with all the nexthop") @@ -1657,7 +1657,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Route " + assert result is not True, "Testcase {} : Failed \nError: Route " \ " is still present in RIB".format(tc_name) step("Reconfigure the deleted routes and verify they are installed") @@ -1683,7 +1683,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): protocol = "static" nh = NEXT_HOP_IP["nh1"][addr_type] result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route " + assert result is True, "Testcase {} : Failed \nError: Route " \ " is still present in RIB".format(tc_name) step("Reload the FRR router") @@ -1704,7 +1704,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): ) assert ( result is True - ), "Testcase {} : Failed \nError: Route " " is missing in RIB".format( + ), "Testcase {} : Failed \nError: Route is missing in RIB".format( tc_name ) @@ -1750,7 +1750,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) write_test_footer(tc_name) @@ -1845,7 +1845,7 @@ def test_static_route_delete_p0_tc11_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Verify that highest AD nexthop are inactive") @@ -1862,7 +1862,7 @@ def test_static_route_delete_p0_tc11_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " are missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") @@ -1915,7 +1915,7 @@ def test_static_route_delete_p0_tc11_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) for addr_type in ADDR_TYPES: @@ -1983,8 +1983,9 @@ def test_static_route_delete_p0_tc11_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still active in RIB".format(tc_name) + write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py index 8f9d88a442..0045bc5c25 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py @@ -298,7 +298,7 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -352,7 +352,7 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) step("Configure the static route with nexthop N1 to N8, one by" "one") @@ -380,7 +380,7 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") @@ -408,7 +408,7 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" + assert result is not True, "Testcase {} : Failed \n" \ "Error: Routes are still present in RIB".format(tc_name) step("Random no shut of the nexthop interfaces") @@ -419,7 +419,7 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" + assert result is True, "Testcase {} : Failed \n" \ "Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") @@ -430,7 +430,7 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" + assert result is True, "Testcase {} : Failed \nError: Routes are" \ " missing in RIB".format(tc_name) write_test_footer(tc_name) @@ -510,7 +510,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " + assert result is True, "Testcase {} : Failed \nError: Route with " \ " lowest AD is missing in RIB".format(tc_name) nh = [] @@ -526,7 +526,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " with high AD are active in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") @@ -570,7 +570,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " + assert result is True, "Testcase {} : Failed \nError: Route with " \ " lowest AD is missing in RIB".format(tc_name) step( @@ -614,7 +614,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ " still present in RIB".format(tc_name) step("Configure the static route with nexthop N1 to N8, one by" "one") @@ -656,7 +656,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " + assert result is True, "Testcase {} : Failed \nError: Route with " \ " lowest AD is missing in RIB".format(tc_name) nh = [] @@ -672,7 +672,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " with high AD are active in RIB".format(tc_name) step("Random shut of the nexthop interfaces") @@ -700,7 +700,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" + assert result is not True, "Testcase {} : Failed \n" \ "Error: Routes are still present in RIB".format(tc_name) step("Random no shut of the nexthop interfaces") @@ -711,7 +711,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" + assert result is True, "Testcase {} : Failed \n" \ "Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") @@ -741,7 +741,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " + assert result is True, "Testcase {} : Failed \nError: Route with " \ " lowest AD is missing in RIB".format(tc_name) nh = [] @@ -757,7 +757,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " + assert result is not True, "Testcase {} : Failed \nError: Routes " \ " with high AD are active in RIB".format(tc_name) step("Remove the redistribute static knob") @@ -796,8 +796,8 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" - " strill present in RIB of R3".format(tc_name) + assert result is not True, "Testcase {} : Failed \nError: Routes are" \ + " still present in RIB of R3".format(tc_name) write_test_footer(tc_name) @@ -858,17 +858,17 @@ def test_bgp_local_nexthop_p1_tc14_ibgp(request): step("Verify R2 BGP table has IPv4 route") dut = "r2" result = verify_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Routes is" + assert result is True, "Testcase {} : Failed \nError: Routes is" \ " missing in RIB of R2".format(tc_name) step(" Verify route did not install in the R3 BGP table, RIB/FIB") dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4, expected=False) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in BGP RIB of R2".format(tc_name) result = verify_rib(tgen, addr_type, dut, input_dict_4, expected=False) - assert result is not True, "Testcase {} : Failed \nError: Routes is" + assert result is not True, "Testcase {} : Failed \nError: Routes is" \ " still present in RIB of R2".format(tc_name) write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py index 09c437c3c4..5014280bf9 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py @@ -239,7 +239,7 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): step(" All BGP nbrs are down as authentication is mismatch on both" " the sides") bgp_convergence = verify_bgp_convergence(tgen, topo, expected=False) - assert bgp_convergence is not True, "Testcase {} : " + assert bgp_convergence is not True, "Testcase {} : " \ "Failed \n BGP nbrs must be down. Error: {}".format(tc_name, bgp_convergence) step( @@ -335,7 +335,7 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): "show ip prefix list" ) result = verify_prefix_lists(tgen, input_dict_2) - assert result is not True, "Testcase {} : Failed \n" + assert result is not True, "Testcase {} : Failed \n" \ " Error: {}".format(tc_name, result) step("Redistribute all the routes (connected, static)") @@ -586,7 +586,7 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): result4 = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result4 is not True, "Testcase {} : Failed , VM1 route is " + assert result4 is not True, "Testcase {} : Failed , VM1 route is " \ "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) step( @@ -962,7 +962,7 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): ) input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}} result4 = verify_rib(tgen, addr_type, dut, input_dict) - assert result4 is True, "Testcase {} : Failed , VM1 route is " + assert result4 is True, "Testcase {} : Failed , VM1 route is " \ "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) step("vm4 should be present in FRR2") @@ -974,7 +974,7 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): ) input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}} result4 = verify_rib(tgen, addr_type, dut, input_dict) - assert result4 is True, "Testcase {} : Failed , VM1 route is " + assert result4 is True, "Testcase {} : Failed , VM1 route is " \ "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) dut = "r3" From d7265db9b3afa0ed7e249381b0e30e495ec1f84d Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Tue, 13 Apr 2021 13:34:57 -0400 Subject: [PATCH 4/4] tests: run black over mcast-pim-static, static_routing_with_[ei]bgp Run black and clean up formatting along with pylint cleanup. Signed-off-by: Mark Stapp --- .../test_multicast_pim_static_rp.py | 129 ++++----- .../test_static_routes_topo1_ebgp.py | 270 +++++++++++------- .../test_static_routes_topo2_ebgp.py | 195 ++++++++----- .../test_static_routes_topo3_ebgp.py | 170 +++++++---- .../test_static_routes_topo4_ebgp.py | 31 +- .../test_static_routes_topo1_ibgp.py | 238 +++++++++------ .../test_static_routes_topo2_ibgp.py | 228 +++++++++------ .../test_static_routes_topo3_ibgp.py | 120 +++++--- .../test_static_routes_topo4_ibgp.py | 30 +- 9 files changed, 888 insertions(+), 523 deletions(-) diff --git a/tests/topotests/multicast-pim-static-rp-topo1/test_multicast_pim_static_rp.py b/tests/topotests/multicast-pim-static-rp-topo1/test_multicast_pim_static_rp.py index caa0de3d41..7bef57b629 100755 --- a/tests/topotests/multicast-pim-static-rp-topo1/test_multicast_pim_static_rp.py +++ b/tests/topotests/multicast-pim-static-rp-topo1/test_multicast_pim_static_rp.py @@ -210,6 +210,7 @@ class CreateTopo(Topo): """ Dummy """ print("%s", self.name) + def setup_module(mod): """ Sets up the pytest environment @@ -272,9 +273,7 @@ def teardown_module(): # Stop toplogy and Remove tmp files tgen.stop_topology() - logger.info( - "Testsuite end time: %s", time.asctime(time.localtime(time.time())) - ) + logger.info("Testsuite end time: %s", time.asctime(time.localtime(time.time()))) logger.info("=" * 40) @@ -338,10 +337,8 @@ def verify_mroute_repopulated(uptime_before, uptime_after): ) return errormsg - d_1 = datetime.datetime.strptime(uptime_before[group][source], - "%H:%M:%S") - d_2 = datetime.datetime.strptime(uptime_after[group][source], - "%H:%M:%S") + d_1 = datetime.datetime.strptime(uptime_before[group][source], "%H:%M:%S") + d_2 = datetime.datetime.strptime(uptime_after[group][source], "%H:%M:%S") if d_2 >= d_1: errormsg = "mroute (%s, %s) is not " "repopulated [FAILED!!]" % ( source, @@ -365,7 +362,7 @@ def verify_state_incremented(state_before, state_after): """ for router, state_data in state_before.items(): - for state, _ in state_data.items(): + for state, _ in state_data.items(): if state_before[router][state] >= state_after[router][state]: errormsg = ( "[DUT: %s]: state %s value has not" @@ -498,7 +495,8 @@ def test_add_delete_static_RP_p0(request): step("r1: Verify RP info") result = verify_pim_rp_info( - tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE) + tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE + ) assert ( result is not True ), "Testcase {} : Failed \n " "r1: RP info present \n Error: {}".format( @@ -513,9 +511,7 @@ def test_add_delete_static_RP_p0(request): ) step("r1: Verify upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, STAR, GROUP_ADDRESS - ) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream join state is up and join timer is running \n Error: {}".format( @@ -690,8 +686,7 @@ def test_SPT_RPT_path_same_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S, G) upstream join state is up and join timer is running\n Error: {}".format( @@ -759,8 +754,9 @@ def test_not_reachable_static_RP_p0(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " \ - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) step("Enable IGMP on r1 interface and send IGMP " "join (225.1.1.1) to r1") step("Configure r2 loopback interface as RP") @@ -842,9 +838,7 @@ def test_not_reachable_static_RP_p0(request): "r1: join state should not be joined and join timer should stop," "verify using show ip pim upstream" ) - result = verify_join_state_and_timer( - tgen, dut, iif, STAR, GROUP_ADDRESS - ) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: join state is joined and timer is not stopped \n Error: {}".format( @@ -859,8 +853,9 @@ def test_not_reachable_static_RP_p0(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " \ - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) result = verify_state_incremented(state_before, state_after) assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result) @@ -950,14 +945,13 @@ def test_add_RP_after_join_received_p1(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " \ - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) step("r0 : Send IGMP join (225.1.1.1) to r1, when rp is not configured" "in r1") result = iperfSendIGMPJoin(tgen, "r0", GROUP_ADDRESS, join_interval=1) - 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("r1: IGMP group is received on R1 verify using show ip igmp groups") oif = "r1-r0-eth0" @@ -973,9 +967,7 @@ def test_add_RP_after_join_received_p1(request): step("r1: Verify upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, STAR, GROUP_ADDRESS - ) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream join state is joined and timer is running \n Error: {}".format( @@ -1042,8 +1034,9 @@ def test_add_RP_after_join_received_p1(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " \ - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) result = verify_state_incremented(state_before, state_after) assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) @@ -1090,8 +1083,9 @@ def test_reachable_static_RP_after_join_p0(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " \ - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) step("r1: Make RP un-reachable") dut = "r1" @@ -1127,9 +1121,7 @@ def test_reachable_static_RP_after_join_p0(request): ) step("r1 : Verify upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, STAR, GROUP_ADDRESS - ) + result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r1: upstream join state is joined and timer is running\n Error: {}".format( @@ -1188,8 +1180,9 @@ def test_reachable_static_RP_after_join_p0(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " \ - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) result = verify_state_incremented(state_before, state_after) assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result) @@ -1279,8 +1272,9 @@ def test_send_join_on_higher_preffered_rp_p1(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " \ - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) step("r0 : Send IGMP join for 225.1.1.1") result = iperfSendIGMPJoin(tgen, "r0", GROUP_ADDRESS, join_interval=1) @@ -1328,8 +1322,9 @@ def test_send_join_on_higher_preffered_rp_p1(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " \ - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) result = verify_state_incremented(state_before, state_after) assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result) @@ -1359,8 +1354,9 @@ def test_send_join_on_higher_preffered_rp_p1(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " \ - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) step("r1 : Delete RP configuration for 225.1.1.1") input_dict = { @@ -1389,9 +1385,7 @@ def test_send_join_on_higher_preffered_rp_p1(request): step("r1 : Verify rp-info for group 225.1.1.1") iif = "r1-r4-eth3" - result = verify_pim_rp_info( - tgen, TOPO, dut, GROUP_RANGE, oif, rp_address_2, SOURCE - ) + result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_RANGE, oif, rp_address_2, SOURCE) assert result is not True, ( "Testcase {} : Failed \n " "r1: rp-info is present for group 225.1.1.1 \n Error: {}".format( @@ -1440,8 +1434,9 @@ def test_send_join_on_higher_preffered_rp_p1(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " \ - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( + tc_name, result + ) result = verify_state_incremented(state_before, state_after) assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result) @@ -1648,9 +1643,7 @@ def test_RP_configured_as_LHR_1_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S, G) upstream join state is joined and join" @@ -1857,9 +1850,7 @@ def test_RP_configured_as_LHR_2_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format( @@ -2067,9 +2058,7 @@ def test_RP_configured_as_FHR_1_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format( @@ -2079,12 +2068,8 @@ def test_RP_configured_as_FHR_1_p1(request): step("r3: Verify (S, G) ip mroutes") oif = "r3-r1-eth0" - result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, - iif, oif) - assert result is True, "Testcase {} :Failed \n Error: {}".format( - tc_name, - result - ) + result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif) + assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) # Uncomment next line for debugging # tgen.mininet_cli() @@ -2282,9 +2267,7 @@ def test_RP_configured_as_FHR_2_p2(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format( @@ -2411,9 +2394,7 @@ def test_SPT_RPT_path_different_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format( @@ -2435,9 +2416,7 @@ def test_SPT_RPT_path_different_p1(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r2: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r2: (S,G) upstream state is joined and join timer is running\n Error: {}".format( @@ -2666,9 +2645,7 @@ def test_restart_pimd_process_p2(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("r3: Verify (S, G) upstream join state and join timer") - result = verify_join_state_and_timer( - tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS - ) + result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) assert result is not True, ( "Testcase {} : Failed \n " "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format( diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py index 99a04d26de..a16c4ae297 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py @@ -142,9 +142,7 @@ def setup_module(mod): # Api call verify whether BGP is converged converged = verify_bgp_convergence(tgen, topo) - assert converged is True, "setup_module :Failed \n Error: {}".format( - converged - ) + assert converged is True, "setup_module :Failed \n Error: {}".format(converged) logger.info("Running setup_module() done") @@ -312,8 +310,9 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure the static route with nexthop N1") @@ -368,15 +367,19 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is"\ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [next_hop_ip["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure the static route with nexthop N2") input_dict_4 = { @@ -407,8 +410,9 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) nh = next_hop_ip["nh1"][addr_type] result = verify_rib( @@ -420,15 +424,21 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) dut = "r3" result = verify_bgp_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) result = verify_rib( tgen, @@ -439,27 +449,35 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): next_hop=nh, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) dut = "r2" nh = [next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) dut = "r2" step("No shut the nexthop interface N1") @@ -474,8 +492,9 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Shut nexthop interface N2") intf = topo["routers"]["r2"]["links"]["r1-link1"]["interface"] @@ -483,7 +502,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): shutdown_bringup_interface(tgen, dut, intf, False) step( - " after shut of nexthop N1 , route become active with " \ + " after shut of nexthop N1 , route become active with " "nexthop N2 and vice versa." ) nh = next_hop_ip["nh2"][addr_type] @@ -497,8 +516,11 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [next_hop_ip["nh1"][addr_type]] dut = "r2" @@ -506,19 +528,24 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) step("No shut nexthop interface N2") dut = "r2" @@ -533,19 +560,24 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -561,19 +593,26 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) write_test_footer(tc_name) @@ -645,8 +684,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { @@ -672,8 +712,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) step("Configure IBGP IPv4 peering between R2 and R3 router.") step("Explicit route is added in R3 for R2 nexthop rechability") @@ -762,8 +803,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - "missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { @@ -780,8 +822,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): result = verify_rib( tgen, addr_type, dut, rte2_nh2, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) step("Configure the static route with nexthop N1") rte1_nh1 = { @@ -834,15 +877,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [next_hop_ip["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure the static route with nexthop N2") rte2_nh2 = { @@ -880,15 +927,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [next_hop_ip["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte2_nh2, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("No shut the nexthop interface N1") shutdown_bringup_interface(tgen, dut, intf, True) @@ -902,8 +953,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Shut nexthop interface N2") intf = topo["routers"]["r2"]["links"]["r1-link1"]["interface"] @@ -925,15 +977,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [next_hop_ip["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("No shut nexthop interface N2") shutdown_bringup_interface(tgen, dut, intf, True) @@ -959,8 +1015,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { @@ -986,8 +1043,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) dut = "r3" protocol = "bgp" @@ -1002,8 +1060,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) dut = "r2" step("Reload the FRR router") @@ -1033,14 +1092,16 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, rte1_nh1, next_hop=nh) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { @@ -1066,14 +1127,16 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, rte2_nh2, next_hop=nh) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) result = verify_rib( tgen, @@ -1085,8 +1148,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) write_test_footer(tc_name) @@ -1156,14 +1220,20 @@ def test_same_rte_from_bgp_static_p0_tc5_ebgp(request): step("Verify on R3 , route receive on R3 BGP table ") dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) step("Verify route installed in the RIB and FIB of R3") protocol = "bgp" result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) step( "Configure 2 links/interfaces between R1 and R3 , keep one" @@ -1214,15 +1284,19 @@ def test_same_rte_from_bgp_static_p0_tc5_ebgp(request): ) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " missing in BGP RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in BGP RIB".format( + tc_name + ) protocol = "bgp" result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) step("Remove the static route on R3 configured with active" "interface") for addr_type in ADDR_TYPES: @@ -1257,15 +1331,19 @@ def test_same_rte_from_bgp_static_p0_tc5_ebgp(request): ) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " missing in BGP RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in BGP RIB".format( + tc_name + ) protocol = "bgp" result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py index 72a6eb9871..bbb4370a93 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py @@ -314,8 +314,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -338,8 +339,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -384,8 +386,11 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed\nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed\nError: Routes is" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") for addr_type in ADDR_TYPES: @@ -410,8 +415,11 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed\nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed\nError: Routes are" " missing in RIB".format( + tc_name + ) protocol = "static" step("Random shut of the nexthop interfaces") @@ -455,8 +463,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Remove random static route with all the nexthop") dut = "r2" @@ -493,8 +502,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) for addr_type in ADDR_TYPES: input_dict_4 = { @@ -546,8 +556,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Remove the redistribute static knob") for addr_type in ADDR_TYPES: @@ -580,8 +591,11 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) write_test_footer(tc_name) @@ -661,8 +675,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): @@ -679,8 +694,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -723,8 +739,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") @@ -770,8 +789,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): nh.append(NEXT_HOP_IP["nh" + str(nhp)][addr_type]) @@ -787,8 +807,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -815,8 +836,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" \ - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -826,8 +850,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" \ - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) dut = "r2" protocol = "static" @@ -955,8 +980,9 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): @@ -971,8 +997,9 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -1015,8 +1042,11 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") @@ -1062,8 +1092,9 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): nh.append(NEXT_HOP_IP["nh" + str(nhp)][addr_type]) @@ -1077,8 +1108,9 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -1105,8 +1137,11 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" \ - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -1116,8 +1151,9 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" \ - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) dut = "r2" protocol = "static" @@ -1230,8 +1266,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Verify that highest AD nexthop are inactive") nh = [] @@ -1249,8 +1286,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -1312,8 +1350,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") for addr_type in ADDR_TYPES: @@ -1355,8 +1396,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " \ - "lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + "lowest AD is missing in RIB".format(tc_name) + ) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -1383,8 +1426,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" \ - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -1394,8 +1440,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" \ - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) step("Remove random static route with all the nexthop") for addr_type in ADDR_TYPES: @@ -1434,8 +1481,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Route " \ - " is still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Route " + " is still present in RIB".format(tc_name) + ) step("Reconfigure the deleted routes and verify they are installed") for nhp in range(1, 9): @@ -1460,8 +1509,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): protocol = "static" nh = NEXT_HOP_IP["nh1"][addr_type] result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route " \ - " is still present in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route " + " is still present in RIB".format(tc_name) + ) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -1577,8 +1628,9 @@ def test_static_route_delete_p0_tc11_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Verify that highest AD nexthop are inactive") nh = [] @@ -1594,8 +1646,9 @@ def test_static_route_delete_p0_tc11_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -1647,8 +1700,11 @@ def test_static_route_delete_p0_tc11_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) for addr_type in ADDR_TYPES: for nhp in range(1, 9): @@ -1715,8 +1771,11 @@ def test_static_route_delete_p0_tc11_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still active in RIB".format( + tc_name + ) write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py index 6aaa2c0209..8525e3655c 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py @@ -297,8 +297,9 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: input_dict_2 = { @@ -351,8 +352,11 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by" "one") @@ -379,8 +383,9 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -407,8 +412,11 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" \ - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -418,8 +426,9 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" \ - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -429,8 +438,9 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) write_test_footer(tc_name) @@ -509,8 +519,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " \ - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) nh = [] for nhp in range(2, 9): @@ -525,8 +537,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " with high AD are active in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes " + " with high AD are active in RIB".format(tc_name) + ) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -569,8 +583,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " \ - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -613,8 +629,11 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by" "one") for addr_type in ADDR_TYPES: @@ -655,8 +674,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " \ - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) nh = [] for nhp in range(2, 9): @@ -671,8 +692,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " with high AD are active in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes " + " with high AD are active in RIB".format(tc_name) + ) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -699,8 +722,11 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" \ - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -710,8 +736,9 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" \ - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -740,8 +767,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " \ - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) nh = [] for nhp in range(2, 9): @@ -756,8 +785,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " with high AD are active in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes " + " with high AD are active in RIB".format(tc_name) + ) write_test_footer(tc_name) @@ -818,18 +849,25 @@ def test_bgp_local_nexthop_p1_tc14_ebgp(request): step("Verify R2 BGP table has IPv4 route") dut = "r2" result = verify_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB of R2".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB of R2".format( + tc_name + ) step(" Verify route did not install in the R3 BGP table, RIB/FIB") dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4, expected=False) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in BGP RIB of R2".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes is" + " still present in BGP RIB of R2".format(tc_name) + ) result = verify_rib(tgen, addr_type, dut, input_dict_4, expected=False) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB of R2".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes is" + " still present in RIB of R2".format(tc_name) + ) write_test_footer(tc_name) @@ -889,8 +927,9 @@ def test_frr_intf_name_as_gw_gap_tc4_ebgp_p0(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, next_hop=nh ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) input_dict_nh = { "r1": { @@ -902,8 +941,9 @@ def test_frr_intf_name_as_gw_gap_tc4_ebgp_p0(request): } } result = verify_ip_nht(tgen, input_dict_nh) - assert result is True, "Testcase {} : Failed \nError: Nexthop is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Nexthop is" " missing in RIB".format(tc_name) step( "Shut / no shut IPv4 and IPv6 static next hop interface from" @@ -925,8 +965,9 @@ def test_frr_intf_name_as_gw_gap_tc4_ebgp_p0(request): next_hop=nh, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) shutdown_bringup_interface(tgen, dut, intf, True) @@ -970,8 +1011,11 @@ def test_frr_intf_name_as_gw_gap_tc4_ebgp_p0(request): next_hop=nh, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes" " still present in RIB".format( + tc_name + ) write_test_footer(tc_name) @@ -1034,8 +1078,9 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Configure route-map on R2 with allow tag1 and deny tag2") @@ -1116,8 +1161,10 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_0, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route with " \ - "tag 4002 is still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Route with " + "tag 4002 is still present in RIB".format(tc_name) + ) dut = "r2" input_dict_1 = { @@ -1125,8 +1172,10 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): } result = verify_rib(tgen, addr_type, dut, input_dict_0, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route with " \ - "tag 4001 is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + "tag 4001 is missing in RIB".format(tc_name) + ) step("Modify the route-map to allow tag2 and deny tag1") # Create route map @@ -1164,8 +1213,10 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): } result = verify_rib(tgen, addr_type, dut, input_dict_0, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route with " \ - "tag 4002 is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + "tag 4002 is missing in RIB".format(tc_name) + ) input_dict_1 = { "r2": {"static_routes": [{"network": NETWORK[addr_type], "tag": 4001}]} @@ -1173,8 +1224,10 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_1, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route with " \ - "tag 4001 is still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Route with " + "tag 4001 is still present in RIB".format(tc_name) + ) step("Configure one static route with 2 ECMP nexthop N1 and N2") step("For N1 configure tag 1 and for N2 configure tag 2") @@ -1213,8 +1266,9 @@ def test_static_route_with_tag_p0_tc_13_ebgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("shut/no shut of tag1 and tag2 nexthop") diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py index 9a597484d9..812b39797f 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py @@ -88,6 +88,7 @@ NEXT_HOP_IP = {} pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] + class CreateTopo(Topo): """ Test CreateTopo - topology 1. @@ -239,8 +240,11 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ebgp(request): step(" All BGP nbrs are down as authentication is mismatch on both" " the sides") bgp_convergence = verify_bgp_convergence(tgen, topo, expected=False) - assert bgp_convergence is not True, "Testcase {} : " \ - "Failed \n BGP nbrs must be down. Error: {}".format(tc_name, bgp_convergence) + assert ( + bgp_convergence is not True + ), "Testcase {} : " "Failed \n BGP nbrs must be down. Error: {}".format( + tc_name, bgp_convergence + ) step( "Configure 4 IPv4 and 4 IPv6 nbrs with macthing password " @@ -335,8 +339,9 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ebgp(request): "show ip prefix list" ) result = verify_prefix_lists(tgen, input_dict_2) - assert result is not True, "Testcase {} : Failed \n" \ - " Error: {}".format(tc_name, result) + assert result is not True, "Testcase {} : Failed \n" " Error: {}".format( + tc_name, result + ) step("Redistribute all the routes (connected, static)") input_dict_2_r1 = { @@ -586,8 +591,10 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ebgp(request): result4 = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result4 is not True, "Testcase {} : Failed , VM1 route is " \ - "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + assert result4 is not True, ( + "Testcase {} : Failed , VM1 route is " + "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + ) step( "VM4 and VM6 IPV4 and IPv6 address are present in local and " @@ -962,8 +969,10 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ebgp(request): ) input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}} result4 = verify_rib(tgen, addr_type, dut, input_dict) - assert result4 is True, "Testcase {} : Failed , VM1 route is " \ - "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + assert result4 is True, ( + "Testcase {} : Failed , VM1 route is " + "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + ) step("vm4 should be present in FRR2") dut = "r2" @@ -974,8 +983,10 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ebgp(request): ) input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}} result4 = verify_rib(tgen, addr_type, dut, input_dict) - assert result4 is True, "Testcase {} : Failed , VM1 route is " \ - "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + assert result4 is True, ( + "Testcase {} : Failed , VM1 route is " + "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + ) dut = "r3" protocol = "bgp" diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py index 790b16bc75..4e23a72423 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py @@ -242,8 +242,9 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure IBGP IPv4 peering between R2 and R3 router.") step("Configure redistribute static in BGP on R2 router") @@ -296,15 +297,19 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [NEXT_HOP_IP["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure the static route with nexthop N1") @@ -359,15 +364,19 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [NEXT_HOP_IP["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure the static route with nexthop N2") input_dict_4 = { @@ -398,8 +407,9 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) nh = NEXT_HOP_IP["nh1"][addr_type] result = verify_rib( @@ -411,15 +421,21 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) dut = "r3" result = verify_bgp_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) result = verify_rib( tgen, @@ -430,27 +446,35 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): next_hop=nh, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) dut = "r2" nh = [NEXT_HOP_IP["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) dut = "r2" step("No shut the nexthop interface N1") @@ -465,8 +489,9 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Shut nexthop interface N2") intf = topo["routers"]["r2"]["links"]["r1-link1"]["interface"] @@ -488,8 +513,11 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [NEXT_HOP_IP["nh1"][addr_type]] dut = "r2" @@ -497,19 +525,24 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) step("No shut nexthop interface N2") dut = "r2" @@ -524,19 +557,24 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -552,19 +590,26 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Route is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format( + tc_name + ) write_test_footer(tc_name) @@ -636,8 +681,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { @@ -663,8 +709,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) step("Configure IBGP IPv4 peering between R2 and R3 router.") step("Explicit route is added in R3 for R2 nexthop rechability") @@ -753,8 +800,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - "missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { @@ -771,8 +819,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte2_nh2, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) step("Configure the static route with nexthop N1") rte1_nh1 = { @@ -825,15 +874,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [NEXT_HOP_IP["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Configure the static route with nexthop N2") rte2_nh2 = { @@ -871,15 +924,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [NEXT_HOP_IP["nh2"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte2_nh2, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("No shut the nexthop interface N1") shutdown_bringup_interface(tgen, dut, intf, True) @@ -893,8 +950,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("Shut nexthop interface N2") intf = topo["routers"]["r2"]["links"]["r1-link1"]["interface"] @@ -916,15 +974,19 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format( + tc_name + ) nh = [NEXT_HOP_IP["nh1"][addr_type]] result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name) step("No shut nexthop interface N2") shutdown_bringup_interface(tgen, dut, intf, True) @@ -950,8 +1012,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { @@ -977,8 +1040,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) dut = "r3" protocol = "bgp" @@ -993,8 +1057,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) dut = "r2" step("Reload the FRR router") @@ -1024,14 +1089,16 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): result = verify_rib( tgen, addr_type, dut, rte1_nh1, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, rte1_nh1, next_hop=nh) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - "missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name) rte2_nh2 = { "r2": { @@ -1057,14 +1124,16 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, rte2_nh2, next_hop=nh) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) result = verify_rib( tgen, @@ -1076,8 +1145,9 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - "not active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name) write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py index 738d1e6e3a..ee0e01b411 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py @@ -318,8 +318,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -342,8 +343,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): dut = "r3" protocol = "bgp" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -388,8 +390,11 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed\nError: Routes is" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed\nError: Routes is" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") for addr_type in ADDR_TYPES: @@ -414,8 +419,11 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed\nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed\nError: Routes are" " missing in RIB".format( + tc_name + ) protocol = "static" step("Random shut of the nexthop interfaces") @@ -459,8 +467,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Remove random static route with all the nexthop") dut = "r2" @@ -497,8 +506,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) for addr_type in ADDR_TYPES: input_dict_4 = { @@ -550,8 +560,9 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): next_hop=nh_all[addr_type], protocol=protocol, ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Remove the redistribute static knob") for addr_type in ADDR_TYPES: @@ -584,8 +595,11 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) write_test_footer(tc_name) @@ -665,8 +679,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): @@ -683,8 +698,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -727,8 +743,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") @@ -774,8 +793,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): nh.append(NEXT_HOP_IP["nh" + str(nhp)][addr_type]) @@ -791,8 +811,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -819,8 +840,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" \ - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -830,8 +854,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" \ - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) protocol = "bgp" # this is next hop reachability route in r3 as we are using ibgp @@ -856,8 +881,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): for addr_type in ADDR_TYPES: input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \n" \ - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) protocol = "static" dut = "r2" @@ -964,8 +990,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " strill present in RIB of R3".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes are" + " strill present in RIB of R3".format(tc_name) + ) write_test_footer(tc_name) @@ -1060,8 +1088,9 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): @@ -1076,8 +1105,9 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -1120,8 +1150,11 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") @@ -1167,8 +1200,9 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) nh = [] for nhp in range(2, 9): nh.append(NEXT_HOP_IP["nh" + str(nhp)][addr_type]) @@ -1182,8 +1216,9 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -1210,8 +1245,11 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" \ - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -1221,8 +1259,9 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" \ - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) dut = "r2" protocol = "bgp" @@ -1249,8 +1288,9 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): for addr_type in ADDR_TYPES: input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \n" \ - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) protocol = "static" dut = "r2" @@ -1357,8 +1397,10 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB of R3".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes are" + " still present in RIB of R3".format(tc_name) + ) write_test_footer(tc_name) @@ -1453,8 +1495,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Verify that highest AD nexthop are inactive") nh = [] @@ -1472,8 +1515,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): wait=2, attempts=3, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -1535,8 +1579,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by one") for addr_type in ADDR_TYPES: @@ -1578,8 +1625,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " \ - "lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + "lowest AD is missing in RIB".format(tc_name) + ) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -1606,8 +1655,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" \ - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -1617,8 +1669,9 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" \ - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) step("Remove random static route with all the nexthop") for addr_type in ADDR_TYPES: @@ -1657,8 +1710,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Route " \ - " is still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Route " + " is still present in RIB".format(tc_name) + ) step("Reconfigure the deleted routes and verify they are installed") for nhp in range(1, 9): @@ -1683,8 +1738,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): protocol = "static" nh = NEXT_HOP_IP["nh1"][addr_type] result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route " \ - " is still present in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route " + " is still present in RIB".format(tc_name) + ) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -1704,9 +1761,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): ) assert ( result is True - ), "Testcase {} : Failed \nError: Route is missing in RIB".format( - tc_name - ) + ), "Testcase {} : Failed \nError: Route is missing in RIB".format(tc_name) step("Remove the redistribute static knob") for addr_type in ADDR_TYPES: @@ -1750,8 +1805,11 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) write_test_footer(tc_name) @@ -1845,8 +1903,9 @@ def test_static_route_delete_p0_tc11_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Verify that highest AD nexthop are inactive") nh = [] @@ -1862,8 +1921,9 @@ def test_static_route_delete_p0_tc11_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " are missing in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes " " are missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -1915,8 +1975,11 @@ def test_static_route_delete_p0_tc11_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) for addr_type in ADDR_TYPES: for nhp in range(1, 9): @@ -1983,8 +2046,11 @@ def test_static_route_delete_p0_tc11_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still active in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still active in RIB".format( + tc_name + ) write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py index 0045bc5c25..c84c88ac35 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py @@ -298,8 +298,9 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: input_dict_2 = { @@ -352,8 +353,11 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by" "one") @@ -380,8 +384,9 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -408,8 +413,11 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" \ - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -419,8 +427,9 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" \ - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -430,8 +439,9 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol ) - assert result is True, "Testcase {} : Failed \nError: Routes are" \ - " missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes are" " missing in RIB".format(tc_name) write_test_footer(tc_name) @@ -510,8 +520,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " \ - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) nh = [] for nhp in range(2, 9): @@ -526,8 +538,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " with high AD are active in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes " + " with high AD are active in RIB".format(tc_name) + ) step("Configure redistribute static in BGP on R2 router") for addr_type in ADDR_TYPES: @@ -570,8 +584,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " \ - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) step( "Remove the static route configured with nexthop N1 to N8, one" @@ -614,8 +630,11 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \nError: Routes are" " still present in RIB".format( + tc_name + ) step("Configure the static route with nexthop N1 to N8, one by" "one") for addr_type in ADDR_TYPES: @@ -656,8 +675,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " \ - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) nh = [] for nhp in range(2, 9): @@ -672,8 +693,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " with high AD are active in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes " + " with high AD are active in RIB".format(tc_name) + ) step("Random shut of the nexthop interfaces") randnum = random.randint(0, 7) @@ -700,8 +723,11 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" \ - "Error: Routes are still present in RIB".format(tc_name) + assert ( + result is not True + ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format( + tc_name + ) step("Random no shut of the nexthop interfaces") for addr_type in ADDR_TYPES: @@ -711,8 +737,9 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_5, next_hop=nhip, protocol=protocol ) - assert result is True, "Testcase {} : Failed \n" \ - "Error: Routes are missing in RIB".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \n" "Error: Routes are missing in RIB".format(tc_name) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -741,8 +768,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): result = verify_rib( tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True ) - assert result is True, "Testcase {} : Failed \nError: Route with " \ - " lowest AD is missing in RIB".format(tc_name) + assert result is True, ( + "Testcase {} : Failed \nError: Route with " + " lowest AD is missing in RIB".format(tc_name) + ) nh = [] for nhp in range(2, 9): @@ -757,8 +786,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): fib=True, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes " \ - " with high AD are active in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes " + " with high AD are active in RIB".format(tc_name) + ) step("Remove the redistribute static knob") @@ -796,8 +827,10 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \nError: Routes are" \ - " still present in RIB of R3".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes are" + " still present in RIB of R3".format(tc_name) + ) write_test_footer(tc_name) @@ -858,18 +891,25 @@ def test_bgp_local_nexthop_p1_tc14_ibgp(request): step("Verify R2 BGP table has IPv4 route") dut = "r2" result = verify_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Routes is" \ - " missing in RIB of R2".format(tc_name) + assert ( + result is True + ), "Testcase {} : Failed \nError: Routes is" " missing in RIB of R2".format( + tc_name + ) step(" Verify route did not install in the R3 BGP table, RIB/FIB") dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4, expected=False) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in BGP RIB of R2".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes is" + " still present in BGP RIB of R2".format(tc_name) + ) result = verify_rib(tgen, addr_type, dut, input_dict_4, expected=False) - assert result is not True, "Testcase {} : Failed \nError: Routes is" \ - " still present in RIB of R2".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \nError: Routes is" + " still present in RIB of R2".format(tc_name) + ) write_test_footer(tc_name) diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py index 5014280bf9..a82ee64538 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py @@ -239,8 +239,11 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): step(" All BGP nbrs are down as authentication is mismatch on both" " the sides") bgp_convergence = verify_bgp_convergence(tgen, topo, expected=False) - assert bgp_convergence is not True, "Testcase {} : " \ - "Failed \n BGP nbrs must be down. Error: {}".format(tc_name, bgp_convergence) + assert ( + bgp_convergence is not True + ), "Testcase {} : " "Failed \n BGP nbrs must be down. Error: {}".format( + tc_name, bgp_convergence + ) step( "Configure 4 IPv4 and 4 IPv6 nbrs with macthing password " @@ -335,8 +338,9 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): "show ip prefix list" ) result = verify_prefix_lists(tgen, input_dict_2) - assert result is not True, "Testcase {} : Failed \n" \ - " Error: {}".format(tc_name, result) + assert result is not True, "Testcase {} : Failed \n" " Error: {}".format( + tc_name, result + ) step("Redistribute all the routes (connected, static)") input_dict_2_r1 = { @@ -586,8 +590,10 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): result4 = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result4 is not True, "Testcase {} : Failed , VM1 route is " \ - "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + assert result4 is not True, ( + "Testcase {} : Failed , VM1 route is " + "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + ) step( "VM4 and VM6 IPV4 and IPv6 address are present in local and " @@ -962,8 +968,10 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): ) input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}} result4 = verify_rib(tgen, addr_type, dut, input_dict) - assert result4 is True, "Testcase {} : Failed , VM1 route is " \ - "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + assert result4 is True, ( + "Testcase {} : Failed , VM1 route is " + "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + ) step("vm4 should be present in FRR2") dut = "r2" @@ -974,8 +982,10 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): ) input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}} result4 = verify_rib(tgen, addr_type, dut, input_dict) - assert result4 is True, "Testcase {} : Failed , VM1 route is " \ - "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + assert result4 is True, ( + "Testcase {} : Failed , VM1 route is " + "not filtered out via prefix list. \n Error: {}".format(tc_name, result4) + ) dut = "r3" protocol = "bgp"