From 6d5f16a45ca2a3ef6158adbdd0093044aeb2f28f Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 12 Apr 2023 15:55:52 +0200 Subject: [PATCH] topotests: fix bgp lu explicit-null test The label value for the given prefix was ignored, as the compare function always returns ok. Do return the json compare output. Fixes: eee086e6d24b ("topotests: add topotest to check bgp lu explicit-null service") Signed-off-by: Philippe Guibert --- .../test_bgp_lu_explicitnull.py | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/topotests/bgp_lu_explicitnull/test_bgp_lu_explicitnull.py b/tests/topotests/bgp_lu_explicitnull/test_bgp_lu_explicitnull.py index d53ac68e84..0656e1ed41 100644 --- a/tests/topotests/bgp_lu_explicitnull/test_bgp_lu_explicitnull.py +++ b/tests/topotests/bgp_lu_explicitnull/test_bgp_lu_explicitnull.py @@ -115,11 +115,13 @@ def check_show_ip_label_prefix_found(router, ipversion, prefix, label): output = json.loads( router.vtysh_cmd("show {} route {} json".format(ipversion, prefix)) ) - expected = {prefix: [{"prefix": prefix, "nexthops": [{"fib": True, "labels": [label]}]}]} - ret = topotest.json_cmp(output, expected) - if ret is None: - return "not good" - return None + expected = { + prefix: [ + {"prefix": prefix, "nexthops": [{"fib": True, "labels": [int(label)]}]} + ] + } + return topotest.json_cmp(output, expected) + def test_converge_bgplu(): "Wait for protocol convergence" @@ -141,9 +143,7 @@ def test_converge_bgplu(): "0", ) success, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5) - assert ( - success - ), "r1, prefix 192.168.2.2/32 from r2 not present" + assert success, "r1, prefix 192.168.2.2/32 from r2 not present" # Check r2 gets prefix 192.168.2.1/32 test_func = functools.partial( @@ -154,9 +154,8 @@ def test_converge_bgplu(): "0", ) success, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5) - assert ( - success - ), "r2, prefix 192.168.2.1/32 from r1 not present" + assert success, "r2, prefix 192.168.2.1/32 from r1 not present" + def test_traffic_connectivity(): "Wait for protocol convergence" @@ -168,7 +167,9 @@ def test_traffic_connectivity(): def _check_ping(name, dest_addr, src_addr): tgen = get_topogen() - output = tgen.gears[name].run("ping {} -c 1 -w 1 -I {}".format(dest_addr, src_addr)) + output = tgen.gears[name].run( + "ping {} -c 1 -w 1 -I {}".format(dest_addr, src_addr) + ) logger.info(output) if " 0% packet loss" not in output: return True @@ -180,6 +181,7 @@ def test_traffic_connectivity(): success, result = topotest.run_and_expect(func, None, count=10, wait=0.5) assert result is None, "r1, ping to 192.168.2.2 from 192.168.2.1 fails" + def test_memory_leak(): "Run the memory leak test and report results." tgen = get_topogen() -- 2.39.5