Skip to content

Commit

Permalink
Merge pull request #31 from opensourcerouting/eigrp-json-route-check
Browse files Browse the repository at this point in the history
eigrp-topo1: Change Route verification to use json

Fixes topotest failures based on changes in FRR PR 1063
  • Loading branch information
mwinter-osr authored Sep 13, 2017
2 parents 0aedd1a + 7630d45 commit efe1134
Show file tree
Hide file tree
Showing 7 changed files with 307 additions and 56 deletions.
94 changes: 94 additions & 0 deletions eigrp-topo1/r1/show_ip_route.json_ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"192.168.1.0/24":[
{
"prefix":"192.168.1.0/24",
"protocol":"eigrp",
"distance":0,
"metric":0,
"nexthops":[
{
"directlyConnected":true,
"interfaceName":"r1-eth0",
"active":true
}
]
},
{
"prefix":"192.168.1.0/24",
"protocol":"connected",
"selected":true,
"nexthops":[
{
"fib":true,
"directlyConnected":true,
"interfaceName":"r1-eth0",
"active":true
}
]
}
],
"192.168.3.0/24":[
{
"prefix":"192.168.3.0/24",
"protocol":"eigrp",
"selected":true,
"distance":0,
"metric":0,
"nexthops":[
{
"fib":true,
"ip":"193.1.1.2",
"afi":"ipv4",
"interfaceName":"r1-eth1",
"active":true
}
]
}
],
"193.1.1.0/26":[
{
"prefix":"193.1.1.0/26",
"protocol":"eigrp",
"distance":0,
"metric":0,
"nexthops":[
{
"directlyConnected":true,
"interfaceName":"r1-eth1",
"active":true
}
]
},
{
"prefix":"193.1.1.0/26",
"protocol":"connected",
"selected":true,
"nexthops":[
{
"fib":true,
"directlyConnected":true,
"interfaceName":"r1-eth1",
"active":true
}
]
}
],
"193.1.2.0/24":[
{
"prefix":"193.1.2.0/24",
"protocol":"eigrp",
"selected":true,
"distance":0,
"metric":0,
"nexthops":[
{
"fib":true,
"ip":"193.1.1.2",
"afi":"ipv4",
"interfaceName":"r1-eth1",
"active":true
}
]
}
]
}
11 changes: 0 additions & 11 deletions eigrp-topo1/r1/show_ip_route.ref

This file was deleted.

94 changes: 94 additions & 0 deletions eigrp-topo1/r2/show_ip_route.json_ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"192.168.1.0/24":[
{
"prefix":"192.168.1.0/24",
"protocol":"eigrp",
"selected":true,
"distance":0,
"metric":0,
"nexthops":[
{
"fib":true,
"ip":"193.1.1.1",
"afi":"ipv4",
"interfaceName":"r2-eth0",
"active":true
}
]
}
],
"192.168.3.0/24":[
{
"prefix":"192.168.3.0/24",
"protocol":"eigrp",
"selected":true,
"distance":0,
"metric":0,
"nexthops":[
{
"fib":true,
"ip":"193.1.2.2",
"afi":"ipv4",
"interfaceName":"r2-eth1",
"active":true
}
]
}
],
"193.1.1.0/26":[
{
"prefix":"193.1.1.0/26",
"protocol":"eigrp",
"distance":0,
"metric":0,
"nexthops":[
{
"directlyConnected":true,
"interfaceName":"r2-eth0",
"active":true
}
]
},
{
"prefix":"193.1.1.0/26",
"protocol":"connected",
"selected":true,
"nexthops":[
{
"fib":true,
"directlyConnected":true,
"interfaceName":"r2-eth0",
"active":true
}
]
}
],
"193.1.2.0/24":[
{
"prefix":"193.1.2.0/24",
"protocol":"eigrp",
"distance":0,
"metric":0,
"nexthops":[
{
"directlyConnected":true,
"interfaceName":"r2-eth1",
"active":true
}
]
},
{
"prefix":"193.1.2.0/24",
"protocol":"connected",
"selected":true,
"nexthops":[
{
"fib":true,
"directlyConnected":true,
"interfaceName":"r2-eth1",
"active":true
}
]
}
]
}
11 changes: 0 additions & 11 deletions eigrp-topo1/r2/show_ip_route.ref

