]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: Ensure that the daemon has connected to zebra
authorDonald Sharp <sharpd@nvidia.com>
Wed, 19 Mar 2025 19:20:31 +0000 (15:20 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 19 Mar 2025 19:20:31 +0000 (15:20 -0400)
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 <sharpd@nvidia.com>
tests/topotests/lib/topotest.py

index 07033698d0ece92e8406d75ee77d6ffa81acd809..79c93df98737c00d500115ea8cfda92b7c52fa63 100644 (file)
@@ -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)