--- /dev/null
+{
+ "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
+ }
+ ]
+ }
+ ]
+}
+++ /dev/null
-Codes: K - kernel route, C - connected, S - static, R - RIP,
- O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP,
- T - Table, v - VNC, V - VNC-Direct, A - Babel,
- > - selected route, * - FIB route
-
-E 192.168.1.0/24 [0/0] is directly connected, r1-eth0
-C>* 192.168.1.0/24 is directly connected, r1-eth0
-E>* 192.168.3.0/24 [0/0] via 193.1.1.2, r1-eth1
-E 193.1.1.0/26 [0/0] is directly connected, r1-eth1
-C>* 193.1.1.0/26 is directly connected, r1-eth1
-E>* 193.1.2.0/24 [0/0] via 193.1.1.2, r1-eth1
--- /dev/null
+{
+ "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
+ }
+ ]
+ }
+ ]
+}
+++ /dev/null
-Codes: K - kernel route, C - connected, S - static, R - RIP,
- O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP,
- T - Table, v - VNC, V - VNC-Direct, A - Babel,
- > - selected route, * - FIB route
-
-E>* 192.168.1.0/24 [0/0] via 193.1.1.1, r2-eth0
-E>* 192.168.3.0/24 [0/0] via 193.1.2.2, r2-eth1
-E 193.1.1.0/26 [0/0] is directly connected, r2-eth0
-C>* 193.1.1.0/26 is directly connected, r2-eth0
-E 193.1.2.0/24 [0/0] is directly connected, r2-eth1
-C>* 193.1.2.0/24 is directly connected, r2-eth1
--- /dev/null
+{
+ "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
+ }
+ ]
+ }
+ ]
+}
+++ /dev/null
-Codes: K - kernel route, C - connected, S - static, R - RIP,
- O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP,
- T - Table, v - VNC, V - VNC-Direct, A - Babel,
- > - selected route, * - FIB route
-
-E>* 192.168.1.0/24 [0/0] via 193.1.2.1, r3-eth1
-S>* 192.168.2.0/24 [1/0] via 192.168.3.10, r3-eth0
-E 192.168.3.0/24 [0/0] is directly connected, r3-eth0
-C>* 192.168.3.0/24 is directly connected, r3-eth0
-E>* 193.1.1.0/26 [0/0] via 193.1.2.1, r3-eth1
-E 193.1.2.0/24 [0/0] is directly connected, r3-eth1
-C>* 193.1.2.0/24 is directly connected, r3-eth1
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__))
assert failures == 0, 'SHOW IP EIGRP failed for router {}:\n{}'.format(router.name, diff)
+# def test_zebra_ipv4_routingTable():
+# "Test 'show ip route'"
+
+# tgen = get_topogen()
+# # Don't run this test if we have any failure.
+# if tgen.routers_have_failure():
+# pytest.skip(tgen.errors)
+
+# # Verify OSPFv2 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))
+
+# assert failures == 0, 'Zebra IPv4 Routing Table verification failed for router {}:\n{}'.format(router.name, diff)
+
+
def test_zebra_ipv4_routingTable():
"Test 'show ip route'"
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)
+ 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())
- # Read expected result from file
- expected = open(refTableFile).read().rstrip()
-
- # Actual output from router
- actual = router.vtysh_cmd('show ip route').rstrip()
+ # diff = topotest.json_cmp(output, expected)
- # Generate Diff
- diff = topotest.difflines(actual, expected,
- title1="actual Zebra IPv4 routing table",
- title2="expected Zebra IPv4 routing table")
+ assertmsg = 'Zebra IPv4 Routing Table verification failed for router {}'.format(router.name)
+ assert topotest.json_cmp(output, expected) is None, assertmsg
- # Empty string if it matches, otherwise diff contains unified diff
- if diff:
- failures += 1
- else:
- logger.info('{} ok'.format(router.name))
+ # # Empty string if it matches, otherwise diff contains unified diff
+ # if diff:
+ # logger.info('{} NOT ok'.format(router.name))
+ # print("diff = %s" % str(diff))
+ # failures += 1
+ # else:
+ # logger.info('{} ok'.format(router.name))
- assert failures == 0, 'Zebra IPv4 Routing Table verification failed for router {}:\n{}'.format(router.name, diff)
+ # assert failures == 0, 'Zebra IPv4 Routing Table verification failed for router {}:\n{}'.format(router.name, diff)
def test_shutdown_check_stderr():