diff options
author | Louis Scalbert <louis.scalbert@6wind.com> | 2023-02-08 12:05:15 +0100 |
---|---|---|
committer | Louis Scalbert <louis.scalbert@6wind.com> | 2023-02-08 12:05:15 +0100 |
commit | a8d6faa9864c78f8570c8ac89c78d3095c43532d (patch) | |
tree | 11b7b7347762ae74e51271eb2c604511067e3fb2 | |
parent | Merge pull request #12761 from anlancs/fix/bgpd-crash-evpn-vni-both-rts (diff) | |
download | frr-a8d6faa9864c78f8570c8ac89c78d3095c43532d.tar.xz frr-a8d6faa9864c78f8570c8ac89c78d3095c43532d.zip |
tests: do not use exclude grep
Filter out keys in JSON output with "grep -v" does not work when JSON
does not use the pretty format.
Use native python code to filter out keys.
Fixes: 6c13bd5744 ("topotests: fix bgp_vpnv4_noretain")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
-rw-r--r-- | tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py b/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py index ed5cc3faf..d3b9b75ef 100644 --- a/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py +++ b/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py @@ -134,12 +134,21 @@ def teardown_module(_mod): def router_json_cmp_exact_filter(router, cmd, expected): - # filter out tableVersion, version and nhVrfID - output = router.cmd('vtysh -c "{}" | grep -v ersion | grep -v nhVrfId'.format(cmd)) + output = router.vtysh_cmd(cmd) logger.info("{}: {}\n{}".format(router.name, cmd, output)) json_output = json.loads(output) + # filter out tableVersion, version and nhVrfID + json_output.pop("tableVersion") + for rd, data in json_output["routes"]["routeDistinguishers"].items(): + for prefix, attrs in data.items(): + for attr in attrs: + if "nhVrfId" in attr: + attr.pop("nhVrfId") + if "version" in attr: + attr.pop("version") + return topotest.json_cmp(json_output, expected, exact=True) |