]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: reset neighbor state machine to avoid bad/stale state 13490/head
authorJafar Al-Gharaibeh <jafar@atcorp.com>
Thu, 11 May 2023 05:12:29 +0000 (00:12 -0500)
committerJafar Al-Gharaibeh <jafar@atcorp.com>
Thu, 11 May 2023 14:51:26 +0000 (09:51 -0500)
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
tests/topotests/lib/ospf.py
tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py
tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py

index af1618bf62e4732b5daa0e482bb5ef5dcfb68325..ffe81fbd99cade52d8c6d6a36aca58a8cd5ac582 100644 (file)
@@ -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)
 
index ba1d49f4272dacd7dabf8cc1b2ea38e04260e493..cf7d95b65a3b63fa1f3e9c3ec999b7e34e08cb57 100644 (file)
@@ -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
index b0e56e619a096fa9a88845856741ba444561e304..8cc0ed6090529bc8d4d572bf7ad10af05aba54fd 100644 (file)
@@ -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