]> git.proxmox.com Git - mirror_frr.git/commitdiff
tests: do not use a custom expect function in isis_lfa_topo1
authorLouis Scalbert <louis.scalbert@6wind.com>
Mon, 21 Nov 2022 11:14:03 +0000 (12:14 +0100)
committerLouis Scalbert <louis.scalbert@6wind.com>
Mon, 21 Nov 2022 12:48:51 +0000 (13:48 +0100)
Replace the custom run and expect function by one from the library.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py

index f46f6bf9c3223540b10ed863964a9f2bf2bc1b51..d01ba9da3f6388c8f2dde231c2ee03cb86e4f7db 100755 (executable)
@@ -758,6 +758,80 @@ def test_rib_ipv6_step17():
 # - Route switchover of routes via eth-rt2
 #
 def test_rib_ipv6_step18():
+    def _rt2_neigh_down(router):
+        output = json.loads(router.vtysh_cmd("show isis neighbor rt2 json"))
+
+        """
+        Previous output was:
+        {
+          "areas":[
+            {
+              "area":"1",
+              "circuits":[
+                {
+                  "circuit":0,
+                  "adj":"rt2",
+                  "interface":{
+                    "name":"eth-rt2",
+                    "state":"Up",
+                    "adj-flaps":1,
+                    "last-ago":"21s",
+                    "circuit-type":"L1",
+                    "speaks":"IPv6",
+                    "topologies":{
+                      "topo-0":"ipv6-unicast"
+                    },
+                    "snpa":"2020.2020.2020",
+                    "area-address":{
+                      "isonet":"49.0000"
+                    },
+                    "ipv6-link-local":{
+                      "ipv6":"fe80::ac19:a8ff:fee5:f48f"
+                    },
+                    "adj-sid":{
+                    }
+                  },
+                  "level":1,
+                  "expires-in":"2s"
+                },
+                {
+                  "circuit":0
+                },
+                {
+                  "circuit":0
+                },
+                {
+                  "circuit":0
+                },
+                {
+                  "circuit":0
+                },
+                {
+                  "circuit":0
+                }
+              ]
+            }
+          ]
+        """
+
+        expected = {
+            "areas": [
+                {
+                    "area": "1",
+                    "circuits": [
+                        {"circuit": 0},
+                        {"circuit": 0},
+                        {"circuit": 0},
+                        {"circuit": 0},
+                        {"circuit": 0},
+                        {"circuit": 0},
+                    ],
+                }
+            ]
+        }
+
+        return topotest.json_cmp(output, expected, exact=True)
+
     logger.info("Test (step 18): verify IPv6 RIB")
     tgen = get_topogen()
 
@@ -769,23 +843,10 @@ def test_rib_ipv6_step18():
     tgen.net.cmd_raises("ip link set s1 down")
 
     rname = "rt1"
-
-    retry = 200 + 1
-
-    while retry:
-        retry -= 1
-        output = tgen.gears[rname].vtysh_cmd("show isis neighbor json")
-        output_json = json.loads(output)
-        found = False
-        for neighbor in output_json["areas"][0]["circuits"]:
-            if "adj" in neighbor and neighbor["adj"] == "rt2":
-                found = True
-                break
-        if not found:
-            break
-        time.sleep(0.05)
-
-    assert not found, "rt2 neighbor is still present"
+    router = tgen.gears[rname]
+    test_func = partial(_rt2_neigh_down, router)
+    success, result = topotest.run_and_expect(test_func, None, count=200, wait=0.05)
+    assert result is None, 'rt2 neighbor is still present on "{}"'.format(router)
 
     router_compare_json_output(
         rname,