]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospf-topo1-vrf: replace ip_route method with ip_route_zebra
authorPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 20 Jul 2018 14:23:51 +0000 (16:23 +0200)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 28 Nov 2018 01:22:14 +0000 (20:22 -0500)
To analyse which route has been entered in the kernel, the
 zebra show ip route vrf command is used.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
tests/topotests/ospf-topo1-vrf/r1/zebraroute.txt [new file with mode: 0644]
tests/topotests/ospf-topo1-vrf/r1/zebraroutedown.txt [new file with mode: 0644]
tests/topotests/ospf-topo1-vrf/r2/zebraroute.txt [new file with mode: 0644]
tests/topotests/ospf-topo1-vrf/r2/zebraroutedown.txt [new file with mode: 0644]
tests/topotests/ospf-topo1-vrf/r3/zebraroute.txt [new file with mode: 0644]
tests/topotests/ospf-topo1-vrf/r3/zebraroutedown.txt [new file with mode: 0644]
tests/topotests/ospf-topo1-vrf/test_ospf_topo1_vrf.py

diff --git a/tests/topotests/ospf-topo1-vrf/r1/zebraroute.txt b/tests/topotests/ospf-topo1-vrf/r1/zebraroute.txt
new file mode 100644 (file)
index 0000000..a5e9573
--- /dev/null
@@ -0,0 +1,15 @@
+Codes: K - kernel route, C - connected, S - static, R - RIP,
+       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
+       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
+       F - PBR,
+       > - selected route, * - FIB route
+
+
+VRF r1-cust1:
+O   10.0.1.0/24 [110/10] is directly connected, r1-eth0, XX:XX:XX
+C>* 10.0.1.0/24 is directly connected, r1-eth0, XX:XX:XX
+O>* 10.0.2.0/24 [110/20] via 10.0.3.3, r1-eth1, XX:XX:XX
+O   10.0.3.0/24 [110/10] is directly connected, r1-eth1, XX:XX:XX
+C>* 10.0.3.0/24 is directly connected, r1-eth1, XX:XX:XX
+O>* 10.0.10.0/24 [110/20] via 10.0.3.1, r1-eth1, XX:XX:XX
+
diff --git a/tests/topotests/ospf-topo1-vrf/r1/zebraroutedown.txt b/tests/topotests/ospf-topo1-vrf/r1/zebraroutedown.txt
new file mode 100644 (file)
index 0000000..b6ef099
--- /dev/null
@@ -0,0 +1,14 @@
+Codes: K - kernel route, C - connected, S - static, R - RIP,
+       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
+       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
+       F - PBR,
+       > - selected route, * - FIB route
+
+
+VRF r1-cust1:
+O   10.0.1.0/24 [110/10] is directly connected, r1-eth0, XX:XX:XX
+C>* 10.0.1.0/24 is directly connected, r1-eth0, XX:XX:XX
+O>* 10.0.2.0/24 [110/20] via 10.0.3.3, r1-eth1, XX:XX:XX
+O   10.0.3.0/24 [110/10] is directly connected, r1-eth1, XX:XX:XX
+C>* 10.0.3.0/24 is directly connected, r1-eth1, XX:XX:XX
+
diff --git a/tests/topotests/ospf-topo1-vrf/r2/zebraroute.txt b/tests/topotests/ospf-topo1-vrf/r2/zebraroute.txt
new file mode 100644 (file)
index 0000000..d079c62
--- /dev/null
@@ -0,0 +1,15 @@
+Codes: K - kernel route, C - connected, S - static, R - RIP,
+       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
+       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
+       F - PBR,
+       > - selected route, * - FIB route
+
+
+VRF r2-cust1:
+O>* 10.0.1.0/24 [110/20] via 10.0.3.2, r2-eth1, XX:XX:XX
+O   10.0.2.0/24 [110/10] is directly connected, r2-eth0, XX:XX:XX
+C>* 10.0.2.0/24 is directly connected, r2-eth0, XX:XX:XX
+O   10.0.3.0/24 [110/10] is directly connected, r2-eth1, XX:XX:XX
+C>* 10.0.3.0/24 is directly connected, r2-eth1, XX:XX:XX
+O>* 10.0.10.0/24 [110/20] via 10.0.3.1, r2-eth1, XX:XX:XX
+
diff --git a/tests/topotests/ospf-topo1-vrf/r2/zebraroutedown.txt b/tests/topotests/ospf-topo1-vrf/r2/zebraroutedown.txt
new file mode 100644 (file)
index 0000000..7ad5f14
--- /dev/null
@@ -0,0 +1,14 @@
+Codes: K - kernel route, C - connected, S - static, R - RIP,
+       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
+       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
+       F - PBR,
+       > - selected route, * - FIB route
+
+
+VRF r2-cust1:
+O>* 10.0.1.0/24 [110/20] via 10.0.3.2, r2-eth1, XX:XX:XX
+O   10.0.2.0/24 [110/10] is directly connected, r2-eth0, XX:XX:XX
+C>* 10.0.2.0/24 is directly connected, r2-eth0, XX:XX:XX
+O   10.0.3.0/24 [110/10] is directly connected, r2-eth1, XX:XX:XX
+C>* 10.0.3.0/24 is directly connected, r2-eth1, XX:XX:XX
+
diff --git a/tests/topotests/ospf-topo1-vrf/r3/zebraroute.txt b/tests/topotests/ospf-topo1-vrf/r3/zebraroute.txt
new file mode 100644 (file)
index 0000000..f620942
--- /dev/null
@@ -0,0 +1,15 @@
+Codes: K - kernel route, C - connected, S - static, R - RIP,
+       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
+       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
+       F - PBR,
+       > - selected route, * - FIB route
+
+
+VRF r3-cust1:
+O>* 10.0.1.0/24 [110/20] via 10.0.3.2, r3-eth0, XX:XX:XX
+O>* 10.0.2.0/24 [110/20] via 10.0.3.3, r3-eth0, XX:XX:XX
+O   10.0.3.0/24 [110/10] is directly connected, r3-eth0, XX:XX:XX
+C>* 10.0.3.0/24 is directly connected, r3-eth0, XX:XX:XX
+O   10.0.10.0/24 [110/10] is directly connected, r3-eth1, XX:XX:XX
+C>* 10.0.10.0/24 is directly connected, r3-eth1, XX:XX:XX
+
diff --git a/tests/topotests/ospf-topo1-vrf/r3/zebraroutedown.txt b/tests/topotests/ospf-topo1-vrf/r3/zebraroutedown.txt
new file mode 100644 (file)
index 0000000..30b495d
--- /dev/null
@@ -0,0 +1,11 @@
+Codes: K - kernel route, C - connected, S - static, R - RIP,
+       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
+       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
+       F - PBR,
+       > - selected route, * - FIB route
+
+
+VRF r3-cust1:
+O   10.0.10.0/24 [110/10] is directly connected, r3-eth1, XX:XX:XX
+C>* 10.0.10.0/24 is directly connected, r3-eth1, XX:XX:XX
+
index 9464e6fb1d86cc2f4feb672268f60c2aa2b07e92..0a111504e4fae72d3983d103f9f7f0b4a6e727a4 100755 (executable)
@@ -150,6 +150,21 @@ def compare_show_ip_ospf_vrf(rname, expected):
                               title1="Current output",
                               title2="Expected output")
 