This file was deleted.

112 changes: 112 additions & 0 deletions eigrp-topo1/r3/show_ip_route.json_ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"192.168.1.0/24":[
{
"prefix":"192.168.1.0/24",
"protocol":"eigrp",
"selected":true,
"distance":0,
"metric":0,
"nexthops":[
{
"fib":true,
"ip":"193.1.2.1",
"afi":"ipv4",
"interfaceName":"r3-eth1",
"active":true
}
]
}
],
"192.168.2.0/24":[
{
"prefix":"192.168.2.0/24",
"protocol":"static",
"selected":true,
"distance":1,
"metric":0,
"nexthops":[
{
"fib":true,
"ip":"192.168.3.10",
"afi":"ipv4",
"interfaceName":"r3-eth0",
"active":true
}
]
}
],
"192.168.3.0/24":[
{
"prefix":"192.168.3.0/24",
"protocol":"eigrp",
"distance":0,
"metric":0,
"nexthops":[
{
"directlyConnected":true,
"interfaceName":"r3-eth0",
"active":true
}
]
},
{
"prefix":"192.168.3.0/24",
"protocol":"connected",
"selected":true,
"nexthops":[
{
"fib":true,
"directlyConnected":true,
"interfaceName":"r3-eth0",
"active":true
}
]
}
],
"193.1.1.0/26":[
{
"prefix":"193.1.1.0/26",
"protocol":"eigrp",
"selected":true,
"distance":0,
"metric":0,
"nexthops":[
{
"fib":true,
"ip":"193.1.2.1",
"afi":"ipv4",
"interfaceName":"r3-eth1",
"active":true
}
]
}
],
"193.1.2.0/24":[
{
"prefix":"193.1.2.0/24",
"protocol":"eigrp",
"distance":0,
"metric":0,
"nexthops":[
{
"directlyConnected":true,
"interfaceName":"r3-eth1",
"active":true
}
]
},
{
"prefix":"193.1.2.0/24",
"protocol":"connected",
"selected":true,
"nexthops":[
{
"fib":true,
"directlyConnected":true,
"interfaceName":"r3-eth1",
"active":true
}
]
}
]
}
12 changes: 0 additions & 12 deletions eigrp-topo1/r3/show_ip_route.ref

This file was deleted.

29 changes: 7 additions & 22 deletions eigrp-topo1/test_eigrp_topo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import re
import sys
import pytest
import json

# Save the Current Working Directory to find configuration files.
CWD = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -166,6 +167,7 @@ def test_eigrp_routes():
assert failures == 0, 'SHOW IP EIGRP failed for router {}:\n{}'.format(router.name, diff)



def test_zebra_ipv4_routingTable():
"Test 'show ip route'"

Expand All @@ -174,32 +176,15 @@ def test_zebra_ipv4_routingTable():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)

# Verify OSPFv3 Routing Table
logger.info("Verifying Zebra IPv4 Routing Table")

failures = 0
router_list = tgen.routers().values()
for router in router_list:
refTableFile = '{}/{}/show_ip_route.ref'.format(CWD, router.name)

# Read expected result from file
expected = open(refTableFile).read().rstrip()

# Actual output from router
actual = router.vtysh_cmd('show ip route').rstrip()

# Generate Diff
diff = topotest.difflines(actual, expected,
title1="actual Zebra IPv4 routing table",
title2="expected Zebra IPv4 routing table")

# Empty string if it matches, otherwise diff contains unified diff
if diff:
failures += 1
else:
logger.info('{} ok'.format(router.name))
output = router.vtysh_cmd('show ip route json', isjson=True)
refTableFile = '{}/{}/show_ip_route.json_ref'.format(CWD, router.name)
expected = json.loads(open(refTableFile).read())

assert failures == 0, 'Zebra IPv4 Routing Table verification failed for router {}:\n{}'.format(router.name, diff)
assertmsg = 'Zebra IPv4 Routing Table verification failed for router {}'.format(router.name)
assert topotest.json_cmp(output, expected) is None, assertmsg


def test_shutdown_check_stderr():
Expand Down

0 comments on commit efe1134

Please sign in to comment.