--- /dev/null
+BGP table version is 1, local router ID is 192.168.0.1, vrf id 0
+Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
+ i internal, r RIB-failure, S Stale, R Removed
+Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
+Origin codes: i - IGP, e - EGP, ? - incomplete
+
+ Network Next Hop Metric LocPrf Weight Path
+*> 192.168.0.0 0.0.0.0 0 32768 i
--- /dev/null
+BGP table version is 1, local router ID is 192.168.0.1, vrf id 0
+Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
+ i internal, r RIB-failure, S Stale, R Removed
+Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
+Origin codes: i - IGP, e - EGP, ? - incomplete
+
+ Network Next Hop Metric LocPrf Weight Path
+*> fc00::/64 :: 0 32768 i
import re
import sys
import pytest
+import glob
from time import sleep
from mininet.topo import Topo
print("\n\n** Verifying BGP IPv4")
print("******************************************\n")
- failures = 0
+ diffresult = {}
for i in range(1, 2):
- refTableFile = '%s/r%s/show_bgp_ipv4.ref' % (thisDir, i)
- if os.path.isfile(refTableFile):
- # Read expected result from file
- expected = open(refTableFile).read().rstrip()
- # Fix newlines (make them all the same)
- expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
-
- # Actual output from router
- actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv4" 2> /dev/null').rstrip()
- # Remove summary line (changed recently)
- actual = re.sub(r'Total number.*', '', actual)
- actual = re.sub(r'Displayed.*', '', actual)
- actual = actual.rstrip()
- # Fix newlines (make them all the same)
- actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
-
- # Generate Diff
- diff = topotest.get_textdiff(actual, expected,
- title1="actual SHOW BGP IPv4",
- title2="expected SHOW BGP IPv4")
-
- # Empty string if it matches, otherwise diff contains unified diff
- if diff:
- sys.stderr.write('r%s failed SHOW BGP IPv4 check:\n%s\n' % (i, diff))
- failures += 1
- else:
- print("r%s ok" % i)
-
- assert failures == 0, "SHOW BGP IPv4 failed for router r%s:\n%s" % (i, diff)
+ success = 0
+ for refTableFile in (glob.glob(
+ '%s/r%s/show_bgp_ipv4*.ref' % (thisDir, i))):
+ if os.path.isfile(refTableFile):
+ # Read expected result from file
+ expected = open(refTableFile).read().rstrip()
+ # Fix newlines (make them all the same)
+ expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
+
+ # Actual output from router
+ actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv4" 2> /dev/null').rstrip()
+ # Remove summary line (changed recently)
+ actual = re.sub(r'Total number.*', '', actual)
+ actual = re.sub(r'Displayed.*', '', actual)
+ actual = actual.rstrip()
+ # Fix newlines (make them all the same)
+ actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
+
+ # Generate Diff
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual SHOW BGP IPv4",
+ title2="expected SHOW BGP IPv4")
+
+ # Empty string if it matches, otherwise diff contains unified diff
+ if diff:
+ diffresult[refTableFile] = diff
+ else:
+ success = 1
+ print("template %s matched: r%s ok" % (refTableFile, i))
+ break
+
+ if not success:
+ resultstr = 'No template matched.\n'
+ for f in diffresult.iterkeys():
+ resultstr += (
+ 'template %s: r%s failed SHOW BGP IPv4 check:\n%s\n'
+ % (f, i, diffresult[f]))
+ raise AssertionError(
+ "SHOW BGP IPv4 failed for router r%s:\n%s" % (i, resultstr))
# Make sure that all daemons are running
for i in range(1, 2):
print("\n\n** Verifying BGP IPv6")
print("******************************************\n")
- failures = 0
+ diffresult = {}
for i in range(1, 2):
- refTableFile = '%s/r%s/show_bgp_ipv6.ref' % (thisDir, i)
- if os.path.isfile(refTableFile):
- # Read expected result from file
- expected = open(refTableFile).read().rstrip()
- # Fix newlines (make them all the same)
- expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
-
- # Actual output from router
- actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv6" 2> /dev/null').rstrip()
- # Remove summary line (changed recently)
- actual = re.sub(r'Total number.*', '', actual)
- actual = re.sub(r'Displayed.*', '', actual)
- actual = actual.rstrip()
- # Fix newlines (make them all the same)
- actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
-
- # Generate Diff
- diff = topotest.get_textdiff(actual, expected,
- title1="actual SHOW BGP IPv6",
- title2="expected SHOW BGP IPv6")
-
- # Empty string if it matches, otherwise diff contains unified diff
- if diff:
- sys.stderr.write('r%s failed SHOW BGP IPv6 check:\n%s\n' % (i, diff))
- failures += 1
- else:
- print("r%s ok" % i)
-
- assert failures == 0, "SHOW BGP IPv6 failed for router r%s:\n%s" % (i, diff)
+ success = 0
+ for refTableFile in (glob.glob(
+ '%s/r%s/show_bgp_ipv6*.ref' % (thisDir, i))):
+ if os.path.isfile(refTableFile):
+ # Read expected result from file
+ expected = open(refTableFile).read().rstrip()
+ # Fix newlines (make them all the same)
+ expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
+
+ # Actual output from router
+ actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv6" 2> /dev/null').rstrip()
+ # Remove summary line (changed recently)
+ actual = re.sub(r'Total number.*', '', actual)
+ actual = re.sub(r'Displayed.*', '', actual)
+ actual = actual.rstrip()
+ # Fix newlines (make them all the same)
+ actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
+
+ # Generate Diff
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual SHOW BGP IPv6",
+ title2="expected SHOW BGP IPv6")
+
+ # Empty string if it matches, otherwise diff contains unified diff
+ if diff:
+ diffresult[refTableFile] = diff
+ else:
+ success = 1
+ print("template %s matched: r%s ok" % (refTableFile, i))
+
+ if not success:
+ resultstr = 'No template matched.\n'
+ for f in diffresult.iterkeys():
+ resultstr += (
+ 'template %s: r%s failed SHOW BGP IPv6 check:\n%s\n'
+ % (f, i, diffresult[f]))
+ raise AssertionError(
+ "SHOW BGP IPv6 failed for router r%s:\n%s" % (i, resultstr))
# Make sure that all daemons are running
for i in range(1, 2):
--- /dev/null
+BGP table version is XXX, local router ID is 172.30.1.1, vrf id 0
+Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
+ i internal, r RIB-failure, S Stale, R Removed
+Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
+Origin codes: i - IGP, e - EGP, ? - incomplete
+
+ Network Next Hop Metric LocPrf Weight Path
+* 10.0.1.0/24 172.16.1.5 0 65005 i
+* 172.16.1.2 0 65002 i
+*> 172.16.1.1 0 65001 i
+*> 10.101.0.0/24 172.16.1.1 100 0 65001 i
+*> 10.101.1.0/24 172.16.1.1 100 0 65001 i
+*> 10.101.2.0/24 172.16.1.1 100 0 65001 i
+*> 10.101.3.0/24 172.16.1.1 100 0 65001 i
+*> 10.101.4.0/24 172.16.1.1 100 0 65001 i
+*> 10.101.5.0/24 172.16.1.1 100 0 65001 i
+*> 10.101.6.0/24 172.16.1.1 100 0 65001 i
+*> 10.101.7.0/24 172.16.1.1 100 0 65001 i
+*> 10.101.8.0/24 172.16.1.1 100 0 65001 i
+*> 10.101.9.0/24 172.16.1.1 100 0 65001 i
+*> 10.102.0.0/24 172.16.1.2 100 0 65002 i
+*> 10.102.1.0/24 172.16.1.2 100 0 65002 i
+*> 10.102.2.0/24 172.16.1.2 100 0 65002 i
+*> 10.102.3.0/24 172.16.1.2 100 0 65002 i
+*> 10.102.4.0/24 172.16.1.2 100 0 65002 i
+*> 10.102.5.0/24 172.16.1.2 100 0 65002 i
+*> 10.102.6.0/24 172.16.1.2 100 0 65002 i
+*> 10.102.7.0/24 172.16.1.2 100 0 65002 i
+*> 10.102.8.0/24 172.16.1.2 100 0 65002 i
+*> 10.102.9.0/24 172.16.1.2 100 0 65002 i
+*> 10.105.0.0/24 172.16.1.5 100 0 65005 i
+*> 10.105.1.0/24 172.16.1.5 100 0 65005 i
+*> 10.105.2.0/24 172.16.1.5 100 0 65005 i
+*> 10.105.3.0/24 172.16.1.5 100 0 65005 i
+*> 10.105.4.0/24 172.16.1.5 100 0 65005 i
+*> 10.105.5.0/24 172.16.1.5 100 0 65005 i
+*> 10.105.6.0/24 172.16.1.5 100 0 65005 i
+*> 10.105.7.0/24 172.16.1.5 100 0 65005 i
+*> 10.105.8.0/24 172.16.1.5 100 0 65005 i
+*> 10.105.9.0/24 172.16.1.5 100 0 65005 i
+*> 172.20.0.0/28 0.0.0.0 0 32768 i
--- /dev/null
+BGP table version is XXX, local router ID is 172.30.1.1, vrf id 0
+Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
+ i internal, r RIB-failure, S Stale, R Removed
+Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
+Origin codes: i - IGP, e - EGP, ? - incomplete
+
+ Network Next Hop Metric LocPrf Weight Path
+* 10.0.1.0/24 172.16.1.4 0 65004 i
+*> 172.16.1.3 0 65003 i
+*> 10.103.0.0/24 172.16.1.3 100 0 65003 i
+*> 10.103.1.0/24 172.16.1.3 100 0 65003 i
+*> 10.103.2.0/24 172.16.1.3 100 0 65003 i
+*> 10.103.3.0/24 172.16.1.3 100 0 65003 i
+*> 10.103.4.0/24 172.16.1.3 100 0 65003 i
+*> 10.103.5.0/24 172.16.1.3 100 0 65003 i
+*> 10.103.6.0/24 172.16.1.3 100 0 65003 i
+*> 10.103.7.0/24 172.16.1.3 100 0 65003 i
+*> 10.103.8.0/24 172.16.1.3 100 0 65003 i
+*> 10.103.9.0/24 172.16.1.3 100 0 65003 i
+*> 10.104.0.0/24 172.16.1.4 100 0 65004 i
+*> 10.104.1.0/24 172.16.1.4 100 0 65004 i
+*> 10.104.2.0/24 172.16.1.4 100 0 65004 i
+*> 10.104.3.0/24 172.16.1.4 100 0 65004 i
+*> 10.104.4.0/24 172.16.1.4 100 0 65004 i
+*> 10.104.5.0/24 172.16.1.4 100 0 65004 i
+*> 10.104.6.0/24 172.16.1.4 100 0 65004 i
+*> 10.104.7.0/24 172.16.1.4 100 0 65004 i
+*> 10.104.8.0/24 172.16.1.4 100 0 65004 i
+*> 10.104.9.0/24 172.16.1.4 100 0 65004 i
+*> 172.20.0.0/28 0.0.0.0 9999 32768 100 100 100 100 100 i
--- /dev/null
+BGP table version is XXX, local router ID is 172.30.1.1, vrf id 0
+Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
+ i internal, r RIB-failure, S Stale, R Removed
+Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
+Origin codes: i - IGP, e - EGP, ? - incomplete
+
+ Network Next Hop Metric LocPrf Weight Path
+* 10.0.1.0/24 172.16.1.8 0 65008 i
+* 172.16.1.7 0 65007 i
+*> 172.16.1.6 0 65006 i
+*> 10.106.0.0/24 172.16.1.6 100 0 65006 i
+*> 10.106.1.0/24 172.16.1.6 100 0 65006 i
+*> 10.106.2.0/24 172.16.1.6 100 0 65006 i
+*> 10.106.3.0/24 172.16.1.6 100 0 65006 i
+*> 10.106.4.0/24 172.16.1.6 100 0 65006 i
+*> 10.106.5.0/24 172.16.1.6 100 0 65006 i
+*> 10.106.6.0/24 172.16.1.6 100 0 65006 i
+*> 10.106.7.0/24 172.16.1.6 100 0 65006 i
+*> 10.106.8.0/24 172.16.1.6 100 0 65006 i
+*> 10.106.9.0/24 172.16.1.6 100 0 65006 i
+*> 10.107.0.0/24 172.16.1.7 100 0 65007 i
+*> 10.107.1.0/24 172.16.1.7 100 0 65007 i
+*> 10.107.2.0/24 172.16.1.7 100 0 65007 i
+*> 10.107.3.0/24 172.16.1.7 100 0 65007 i
+*> 10.107.4.0/24 172.16.1.7 100 0 65007 i
+*> 10.107.5.0/24 172.16.1.7 100 0 65007 i
+*> 10.107.6.0/24 172.16.1.7 100 0 65007 i
+*> 10.107.7.0/24 172.16.1.7 100 0 65007 i
+*> 10.107.8.0/24 172.16.1.7 100 0 65007 i
+*> 10.107.9.0/24 172.16.1.7 100 0 65007 i
+*> 10.108.0.0/24 172.16.1.8 100 0 65008 i
+*> 10.108.1.0/24 172.16.1.8 100 0 65008 i
+*> 10.108.2.0/24 172.16.1.8 100 0 65008 i
+*> 10.108.3.0/24 172.16.1.8 100 0 65008 i
+*> 10.108.4.0/24 172.16.1.8 100 0 65008 i
+*> 10.108.5.0/24 172.16.1.8 100 0 65008 i
+*> 10.108.6.0/24 172.16.1.8 100 0 65008 i
+*> 10.108.7.0/24 172.16.1.8 100 0 65008 i
+*> 10.108.8.0/24 172.16.1.8 100 0 65008 i
+*> 10.108.9.0/24 172.16.1.8 100 0 65008 i
+*> 172.20.0.0/28 0.0.0.0 0 32768 i
import re
import sys
import pytest
+import glob
from time import sleep
from mininet.topo import Topo
print("\n\n** Verifying BGP Routing Tables")
print("******************************************\n")
- failures = 0
+ diffresult = {}
for i in range(1, 2):
for view in range(1, 4):
- refTableFile = '%s/r%s/show_ip_bgp_view_%s.ref' % (thisDir, i, view)
- if os.path.isfile(refTableFile):
- # Read expected result from file
- expected = open(refTableFile).read().rstrip()
- # Fix newlines (make them all the same)
- expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
-
- # Actual output from router
- actual = net['r%s' % i].cmd('vtysh -c "show ip bgp view %s" 2> /dev/null' % view).rstrip()
-
- # Fix inconsitent spaces between 0.99.24 and newer versions of Quagga...
- actual = re.sub('0 0', '0 0', actual)
- actual = re.sub(r'([0-9]) 32768', r'\1 32768', actual)
- # Remove summary line (changed recently)
- actual = re.sub(r'Total number.*', '', actual)
- actual = re.sub(r'Displayed.*', '', actual)
- actual = actual.rstrip()
- # Fix table version (ignore it)
- actual = re.sub(r'(BGP table version is )[0-9]+', r'\1XXX', actual)
-
- # Fix newlines (make them all the same)
- actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
-
- # Generate Diff
- diff = topotest.get_textdiff(actual, expected,
- title1="actual BGP routing table",
- title2="expected BGP routing table")
-
- if diff:
- sys.stderr.write('r%s failed Routing Table Check for view %s:\n%s\n'
- % (i, view, diff))
- failures += 1
- else:
- print("r%s ok" % i)
-
- assert failures == 0, "Routing Table verification failed for router r%s, view %s:\n%s" % (i, view, diff)
+ success = 0
+ # This glob pattern should work as long as number of views < 10
+ for refTableFile in (glob.glob(
+ '%s/r%s/show_ip_bgp_view_%s*.ref' % (thisDir, i, view))):
+
+ if os.path.isfile(refTableFile):
+ # Read expected result from file
+ expected = open(refTableFile).read().rstrip()
+ # Fix newlines (make them all the same)
+ expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
+
+ # Actual output from router
+ actual = net['r%s' % i].cmd('vtysh -c "show ip bgp view %s" 2> /dev/null' % view).rstrip()
+
+ # Fix inconsitent spaces between 0.99.24 and newer versions of Quagga...
+ actual = re.sub('0 0', '0 0', actual)
+ actual = re.sub(r'([0-9]) 32768', r'\1 32768', actual)
+ # Remove summary line (changed recently)
+ actual = re.sub(r'Total number.*', '', actual)
+ actual = re.sub(r'Displayed.*', '', actual)
+ actual = actual.rstrip()
+ # Fix table version (ignore it)
+ actual = re.sub(r'(BGP table version is )[0-9]+', r'\1XXX', actual)
+
+ # Fix newlines (make them all the same)
+ actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
+
+ # Generate Diff
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual BGP routing table",
+ title2="expected BGP routing table")
+
+ if diff:
+ diffresult[refTableFile] = diff
+ else:
+ success = 1
+ print("template %s matched: r%s ok" % (refTableFile, i))
+ break;
+
+ if not success:
+ resultstr = 'No template matched.\n'
+ for f in diffresult.iterkeys():
+ resultstr += (
+ 'template %s: r%s failed Routing Table Check for view %s:\n%s\n'
+ % (f, i, view, diffresult[f]))
+ raise AssertionError(
+ "Routing Table verification failed for router r%s, view %s:\n%s" % (i, view, resultstr))
+
# Make sure that all daemons are running
for i in range(1, 2):