diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2021-09-13 08:32:54 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-13 08:32:54 -0400 |
| commit | 2fdfc842f81d1eab7fcb22a669b302c08d59e2b4 (patch) | |
| tree | 805c55ccda83ef5e82c0864af3a88088752e0f85 | |
| parent | 4731dc4518b4545a1a60c5ead28b460b960f17f0 (diff) | |
| parent | 1375385adf6bfd89d0bcffeec85596783addda0a (diff) | |
Merge pull request #9571 from LabNConsulting/chopps/impr-zeb-netlink
tests: increase wait and update test
| -rw-r--r-- | tests/topotests/lib/common_config.py | 1 | ||||
| -rw-r--r-- | tests/topotests/lib/topotest.py | 13 | ||||
| -rw-r--r-- | tests/topotests/zebra_netlink/r1/sharpd.conf | 0 | ||||
| -rw-r--r-- | tests/topotests/zebra_netlink/r1/v4_route.json | 2302 | ||||
| -rw-r--r-- | tests/topotests/zebra_netlink/test_zebra_netlink.py | 95 |
5 files changed, 64 insertions, 2347 deletions
diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py index 54020d2ff9..1bce3c6bb2 100644 --- a/tests/topotests/lib/common_config.py +++ b/tests/topotests/lib/common_config.py @@ -44,6 +44,7 @@ from lib.micronet import comm_error from lib.topogen import TopoRouter, get_topogen from lib.topolog import get_logger, logger from lib.topotest import frr_unicode, interface_set_status, version_cmp +from lib import topotest FRRCFG_FILE = "frr_json.conf" FRRCFG_BKUP_FILE = "frr_json_initial.conf" diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index 1b26ddc1b5..b98698185c 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -439,6 +439,19 @@ def run_and_expect_type(func, etype, count=20, wait=3, avalue=None): return (False, result) +def router_json_cmp_retry(router, cmd, data, exact=False, retry_timeout=10.0): + """ + Runs `cmd` that returns JSON data (normally the command ends with 'json') + and compare with `data` contents. Retry by default for 10 seconds + """ + + def test_func(): + return router_json_cmp(router, cmd, data, exact) + + ok, _ = run_and_expect(test_func, None, int(retry_timeout), 1) + return ok + + def int2dpid(dpid): "Converting Integer to DPID" diff --git a/tests/topotests/zebra_netlink/r1/sharpd.conf b/tests/topotests/zebra_netlink/r1/sharpd.conf deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/topotests/zebra_netlink/r1/sharpd.conf +++ /dev/null diff --git a/tests/topotests/zebra_netlink/r1/v4_route.json b/tests/topotests/zebra_netlink/r1/v4_route.json deleted file mode 100644 index 39041ebc95..0000000000 --- a/tests/topotests/zebra_netlink/r1/v4_route.json +++ /dev/null @@ -1,2302 +0,0 @@ -{ - "2.1.3.7\/32":[ - { - "prefix":"2.1.3.7\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.8\/32":[ - { - "prefix":"2.1.3.8\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.9\/32":[ - { - "prefix":"2.1.3.9\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.10\/32":[ - { - "prefix":"2.1.3.10\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.11\/32":[ - { - "prefix":"2.1.3.11\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.12\/32":[ - { - "prefix":"2.1.3.12\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.13\/32":[ - { - "prefix":"2.1.3.13\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.14\/32":[ - { - "prefix":"2.1.3.14\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.15\/32":[ - { - "prefix":"2.1.3.15\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.16\/32":[ - { - "prefix":"2.1.3.16\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.17\/32":[ - { - "prefix":"2.1.3.17\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.18\/32":[ - { - "prefix":"2.1.3.18\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.19\/32":[ - { - "prefix":"2.1.3.19\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.20\/32":[ - { - "prefix":"2.1.3.20\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.21\/32":[ - { - "prefix":"2.1.3.21\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.22\/32":[ - { - "prefix":"2.1.3.22\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.23\/32":[ - { - "prefix":"2.1.3.23\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.24\/32":[ - { - "prefix":"2.1.3.24\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.25\/32":[ - { - "prefix":"2.1.3.25\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.26\/32":[ - { - "prefix":"2.1.3.26\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.27\/32":[ - { - "prefix":"2.1.3.27\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.28\/32":[ - { - "prefix":"2.1.3.28\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.29\/32":[ - { - "prefix":"2.1.3.29\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.30\/32":[ - { - "prefix":"2.1.3.30\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.31\/32":[ - { - "prefix":"2.1.3.31\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.32\/32":[ - { - "prefix":"2.1.3.32\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.33\/32":[ - { - "prefix":"2.1.3.33\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.34\/32":[ - { - "prefix":"2.1.3.34\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.35\/32":[ - { - "prefix":"2.1.3.35\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.36\/32":[ - { - "prefix":"2.1.3.36\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.37\/32":[ - { - "prefix":"2.1.3.37\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.38\/32":[ - { - "prefix":"2.1.3.38\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.39\/32":[ - { - "prefix":"2.1.3.39\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.40\/32":[ - { - "prefix":"2.1.3.40\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.41\/32":[ - { - "prefix":"2.1.3.41\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.42\/32":[ - { - "prefix":"2.1.3.42\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.43\/32":[ - { - "prefix":"2.1.3.43\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.44\/32":[ - { - "prefix":"2.1.3.44\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.45\/32":[ - { - "prefix":"2.1.3.45\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.46\/32":[ - { - "prefix":"2.1.3.46\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.47\/32":[ - { - "prefix":"2.1.3.47\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.48\/32":[ - { - "prefix":"2.1.3.48\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.49\/32":[ - { - "prefix":"2.1.3.49\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.50\/32":[ - { - "prefix":"2.1.3.50\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.51\/32":[ - { - "prefix":"2.1.3.51\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.52\/32":[ - { - "prefix":"2.1.3.52\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.53\/32":[ - { - "prefix":"2.1.3.53\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.54\/32":[ - { - "prefix":"2.1.3.54\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.55\/32":[ - { - "prefix":"2.1.3.55\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.56\/32":[ - { - "prefix":"2.1.3.56\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.57\/32":[ - { - "prefix":"2.1.3.57\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.58\/32":[ - { - "prefix":"2.1.3.58\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.59\/32":[ - { - "prefix":"2.1.3.59\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.60\/32":[ - { - "prefix":"2.1.3.60\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.61\/32":[ - { - "prefix":"2.1.3.61\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.62\/32":[ - { - "prefix":"2.1.3.62\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.63\/32":[ - { - "prefix":"2.1.3.63\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.64\/32":[ - { - "prefix":"2.1.3.64\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.65\/32":[ - { - "prefix":"2.1.3.65\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.66\/32":[ - { - "prefix":"2.1.3.66\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.67\/32":[ - { - "prefix":"2.1.3.67\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.68\/32":[ - { - "prefix":"2.1.3.68\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.69\/32":[ - { - "prefix":"2.1.3.69\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.70\/32":[ - { - "prefix":"2.1.3.70\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.71\/32":[ - { - "prefix":"2.1.3.71\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.72\/32":[ - { - "prefix":"2.1.3.72\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.73\/32":[ - { - "prefix":"2.1.3.73\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.74\/32":[ - { - "prefix":"2.1.3.74\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.75\/32":[ - { - "prefix":"2.1.3.75\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.76\/32":[ - { - "prefix":"2.1.3.76\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.77\/32":[ - { - "prefix":"2.1.3.77\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.78\/32":[ - { - "prefix":"2.1.3.78\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.79\/32":[ - { - "prefix":"2.1.3.79\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.80\/32":[ - { - "prefix":"2.1.3.80\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.81\/32":[ - { - "prefix":"2.1.3.81\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.82\/32":[ - { - "prefix":"2.1.3.82\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.83\/32":[ - { - "prefix":"2.1.3.83\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.84\/32":[ - { - "prefix":"2.1.3.84\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.85\/32":[ - { - "prefix":"2.1.3.85\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.86\/32":[ - { - "prefix":"2.1.3.86\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.87\/32":[ - { - "prefix":"2.1.3.87\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.88\/32":[ - { - "prefix":"2.1.3.88\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.89\/32":[ - { - "prefix":"2.1.3.89\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.90\/32":[ - { - "prefix":"2.1.3.90\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.91\/32":[ - { - "prefix":"2.1.3.91\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.92\/32":[ - { - "prefix":"2.1.3.92\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.93\/32":[ - { - "prefix":"2.1.3.93\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.94\/32":[ - { - "prefix":"2.1.3.94\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.95\/32":[ - { - "prefix":"2.1.3.95\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.96\/32":[ - { - "prefix":"2.1.3.96\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.97\/32":[ - { - "prefix":"2.1.3.97\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.98\/32":[ - { - "prefix":"2.1.3.98\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.99\/32":[ - { - "prefix":"2.1.3.99\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.100\/32":[ - { - "prefix":"2.1.3.100\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.101\/32":[ - { - "prefix":"2.1.3.101\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.102\/32":[ - { - "prefix":"2.1.3.102\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.103\/32":[ - { - "prefix":"2.1.3.103\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.104\/32":[ - { - "prefix":"2.1.3.104\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.105\/32":[ - { - "prefix":"2.1.3.105\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ], - "2.1.3.106\/32":[ - { - "prefix":"2.1.3.106\/32", - "protocol":"sharp", - "selected":true, - "destSelected":true, - "distance":150, - "metric":0, - "installed":true, - "table":254, - "nexthops":[ - { - "flags":3, - "fib":true, - "ip":"192.168.1.1", - "afi":"ipv4", - "interfaceName":"r1-eth0", - "active":true, - "weight":1 - } - ] - } - ] -} diff --git a/tests/topotests/zebra_netlink/test_zebra_netlink.py b/tests/topotests/zebra_netlink/test_zebra_netlink.py index 05cc0ae4a1..ca90c5cb15 100644 --- a/tests/topotests/zebra_netlink/test_zebra_netlink.py +++ b/tests/topotests/zebra_netlink/test_zebra_netlink.py @@ -24,21 +24,15 @@ test_zebra_netlink.py: Test some basic interactions with kernel using Netlink """ - -import os -import sys -import pytest +# pylint: disable=C0413 +import ipaddress import json +import sys from functools import partial -# Save the Current Working Directory to find configuration files. -CWD = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(os.path.join(CWD, "../")) - -# pylint: disable=C0413 -# Import topogen and topotest helpers +import pytest from lib import topotest -from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.topogen import Topogen, TopoRouter from lib.topolog import logger @@ -52,62 +46,73 @@ pytestmark = [pytest.mark.sharpd] ##################################################### -def setup_module(mod): +@pytest.fixture(scope="module") +def tgen(request): "Sets up the pytest environment" topodef = {"s1": ("r1")} - tgen = Topogen(topodef, mod.__name__) + tgen = Topogen(topodef, request.module.__name__) tgen.start_topology() + # Initialize all routers. router_list = tgen.routers() for rname, router in router_list.items(): - router.load_config( - TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) - ) - - router.load_config( - TopoRouter.RD_SHARP, os.path.join(CWD, "{}/sharpd.conf".format(rname)) - ) + router.load_config(TopoRouter.RD_ZEBRA, "zebra.conf") + router.load_config(TopoRouter.RD_SHARP) - # Initialize all routers. tgen.start_router() + yield tgen + tgen.stop_topology() -def teardown_module(_mod): - "Teardown the pytest environment" - tgen = get_topogen() - - # This function tears down the whole topology. - tgen.stop_topology() +@pytest.fixture(autouse=True) +def skip_on_failure(tgen): + if tgen.routers_have_failure(): + pytest.skip("skipped because of previous test failure") -def test_zebra_netlink_batching(): +def test_zebra_netlink_batching(tgen): "Test the situation where dataplane fills netlink send buffer entirely." logger.info( "Test the situation where dataplane fills netlink send buffer entirely." ) - tgen = get_topogen() - if tgen.routers_have_failure(): - pytest.skip("skipped because of previous test failure") r1 = tgen.gears["r1"] # Reduce the size of the buffer to hit the limit. r1.vtysh_cmd("conf t\nzebra kernel netlink batch-tx-buf 256 256") - r1.vtysh_cmd("sharp install routes 2.1.3.7 nexthop 192.168.1.1 100") - json_file = "{}/r1/v4_route.json".format(CWD) - expected = json.loads(open(json_file).read()) - test_func = partial( - topotest.router_json_cmp, - r1, - "show ip route json", - expected, - ) - _, result = topotest.run_and_expect(test_func, None, count=2, wait=0.5) - assertmsg = '"r1" JSON output mismatches' - assert result is None, assertmsg - - r1.vtysh_cmd("sharp remove routes 2.1.3.7 100") + count = 100 + r1.vtysh_cmd("sharp install routes 2.1.3.7 nexthop 192.168.1.1 " + str(count)) + + # Generate expected results + entry = { + "protocol": "sharp", + "distance": 150, + "metric": 0, + "installed": True, + "table": 254, + "nexthops": [ + { + "fib": True, + "ip": "192.168.1.1", + "afi": "ipv4", + "interfaceName": "r1-eth0", + "active": True, + "weight": 1, + } + ], + } + + match = {} + base = int(ipaddress.ip_address(u"2.1.3.7")) + for i in range(base, base + count): + pfx = str(ipaddress.ip_network((i, 32))) + match[pfx] = [dict(entry, prefix=pfx)] + + ok = topotest.router_json_cmp_retry(r1, "show ip route json", match) + assert ok, '"r1" JSON output mismatches' + + r1.vtysh_cmd("sharp remove routes 2.1.3.7 " + str(count)) if __name__ == "__main__": |
