Tests: Add _LiveViewer.is_connected()
authorKienan Stewart <kstewart@efficios.com>
Thu, 10 Oct 2024 18:42:25 +0000 (18:42 +0000)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 24 Oct 2024 18:06:16 +0000 (14:06 -0400)
Change-Id: I3adf51ceea08d62e3d23598b57460427cf5561ea
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/utils/lttngtest/environment.py

index fe37cfa7c19f8ac97eecb901985370a7c66c1b0e..65d74a41dbfaff2f464b7bfa463d37a54a7bef89 100644 (file)
@@ -151,7 +151,7 @@ class _LiveViewer:
                 else:
                     break
 
-    def wait_until_connected(self, timeout=0):
+    def is_connected(self):
         ctf_live_cc = bt2.find_plugin("ctf").source_component_classes["lttng-live"]
         self._environment._log(
             "Checking for connected clients at 'net://localhost:{}'".format(
@@ -167,6 +167,21 @@ class _LiveViewer:
                 )
             },
         )
+
+        for live_session in query_executor.query():
+            if (
+                live_session["session-name"] == self._session
+                and live_session["client-count"] >= 1
+            ):
+                self._environment._log(
+                    "Session '{}' has {} connected clients".format(
+                        live_session["session-name"], live_session["client-count"]
+                    )
+                )
+                return True
+        return False
+
+    def wait_until_connected(self, timeout=0):
         connected = False
         started = time.time()
         while not connected:
@@ -177,22 +192,11 @@ class _LiveViewer:
                             self._session, time.time() - started
                         )
                     )
-                query_result = query_executor.query()
+
+                connected = self.is_connected()
             except bt2._Error:
                 time.sleep(0.01)
                 continue
-            for live_session in query_result:
-                if (
-                    live_session["session-name"] == self._session
-                    and live_session["client-count"] >= 1
-                ):
-                    connected = True
-                    self._environment._log(
-                        "Session '{}' has {} connected clients".format(
-                            live_session["session-name"], live_session["client-count"]
-                        )
-                    )
-                    break
         return connected
 
     def wait(self):
This page took 0.026374 seconds and 4 git commands to generate.