summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Scalbert <louis.scalbert@6wind.com>2023-06-01 11:39:30 +0200
committerLouis Scalbert <louis.scalbert@6wind.com>2023-06-01 14:14:51 +0200
commitb24bad5632eae14192fe123963be85b2d2c15a5c (patch)
tree0455fbac23fa04ebf017ef4df98c371cd57e9b5d
parentMerge pull request #13450 from patrasar/mld_core (diff)
downloadfrr-b24bad5632eae14192fe123963be85b2d2c15a5c.tar.xz
frr-b24bad5632eae14192fe123963be85b2d2c15a5c.zip
tests: fix mpls table check in isis_sr_flex_algo_topo1
Some test steps result in removing some entries in the MPLS forwarding table. However, these steps pass before the entries are actually removed. Use the exact JSON comparison so that the removal of the entries is checked. Fixes: 1a61ef95b2 ("tests: add isis_sr_flex_algo_topo1 for flex-algo") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
-rwxr-xr-xtests/topotests/isis_sr_flex_algo_topo1/test_isis_sr_flex_algo_topo1.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/topotests/isis_sr_flex_algo_topo1/test_isis_sr_flex_algo_topo1.py b/tests/topotests/isis_sr_flex_algo_topo1/test_isis_sr_flex_algo_topo1.py
index 85600beb0..fbe179bd3 100755
--- a/tests/topotests/isis_sr_flex_algo_topo1/test_isis_sr_flex_algo_topo1.py
+++ b/tests/topotests/isis_sr_flex_algo_topo1/test_isis_sr_flex_algo_topo1.py
@@ -38,6 +38,7 @@ import sys
import pytest
import json
import tempfile
+from copy import deepcopy
from functools import partial
# Save the Current Working Directory to find configuration files.
@@ -130,6 +131,30 @@ def setup_testcase(msg):
return tgen
+def router_json_cmp_exact_filter(router, cmd, expected):
+ output = router.vtysh_cmd(cmd)
+ logger.info("{}: {}\n{}".format(router.name, cmd, output))
+
+ json_output = json.loads(output)
+ router_output = deepcopy(json_output)
+
+ # filter out dynamic data from "show mpls table"
+ for label, data in json_output.items():
+ if "1500" in label:
+ # filter out SR local labels
+ router_output.pop(label)
+ continue
+ nexthops = data.get("nexthops", [])
+ for i in range(len(nexthops)):
+ if "fe80::" in nexthops[i].get("nexthop"):
+ router_output.get(label).get("nexthops")[i].pop("nexthop")
+ elif "." in nexthops[i].get("nexthop"):
+ # IPv4, just checking the nexthop
+ router_output.get(label).get("nexthops")[i].pop("interface")
+
+ return topotest.json_cmp(router_output, expected, exact=True)
+
+
def router_compare_json_output(rname, command, reference):
"Compare router JSON output"
@@ -139,7 +164,9 @@ def router_compare_json_output(rname, command, reference):
expected = json.loads(reference)
# Run test function until we get an result. Wait at most 60 seconds.
- test_func = partial(topotest.router_json_cmp, tgen.gears[rname], command, expected)
+ test_func = partial(
+ router_json_cmp_exact_filter, tgen.gears[rname], command, expected
+ )
_, diff = topotest.run_and_expect(test_func, None, count=120, wait=0.5)
assertmsg = '"{}" JSON output mismatches the expected result'.format(rname)
assert diff is None, assertmsg