From e4d08d5be792f0b9d8a83d890a4cbd13c67cbe68 Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Wed, 13 Dec 2017 19:56:30 -0200 Subject: [PATCH] isis-topo1: test ISIS route installation Check the 'show ip route json' output for installed ISIS routes. Signed-off-by: Rafael Zalamena --- tests/topotests/isis-topo1/r1/r1_route.json | 86 +++++++++ tests/topotests/isis-topo1/r2/r2_route.json | 86 +++++++++ tests/topotests/isis-topo1/r3/r3_route.json | 173 ++++++++++++++++++ tests/topotests/isis-topo1/r4/r4_route.json | 83 +++++++++ tests/topotests/isis-topo1/r5/r5_route.json | 154 ++++++++++++++++ tests/topotests/isis-topo1/test_isis_topo1.py | 18 ++ 6 files changed, 600 insertions(+) create mode 100644 tests/topotests/isis-topo1/r1/r1_route.json create mode 100644 tests/topotests/isis-topo1/r2/r2_route.json create mode 100644 tests/topotests/isis-topo1/r3/r3_route.json create mode 100644 tests/topotests/isis-topo1/r4/r4_route.json create mode 100644 tests/topotests/isis-topo1/r5/r5_route.json diff --git a/tests/topotests/isis-topo1/r1/r1_route.json b/tests/topotests/isis-topo1/r1/r1_route.json new file mode 100644 index 0000000000..6f5041e3c2 --- /dev/null +++ b/tests/topotests/isis-topo1/r1/r1_route.json @@ -0,0 +1,86 @@ +{ + "10.0.10.0/24": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 2, + "interfaceName": "r1-eth0", + "ip": "10.0.20.1" + } + ], + "prefix": "10.0.10.0/24", + "protocol": "isis", + "selected": true + } + ], + "10.0.20.0/24": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "afi": "ipv4", + "interfaceIndex": 2, + "interfaceName": "r1-eth0", + "ip": "10.0.20.1" + } + ], + "prefix": "10.0.20.0/24", + "protocol": "isis" + }, + { + "nexthops": [ + { + "active": true, + "directlyConnected": true, + "fib": true, + "interfaceIndex": 2, + "interfaceName": "r1-eth0" + } + ], + "prefix": "10.0.20.0/24", + "protocol": "connected", + "selected": true + } + ], + "10.254.0.1/32": [ + { + "nexthops": [ + { + "active": true, + "directlyConnected": true, + "fib": true, + "interfaceIndex": 1, + "interfaceName": "lo" + } + ], + "prefix": "10.254.0.1/32", + "protocol": "connected", + "selected": true + } + ], + "10.254.0.3/32": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 2, + "interfaceName": "r1-eth0", + "ip": "10.0.20.1" + } + ], + "prefix": "10.254.0.3/32", + "protocol": "isis", + "selected": true + } + ] +} diff --git a/tests/topotests/isis-topo1/r2/r2_route.json b/tests/topotests/isis-topo1/r2/r2_route.json new file mode 100644 index 0000000000..3b14f160c0 --- /dev/null +++ b/tests/topotests/isis-topo1/r2/r2_route.json @@ -0,0 +1,86 @@ +{ + "10.0.11.0/24": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 2, + "interfaceName": "r2-eth0", + "ip": "10.0.21.1" + } + ], + "prefix": "10.0.11.0/24", + "protocol": "isis", + "selected": true + } + ], + "10.0.21.0/24": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "afi": "ipv4", + "interfaceIndex": 2, + "interfaceName": "r2-eth0", + "ip": "10.0.21.1" + } + ], + "prefix": "10.0.21.0/24", + "protocol": "isis" + }, + { + "nexthops": [ + { + "active": true, + "directlyConnected": true, + "fib": true, + "interfaceIndex": 2, + "interfaceName": "r2-eth0" + } + ], + "prefix": "10.0.21.0/24", + "protocol": "connected", + "selected": true + } + ], + "10.254.0.2/32": [ + { + "nexthops": [ + { + "active": true, + "directlyConnected": true, + "fib": true, + "interfaceIndex": 1, + "interfaceName": "lo" + } + ], + "prefix": "10.254.0.2/32", + "protocol": "connected", + "selected": true + } + ], + "10.254.0.4/32": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 2, + "interfaceName": "r2-eth0", + "ip": "10.0.21.1" + } + ], + "prefix": "10.254.0.4/32", + "protocol": "isis", + "selected": true + } + ] +} diff --git a/tests/topotests/isis-topo1/r3/r3_route.json b/tests/topotests/isis-topo1/r3/r3_route.json new file mode 100644 index 0000000000..d688e63ba1 --- /dev/null +++ b/tests/topotests/isis-topo1/r3/r3_route.json @@ -0,0 +1,173 @@ +{ + "10.0.10.0/24": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "afi": "ipv4", + "interfaceIndex": 3, + "interfaceName": "r3-eth1", + "ip": "10.0.10.1" + } + ], + "prefix": "10.0.10.0/24", + "protocol": "isis" + }, + { + "nexthops": [ + { + "active": true, + "directlyConnected": true, + "fib": true, + "interfaceIndex": 3, + "interfaceName": "r3-eth1" + } + ], + "prefix": "10.0.10.0/24", + "protocol": "connected", + "selected": true + } + ], + "10.0.11.0/24": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 3, + "interfaceName": "r3-eth1", + "ip": "10.0.10.1" + } + ], + "prefix": "10.0.11.0/24", + "protocol": "isis", + "selected": true + } + ], + "10.0.20.0/24": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "afi": "ipv4", + "interfaceIndex": 2, + "interfaceName": "r3-eth0", + "ip": "10.0.20.2" + } + ], + "prefix": "10.0.20.0/24", + "protocol": "isis" + }, + { + "nexthops": [ + { + "active": true, + "directlyConnected": true, + "fib": true, + "interfaceIndex": 2, + "interfaceName": "r3-eth0" + } + ], + "prefix": "10.0.20.0/24", + "protocol": "connected", + "selected": true + } + ], + "10.0.21.0/24": [ + { + "distance": 115, + "metric": 20, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 3, + "interfaceName": "r3-eth1", + "ip": "10.0.10.1" + } + ], + "prefix": "10.0.21.0/24", + "protocol": "isis", + "selected": true + } + ], + "10.254.0.1/32": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 2, + "interfaceName": "r3-eth0", + "ip": "10.0.20.2" + } + ], + "prefix": "10.254.0.1/32", + "protocol": "isis", + "selected": true + } + ], + "10.254.0.3/32": [ + { + "nexthops": [ + { + "active": true, + "directlyConnected": true, + "fib": true, + "interfaceIndex": 1, + "interfaceName": "lo" + } + ], + "prefix": "10.254.0.3/32", + "protocol": "connected", + "selected": true + } + ], + "10.254.0.4/32": [ + { + "distance": 115, + "metric": 20, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 3, + "interfaceName": "r3-eth1", + "ip": "10.0.10.1" + } + ], + "prefix": "10.254.0.4/32", + "protocol": "isis", + "selected": true + } + ], + "10.254.0.5/32": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 3, + "interfaceName": "r3-eth1", + "ip": "10.0.10.1" + } + ], + "prefix": "10.254.0.5/32", + "protocol": "isis", + "selected": true + } + ] +} diff --git a/tests/topotests/isis-topo1/r4/r4_route.json b/tests/topotests/isis-topo1/r4/r4_route.json new file mode 100644 index 0000000000..282565a273 --- /dev/null +++ b/tests/topotests/isis-topo1/r4/r4_route.json @@ -0,0 +1,83 @@ +{ + "10.0.11.0/24": [ + { + "nexthops": [ + { + "active": true, + "directlyConnected": true, + "fib": true, + "interfaceIndex": 3, + "interfaceName": "r4-eth1" + } + ], + "prefix": "10.0.11.0/24", + "protocol": "connected", + "selected": true + } + ], + "10.0.21.0/24": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "afi": "ipv4", + "interfaceIndex": 2, + "interfaceName": "r4-eth0", + "ip": "10.0.21.2" + } + ], + "prefix": "10.0.21.0/24", + "protocol": "isis" + }, + { + "nexthops": [ + { + "active": true, + "directlyConnected": true, + "fib": true, + "interfaceIndex": 2, + "interfaceName": "r4-eth0" + } + ], + "prefix": "10.0.21.0/24", + "protocol": "connected", + "selected": true + } + ], + "10.254.0.2/32": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 2, + "interfaceName": "r4-eth0", + "ip": "10.0.21.2" + } + ], + "prefix": "10.254.0.2/32", + "protocol": "isis", + "selected": true + } + ], + "10.254.0.4/32": [ + { + "nexthops": [ + { + "active": true, + "directlyConnected": true, + "fib": true, + "interfaceIndex": 1, + "interfaceName": "lo" + } + ], + "prefix": "10.254.0.4/32", + "protocol": "connected", + "selected": true + } + ] +} diff --git a/tests/topotests/isis-topo1/r5/r5_route.json b/tests/topotests/isis-topo1/r5/r5_route.json new file mode 100644 index 0000000000..5bdde09f1b --- /dev/null +++ b/tests/topotests/isis-topo1/r5/r5_route.json @@ -0,0 +1,154 @@ +{ + "10.0.10.0/24": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "afi": "ipv4", + "interfaceIndex": 2, + "interfaceName": "r5-eth0", + "ip": "10.0.10.2" + } + ], + "prefix": "10.0.10.0/24", + "protocol": "isis" + }, + { + "nexthops": [ + { + "active": true, + "directlyConnected": true, + "fib": true, + "interfaceIndex": 2, + "interfaceName": "r5-eth0" + } + ], + "prefix": "10.0.10.0/24", + "protocol": "connected", + "selected": true + } + ], + "10.0.11.0/24": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "afi": "ipv4", + "interfaceIndex": 3, + "interfaceName": "r5-eth1", + "ip": "10.0.11.2" + } + ], + "prefix": "10.0.11.0/24", + "protocol": "isis" + }, + { + "nexthops": [ + { + "active": true, + "directlyConnected": true, + "fib": true, + "interfaceIndex": 3, + "interfaceName": "r5-eth1" + } + ], + "prefix": "10.0.11.0/24", + "protocol": "connected", + "selected": true + } + ], + "10.0.20.0/24": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 2, + "interfaceName": "r5-eth0", + "ip": "10.0.10.2" + } + ], + "prefix": "10.0.20.0/24", + "protocol": "isis", + "selected": true + } + ], + "10.0.21.0/24": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 3, + "interfaceName": "r5-eth1", + "ip": "10.0.11.2" + } + ], + "prefix": "10.0.21.0/24", + "protocol": "isis", + "selected": true + } + ], + "10.254.0.3/32": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 2, + "interfaceName": "r5-eth0", + "ip": "10.0.10.2" + } + ], + "prefix": "10.254.0.3/32", + "protocol": "isis", + "selected": true + } + ], + "10.254.0.4/32": [ + { + "distance": 115, + "metric": 10, + "nexthops": [ + { + "active": true, + "afi": "ipv4", + "fib": true, + "interfaceIndex": 3, + "interfaceName": "r5-eth1", + "ip": "10.0.11.2" + } + ], + "prefix": "10.254.0.4/32", + "protocol": "isis", + "selected": true + } + ], + "10.254.0.5/32": [ + { + "nexthops": [ + { + "active": true, + "directlyConnected": true, + "fib": true, + "interfaceIndex": 1, + "interfaceName": "lo" + } + ], + "prefix": "10.254.0.5/32", + "protocol": "connected", + "selected": true + } + ] +} diff --git a/tests/topotests/isis-topo1/test_isis_topo1.py b/tests/topotests/isis-topo1/test_isis_topo1.py index 1da2204225..1b03a8b26f 100644 --- a/tests/topotests/isis-topo1/test_isis_topo1.py +++ b/tests/topotests/isis-topo1/test_isis_topo1.py @@ -133,6 +133,24 @@ def test_isis_convergence(): assert topotest.json_cmp(actual, expected) is None, assertmsg +def test_isis_route_installation(): + "Check whether all expected routes are present" + tgen = get_topogen() + # Don't run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + logger.info('Checking routers for installed ISIS routes') + + # Check for routes in 'show ip route json' + for rname, router in tgen.routers().iteritems(): + filename = '{0}/{1}/{1}_route.json'.format(CWD, rname) + expected = json.loads(open(filename, 'r').read()) + actual = router.vtysh_cmd('show ip route json', isjson=True) + assertmsg = "Router '{}' routes mismatch".format(rname) + assert topotest.json_cmp(actual, expected) is None, assertmsg + + def test_memory_leak(): "Run the memory leak test and report results." tgen = get_topogen() -- 2.39.5