3 # Copyright (C) 2024 Kienan Stewart <kstewart@efficios.com>
4 # SPDX-License-Identifier: GPL-2.0-only
8 Test for https://review.lttng.org/c/lttng-tools/+/11819
10 A live client shouldn't hang around after a session with no data has
20 # Import in-tree test utils
21 test_utils_import_path
= pathlib
.Path(__file__
).absolute().parents
[3] / "utils"
22 sys
.path
.append(str(test_utils_import_path
))
27 tap
= lttngtest
.TapGenerator(1)
30 def test_live_hang(tap
, test_env
):
31 client
= lttngtest
.LTTngClient(test_env
, log
=tap
.diagnostic
)
34 output
= lttngtest
.NetworkSessionOutputLocation(
35 "net://localhost:{}:{}/".format(
36 test_env
.lttng_relayd_control_port
, test_env
.lttng_relayd_data_port
39 session
= client
.create_session(output
=output
, live
=True)
41 # lttng enable-event --userspace --all
42 channel
= session
.add_channel(lttngtest
.lttngctl
.TracingDomain
.User
)
43 channel
.add_recording_rule(lttngtest
.lttngctl
.UserTracepointEventRule())
46 test_app
= test_env
.launch_wait_trace_test_application(100)
50 ctf_live_cc
= bt2
.find_plugin("ctf").source_component_classes
["lttng-live"]
51 query_executor
= bt2
.QueryExecutor(
54 params
={"url": "net://localhost:{}".format(test_env
.lttng_relayd_live_port
)},
62 query_result
= query_executor
.query()
67 for live_session
in query_result
:
68 if live_session
["session-name"] == session
.name
:
78 "net://localhost:{}/host/{}/{}".format(
79 test_env
.lttng_relayd_live_port
, socket
.gethostname(), session
.name
81 "--params=session-not-found-action=end",
83 tap
.diagnostic("Running bt2: {}".format(bt2_args
))
84 bt2_proc
= subprocess
.Popen(bt2_args
)
86 # wait until one client is connected
90 query_result
= query_executor
.query()
94 for live_session
in query_result
:
96 live_session
["session-name"] == session
.name
97 and live_session
["client-count"] == 1
105 # assert live viewer has exited
110 except subprocess
.TimeoutExpired
as e
:
111 tap
.diagnostic("Timed out (5s) waiting for babeltrace2 to return")
113 stopped
and bt2_proc
.returncode
== 0, "BT2 live viewer exited successfully"
119 with lttngtest
.test_environment(
120 with_sessiond
=True, log
=tap
.diagnostic
, with_relayd
=True
122 test_live_hang(tap
, test_env
)
124 sys
.exit(0 if tap
.is_successful
else 1)