+def compare_show_ip_route_vrf(rname, expected):
+    """
+    Calls 'show ip ospf vrf [rname]-cust1 route' for router `rname` and compare the obtained
+    result with the expected output.
+    """
+    tgen = get_topogen()
+    if tgen.gears[rname].has_version('<', '4.0') == True:
+        return
+    vrf_name = '{0}-cust1'.format(rname)
+    current = topotest.ip4_route_zebra(tgen.gears[rname], vrf_name)
+    ret = topotest.difflines(current, expected,
+                             title1="Current output",
+                             title2="Expected output")
+    return ret
+
 def test_ospf_convergence():
     "Test OSPF daemon convergence"
     tgen = get_topogen()
@@ -190,15 +205,13 @@ def test_ospf_kernel_route():
     for router in rlist:
         logger.info('Checking OSPF IPv4 kernel routes in "%s"', router.name)
         str='{0}-cust1'.format(router.name)
-        routes = topotest.ip4_route(router,str)
-        expected = {
-            '10.0.1.0/24': {},
-            '10.0.2.0/24': {},
-            '10.0.3.0/24': {},
-            '10.0.10.0/24': {},
-        }
-        assertmsg = 'OSPF IPv4 route mismatch in router "{}"'.format(router.name)
-        assert topotest.json_cmp(routes, expected) is None, assertmsg
+        reffile = os.path.join(CWD, '{}/zebraroute.txt'.format(router.name))
+        expected = open(reffile).read()
+        # Run test function until we get an result. Wait at most 60 seconds.
+        test_func = partial(compare_show_ip_route_vrf, router.name, expected)
+        result, diff = topotest.run_and_expect(test_func, '',
+                                               count=25, wait=3)
+        assert result, 'OSPF IPv4 route mismatch in router "{}"'.format(router.name, diff)
 
 def test_ospf_json():
     "Test 'show ip ospf json' output for coherency."
@@ -290,27 +303,13 @@ def test_ospf_link_down_kernel_route():
         logger.info('Checking OSPF IPv4 kernel routes in "%s" after link down', router.name)
 
         str='{0}-cust1'.format(router.name)
-        routes = topotest.ip4_route(router, str)
-        expected = {
-            '10.0.1.0/24': {},
-            '10.0.2.0/24': {},
-            '10.0.3.0/24': {},
-            '10.0.10.0/24': {},
-        }
-        if router.name == 'r1' or router.name == 'r2':
-            expected.update({
-                '10.0.10.0/24': None,
-                '172.16.0.0/24': None,
-                '172.16.1.0/24': None,
-            })
-        elif router.name == 'r3':
-            expected.update({
-                '10.0.1.0/24': None,
-                '10.0.2.0/24': None,
-            })
-        # Route '10.0.3.0' is no longer available for r4 since it is down.
-        assertmsg = 'OSPF IPv4 route mismatch in router "{}" after link down'.format(router.name)
-        assert topotest.json_cmp(routes, expected) is None, assertmsg
+        reffile = os.path.join(CWD, '{}/zebraroutedown.txt'.format(router.name))
+        expected = open(reffile).read()
+        # Run test function until we get an result. Wait at most 60 seconds.
+        test_func = partial(compare_show_ip_route_vrf, router.name, expected)
+        result, diff = topotest.run_and_expect(test_func, '',
+                                               count=25, wait=3)
+        assert result, 'OSPF IPv4 route mismatch in router "{}" after link down'.format(router.name, diff)
 
 def test_memory_leak():
     "Run the memory leak test and report results."