]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotests: Add code to ensure routes are as expected 3777/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 11 Feb 2019 17:54:31 +0000 (12:54 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 11 Feb 2019 17:54:31 +0000 (12:54 -0500)
This code just ensures that v4 and v6 routes are as expected
in the rib.  While this test addition is not that complicated it would
have caught some issues while I was attempting to handle the
switchover to a different style of rib processing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
tests/topotests/all-protocol-startup/r1/ipv4_routes.ref [new file with mode: 0644]
tests/topotests/all-protocol-startup/r1/ipv6_routes.ref [new file with mode: 0644]
tests/topotests/all-protocol-startup/test_all_protocol_startup.py

diff --git a/tests/topotests/all-protocol-startup/r1/ipv4_routes.ref b/tests/topotests/all-protocol-startup/r1/ipv4_routes.ref
new file mode 100644 (file)
index 0000000..e75d896
--- /dev/null
@@ -0,0 +1,12 @@
+C>* 192.168.0.0/24 is directly connected, r1-eth0, XX:XX:XX
+C>* 192.168.1.0/26 is directly connected, r1-eth1, XX:XX:XX
+C>* 192.168.2.0/26 is directly connected, r1-eth2, XX:XX:XX
+C>* 192.168.3.0/26 is directly connected, r1-eth3, XX:XX:XX
+C>* 192.168.4.0/26 is directly connected, r1-eth4, XX:XX:XX
+C>* 192.168.5.0/26 is directly connected, r1-eth5, XX:XX:XX
+C>* 192.168.6.0/26 is directly connected, r1-eth6, XX:XX:XX
+C>* 192.168.7.0/26 is directly connected, r1-eth7, XX:XX:XX
+C>* 192.168.8.0/26 is directly connected, r1-eth8, XX:XX:XX
+C>* 192.168.9.0/26 is directly connected, r1-eth9, XX:XX:XX
+O   192.168.0.0/24 [110/10] is directly connected, r1-eth0, XX:XX:XX
+O   192.168.3.0/26 [110/10] is directly connected, r1-eth3, XX:XX:XX
diff --git a/tests/topotests/all-protocol-startup/r1/ipv6_routes.ref b/tests/topotests/all-protocol-startup/r1/ipv6_routes.ref
new file mode 100644 (file)
index 0000000..88cee96
--- /dev/null
@@ -0,0 +1,22 @@
+C>* fc00:0:0:1::/64 is directly connected, r1-eth1, XX:XX:XX
+C>* fc00:0:0:2::/64 is directly connected, r1-eth2, XX:XX:XX
+C>* fc00:0:0:3::/64 is directly connected, r1-eth3, XX:XX:XX
+C>* fc00:0:0:4::/64 is directly connected, r1-eth4, XX:XX:XX
+C>* fc00:0:0:5::/64 is directly connected, r1-eth5, XX:XX:XX
+C>* fc00:0:0:6::/64 is directly connected, r1-eth6, XX:XX:XX
+C>* fc00:0:0:7::/64 is directly connected, r1-eth7, XX:XX:XX
+C>* fc00:0:0:8::/64 is directly connected, r1-eth8, XX:XX:XX
+C>* fc00:0:0:9::/64 is directly connected, r1-eth9, XX:XX:XX
+C>* fc00::/64 is directly connected, r1-eth0, XX:XX:XX
+C>* fe80::/64 is directly connected, lo, XX:XX:XX
+C * fe80::/64 is directly connected, r1-eth0, XX:XX:XX
+C * fe80::/64 is directly connected, r1-eth1, XX:XX:XX
+C * fe80::/64 is directly connected, r1-eth2, XX:XX:XX
+C * fe80::/64 is directly connected, r1-eth3, XX:XX:XX
+C * fe80::/64 is directly connected, r1-eth4, XX:XX:XX
+C * fe80::/64 is directly connected, r1-eth5, XX:XX:XX
+C * fe80::/64 is directly connected, r1-eth6, XX:XX:XX
+C * fe80::/64 is directly connected, r1-eth7, XX:XX:XX
+C * fe80::/64 is directly connected, r1-eth8, XX:XX:XX
+C * fe80::/64 is directly connected, r1-eth9, XX:XX:XX
+O   fc00:0:0:4::/64 [110/10] is directly connected, r1-eth4, XX:XX:XX
index fb2100e03deccf511df8c5c6b69fbbac97bcc8b0..239de55bd6f27baf5cea9245cfc5da0945ae9ae4 100755 (executable)
@@ -296,10 +296,53 @@ def test_converge_protocols():
     sleep(60)
 
     # Make sure that all daemons are running
+    failures = 0
     for i in range(1, 2):
         fatal_error = net['r%s' % i].checkRouterRunning()
         assert fatal_error == "", fatal_error
 
+        print("Show that v4 routes are right\n");
+        v4_routesFile = '%s/r%s/ipv4_routes.ref' % (thisDir, i)
+        expected = open(v4_routesFile).read().rstrip()
+        expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
+
+        actual = net['r%s' %i].cmd('vtysh -c "show ip route" | /usr/bin/tail -n +7 | sort 2> /dev/null').rstrip()
+        # Drop time in last update
+        actual = re.sub(r" [0-2][0-9]:[0-5][0-9]:[0-5][0-9]", " XX:XX:XX", actual)
+        actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
+        diff = topotest.get_textdiff(actual, expected,
+                                     title1="Actual IP Routing Table",
+                                     title2="Expected IP RoutingTable")
+        if diff:
+            sys.stderr.write('r%s failed IP Routing table check:\n%s\n' % (i, diff))
+            failures += 1
+        else:
+            print("r%s ok" %i)
+
+        assert failures == 0, "IP Routing table failed for r%s\n%s" % (i, diff)
+
+        failures = 0
+
+        print("Show that v6 routes are right\n")
+        v6_routesFile = '%s/r%s/ipv6_routes.ref' % (thisDir, i)
+        expected = open(v6_routesFile).read().rstrip()
+        expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
+
+        actual = net['r%s' %i].cmd('vtysh -c "show ipv6 route" | /usr/bin/tail -n +7 | sort 2> /dev/null').rstrip()
+        # Drop time in last update
+        actual = re.sub(r" [0-2][0-9]:[0-5][0-9]:[0-5][0-9]", " XX:XX:XX", actual)
+        actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
+        diff = topotest.get_textdiff(actual, expected,
+                                     title1="Actual IPv6 Routing Table",
+                                     title2="Expected IPv6 RoutingTable")
+        if diff:
+            sys.stderr.write('r%s failed IPv6 Routing table check:\n%s\n' % (i, diff))
+            failures += 1
+        else:
+            print("r%s ok" %i)
+
+        assert failures == 0, "IPv6 Routing table failed for r%s\n%s" % (i, diff)
+
     # For debugging after starting FRR/Quagga daemons, uncomment the next line
     ## CLI(net)