tests: make --port-filename optional in lttng_live_server.py
authorSimon Marchi <simon.marchi@efficios.com>
Sat, 23 Sep 2023 02:26:14 +0000 (22:26 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 20 Oct 2023 23:29:14 +0000 (19:29 -0400)
While port_filename is useful for automation, it isn't essential when
using lttng_live_server.py manually.  Make that argument non-required.

Also, print a message indicating the port used to listen, which is handy
for interactive use.

Change how lttng_live_server.py is invoked to redirect stdout to stderr,
hopefully avoiding messing up the tap output format.

Change-Id: Ie185ced440c51fb1bb8355553f7b4a7725a13542
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10896
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py
tests/plugins/src.ctf.lttng-live/test_live

index 098f46442e61dacb767508d514998e617bf8c1d5..078b31fc24394a4fdf2cd242c055b18ead20eccd 100644 (file)
@@ -1624,7 +1624,7 @@ class LttngLiveServer:
     def __init__(
         self,
         port: Optional[int],
-        port_filename: str,
+        port_filename: Optional[str],
         tracing_session_descriptors: Iterable[LttngTracingSessionDescriptor],
         max_query_data_response_size: Optional[int],
     ):
@@ -1664,7 +1664,11 @@ class LttngLiveServer:
         # Port 0: OS assigns an unused port
         serv_addr = ("localhost", port if port is not None else 0)
         self._sock.bind(serv_addr)
-        self._write_port_to_file(port_filename)
+
+        if port_filename is not None:
+            self._write_port_to_file(port_filename)
+
+        print("Listening on port {}".format(self._server_port))
 
         try:
             self._listen()
@@ -1900,7 +1904,6 @@ if __name__ == "__main__":
     parser.add_argument(
         "--port-filename",
         help="The final port file. This file is present when the server is ready to receive connection.",
-        required=True,
     )
     parser.add_argument(
         "--max-query-data-response-size",
@@ -1934,6 +1937,6 @@ if __name__ == "__main__":
     )
 
     port = args.port  # type: int | None
-    port_filename = args.port_filename  # type: str
+    port_filename = args.port_filename  # type: str | None
     max_query_data_response_size = args.max_query_data_response_size  # type: int | None
     LttngLiveServer(port, port_filename, sessions, max_query_data_response_size)
index f694d799e9a3697c0c4d2e8550d410e1805fc0c1..86e498a01a433d879b4a3ae2460752c36628dccb 100755 (executable)
@@ -58,7 +58,7 @@ lttng_live_server() {
        diag "$BT_TESTS_PYTHON_BIN $server_script --port-file $port_file --trace-path-prefix $trace_dir_native $server_args"
        echo "$server_args" | run_python xargs "$BT_TESTS_PYTHON_BIN" "$server_script" \
                --port-file "$port_file" \
-               --trace-path-prefix "$trace_dir_native" &
+               --trace-path-prefix "$trace_dir_native" 1>&2 &
 
        # write PID to file
        echo $! > "$pid_file"
This page took 0.025694 seconds and 4 git commands to generate.