]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: Change bgp_gr_retained_routes to use json output of "ip route" 12841/head
authorMartin Winter <mwinter@opensourcerouting.org>
Sat, 18 Feb 2023 01:16:26 +0000 (02:16 +0100)
committerMartin Winter <mwinter@opensourcerouting.org>
Sat, 18 Feb 2023 01:16:26 +0000 (02:16 +0100)
Depending on ip_route and kernel, the output might include a nhid
which causes the test to fail with a strict text output check.
Change to json output to avoid the issue

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
tests/topotests/bgp_gr_restart_retain_routes/test_bgp_gr_restart_retain_routes.py

index 0b6152568dd0be461e18f728b5e317ad5c04bbe1..a820b4b2211b2d13203beb183a0afb6cacb5ee4f 100644 (file)
@@ -83,18 +83,9 @@ def test_bgp_gr_restart_retain_routes():
         return topotest.json_cmp(output, expected)
 
     def _bgp_check_kernel_retained_routes():
-        output = (
-            r2.cmd("ip route show 172.16.255.1/32 proto bgp dev r2-eth0")
-            .replace("\n", "")
-            .rstrip()
-        )
-        expected = "172.16.255.1 via 192.168.255.1 metric 20"
-        diff = topotest.get_textdiff(
-            output, expected, "Actual IP Routing Table", "Expected IP RoutingTable"
-        )
-        if diff:
-            return False
-        return True
+        output = json.loads(r2.cmd("ip -j route show 172.16.255.1/32 proto bgp dev r2-eth0"))
+        expected = [{"dst":"172.16.255.1","gateway":"192.168.255.1","metric":20}]
+        return topotest.json_cmp(output, expected)
 
     step("Initial BGP converge")
     test_func = functools.partial(_bgp_converge)
@@ -110,7 +101,7 @@ def test_bgp_gr_restart_retain_routes():
     assert result is None, "Failed to see BGP retained routes on R2"
 
     step("Check if routes (Kernel) are retained at R2")
-    assert _bgp_check_kernel_retained_routes() == True
+    assert _bgp_check_kernel_retained_routes() is None, "Failed to retain BGP routes in kernel on R2"
 
 
 if __name__ == "__main__":