diff options
3 files changed, 18 insertions, 10 deletions
diff --git a/tests/topotests/lib/ospf.py b/tests/topotests/lib/ospf.py index af1618bf6..ffe81fbd9 100644 --- a/tests/topotests/lib/ospf.py +++ b/tests/topotests/lib/ospf.py @@ -302,7 +302,6 @@ def __create_ospf_global(tgen, input_dict, router, build, load_config, ospf): # ospf gr information gr_data = ospf_data.setdefault("graceful-restart", {}) if gr_data: - if "opaque" in gr_data and gr_data["opaque"]: cmd = "capability opaque" if gr_data.setdefault("delete", False): @@ -729,8 +728,10 @@ def verify_ospf_neighbor( try: nh_state = show_ospf_json[nbr_rid][0]["nbrState"].split("/")[0] except KeyError: - errormsg = "[DUT: {}] missing OSPF neighbor {} with router-id {}".format( - router, ospf_nbr, nbr_rid + errormsg = ( + "[DUT: {}] missing OSPF neighbor {} with router-id {}".format( + router, ospf_nbr, nbr_rid + ) ) return errormsg @@ -844,7 +845,6 @@ def verify_ospf6_neighbor(tgen, topo=None, dut=None, input_dict=None, lan=False) return errormsg for ospf_nbr, nbr_data in ospf_nbr_list.items(): - try: data_ip = data_rid = topo["routers"][ospf_nbr]["ospf6"]["router_id"] except KeyError: @@ -915,7 +915,6 @@ def verify_ospf6_neighbor(tgen, topo=None, dut=None, input_dict=None, lan=False) return errormsg continue else: - for router, rnode in tgen.routers().items(): if "ospf6" not in topo["routers"][router]: continue @@ -969,8 +968,10 @@ def verify_ospf6_neighbor(tgen, topo=None, dut=None, input_dict=None, lan=False) nh_state = get_index_val.get(neighbor_ip)["state"] intf_state = get_index_val.get(neighbor_ip)["ifState"] except TypeError: - errormsg = "[DUT: {}] missing OSPF neighbor {} with router-id {}".format( - router, ospf_nbr, nbr_rid + errormsg = ( + "[DUT: {}] missing OSPF neighbor {} with router-id {}".format( + router, ospf_nbr, nbr_rid + ) ) return errormsg @@ -1762,7 +1763,6 @@ def verify_ospf6_rib( continue if st_rt in ospf_rib_json: - st_found = True found_routes.append(st_rt) diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py index ba1d49f42..cf7d95b65 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py @@ -977,7 +977,7 @@ def test_ospf_type5_summary_tc42_p0(request): ip = topo["routers"]["r0"]["links"]["r3"]["ipv4"] - ip_net = str(ipaddress.ip_interface(u"{}".format(ip)).network) + ip_net = str(ipaddress.ip_interface("{}".format(ip)).network) ospf_summ_r1 = { "r0": { "ospf": {"summary-address": [{"prefix": ip_net.split("/")[0], "mask": "8"}]} @@ -1579,6 +1579,10 @@ def test_ospf_type5_summary_tc45_p0(request): result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) + # clear neighbor state on both routers to avoid stale state + tgen.net["r0"].cmd("clear ip ospf neighbor") + tgen.net["r1"].cmd("clear ip ospf neighbor") + ospf_covergence = verify_ospf_neighbor(tgen, topo) assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py index b0e56e619..8cc0ed609 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py @@ -565,7 +565,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): ip = topo["routers"]["r0"]["links"]["r3"]["ipv6"] - ip_net = str(ipaddress.ip_interface(u"{}".format(ip)).network) + ip_net = str(ipaddress.ip_interface("{}".format(ip)).network) ospf_summ_r1 = { "r0": { "ospf6": { @@ -1428,6 +1428,10 @@ def ospfv3_type5_summary_tc45_p0(request): result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) + # restart interface state machine on both routers to avoid stale state + tgen.net["r0"].cmd("clear ipv6 ospf6 interface") + tgen.net["r1"].cmd("clear ipv6 ospf6 interface") + ospf_covergence = verify_ospf6_neighbor(tgen, topo) assert ospf_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf_covergence |