forked from Mirror/frr
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>
This commit is contained in:
parent
e7765b81ce
commit
a8d6faa986
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue