summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2021-10-28 15:51:46 -0400
committerDonald Sharp <sharpd@nvidia.com>2021-10-28 15:51:46 -0400
commit6b60e7b81ddb5e1a211ced15d9f6f6c4061d8ed5 (patch)
tree86a95976e9d739f072b332231b529c0eeb593afa
parentfd4bd21eeef612234c6000f9ff87e763969d2479 (diff)
tests: Fix `check_ping` function in test_bgp_srv6l3vpn_to_bgp_vrf.py
The check_ping function `_check` function was asserting and being passed to the topotests.run_and_expect() functionality causing it to not run the full range of pings if one failed the test. So effectively it was properly detecting pass / failure but only allowing for 1 iteration if it was going to fail. Modify the code to not assert and act like all the other run_and_expect functionality. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
-rwxr-xr-xtests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py
index e0cf8c88e6..ffdcd08f80 100755
--- a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py
+++ b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py
@@ -152,13 +152,14 @@ def check_ping(name, dest_addr, expect_connected):
tgen = get_topogen()
output = tgen.gears[name].run("ping6 {} -c 1 -w 1".format(dest_addr))
logger.info(output)
- assert match in output, "ping fail"
+ if match not in output:
+ return "ping fail"
match = "{} packet loss".format("0%" if expect_connected else "100%")
logger.info("[+] check {} {} {}".format(name, dest_addr, match))
tgen = get_topogen()
func = functools.partial(_check, name, dest_addr, match)
- success, result = topotest.run_and_expect(func, None, count=10, wait=0.5)
+ success, result = topotest.run_and_expect(func, None, count=10, wait=1)
assert result is None, "Failed"
@@ -171,7 +172,7 @@ def check_rib(name, cmd, expected_file):
expected = open_json_file("{}/{}".format(CWD, expected_file))
return topotest.json_cmp(output, expected)
- logger.info("[+] check {} \"{}\" {}".format(name, cmd, expected_file))
+ logger.info('[+] check {} "{}" {}'.format(name, cmd, expected_file))
tgen = get_topogen()
func = functools.partial(_check, name, cmd, expected_file)
success, result = topotest.run_and_expect(func, None, count=10, wait=0.5)