]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: SRv6 SID Manager json cmp
authorCarmine Scarpitta <cscarpit@cisco.com>
Fri, 6 Sep 2024 21:23:37 +0000 (23:23 +0200)
committerCarmine Scarpitta <cscarpit@cisco.com>
Fri, 6 Sep 2024 21:23:37 +0000 (23:23 +0200)
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
tests/topotests/srv6_sid_manager/test_srv6_sid_manager.py

index 1e1a5e8b2087ad3a82172de773c916c58111b946..d0a8a301cf4714787d0861f1f2001f79fc10f025 100644 (file)
@@ -248,6 +248,22 @@ def teardown_module(mod):
     tgen.stop_topology()
 
 
+def router_compare_json_output(rname, command, reference):
+    "Compare router JSON output"
+
+    logger.info('Comparing router "%s" "%s" output', rname, command)
+
+    tgen = get_topogen()
+    filename = "{}/{}/{}".format(CWD, rname, reference)
+    expected = json.loads(open(filename).read())
+
+    # Run test function until we get an result. Wait at most 60 seconds.
+    test_func = functools.partial(topotest.router_json_cmp, 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
+
+
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]
     sys.exit(pytest.main(args))