Merge pull request #3777 from donaldsharp/topotest_all_routes

topotests: Add code to ensure routes are as expected
This commit is contained in:
David Lamparter 2019-02-18 13:41:44 +01:00 committed by GitHub
commit 50734c950d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 77 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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)