From: Donald Sharp Date: Wed, 19 Mar 2025 19:20:31 +0000 (-0400) Subject: tests: Ensure that the daemon has connected to zebra X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=df0e10076f2c6b4b8e00b09592881a05d7f58ebf;p=matthieu%2Ffrr.git tests: Ensure that the daemon has connected to zebra On daemon startup, ensure that the daemon is there and connected to zebra. There are some exceptions, pathd is srte. pim6d and pimd are the same at the moment and finally smnptrapd. This should help the startup of using a unified config in the topotests. Signed-off-by: Donald Sharp --- diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index 07033698d0..79c93df987 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -2266,6 +2266,19 @@ class Router(Node): ) time.sleep(0.5) + def _check_connected_to_zebra(self, daemon): + # Drop the last 'd' from daemon name for checking connection + if daemon == "pathd": + daemon = "srte" + elif daemon == "pim6d": + daemon = "pim" + elif daemon == "snmptrapd": + return True + else: + daemon = daemon[:-1] + output = self.cmd("vtysh -c 'show zebra client summary'") + return daemon in output + # Start mgmtd first if "mgmtd" in daemons_list: start_daemon("mgmtd") @@ -2276,7 +2289,9 @@ class Router(Node): _check_daemons_running(check_daemon_files) # Start Zebra after mgmtd + zebra_started = False if "zebra" in daemons_list: + zebra_started = True start_daemon("zebra") while "zebra" in daemons_list: daemons_list.remove("zebra") @@ -2290,6 +2305,16 @@ class Router(Node): while "staticd" in daemons_list: daemons_list.remove("staticd") + if zebra_started: + ok, _ = run_and_expect( + lambda: _check_connected_to_zebra(self, daemon="staticd"), + True, + count=30, + wait=1, + ) + if not ok: + assert False, "staticd failed to connect to zebra" + if "snmpd" in daemons_list: # Give zerbra a chance to configure interface addresses that snmpd daemon # may then use. @@ -2317,6 +2342,16 @@ class Router(Node): else: start_daemon(daemon) + if zebra_started: + ok, _ = run_and_expect( + lambda: _check_connected_to_zebra(self, daemon=daemon), + True, + count=30, + wait=1, + ) + if not ok: + assert False, f"{daemon} failed to connect to zebra" + # Check if daemons are running. _check_daemons_running(check_daemon_files)