From 99b93e715c3746265d30b687f8f55731f2cf3146 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 19 Jan 2023 15:46:31 -0500 Subject: [PATCH] tests: zebra_rib remove a sleep The test was sometimes failing around the sleep(4) for waiting for the routes to be installed. Instead of blindly sleeping let's check to see that the routes are actually there in zebra and then continue on. Signed-off-by: Donald Sharp --- tests/topotests/zebra_rib/test_zebra_rib.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/topotests/zebra_rib/test_zebra_rib.py b/tests/topotests/zebra_rib/test_zebra_rib.py index b72691b71e..2334a198da 100644 --- a/tests/topotests/zebra_rib/test_zebra_rib.py +++ b/tests/topotests/zebra_rib/test_zebra_rib.py @@ -203,7 +203,16 @@ def test_route_map_usage(): r1.vtysh_cmd("conf\nip route 10.100.100.100/32 192.168.216.3") r1.vtysh_cmd("conf\nip route 10.100.100.101/32 10.0.0.44") r1.vtysh_cmd("sharp install route 10.0.0.0 nexthop 192.168.216.3 500") - sleep(4) + + def check_initial_routes_installed(router): + output = json.loads(router.vtysh_cmd("show ip route summ json")) + expected = { + "routes": [{"type": "static", "rib": 2}, {"type": "sharp", "rib": 500}] + } + return topotest.json_cmp(output, expected) + + test_func = partial(check_initial_routes_installed, r1) + success, result = topotest.run_and_expect(test_func, None, count=40, wait=1) static_rmapfile = "%s/r1/static_rmap.ref" % (thisDir) expected = open(static_rmapfile).read().rstrip() -- 2.39.5