Tests: src.ctf.lttng-live: stream creation while trace is inactive
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 16 Jan 2024 17:00:17 +0000 (12:00 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 26 Mar 2024 14:57:50 +0000 (10:57 -0400)
commitc362e0f6293f5f215e82ea670051219cba5aece7
tree91a1729596d62bc5d925feea8bf3f7eaaaf6f471
parent3c22c122c56f58b7055d913b3901e7e8f48dded7
Tests: src.ctf.lttng-live: stream creation while trace is inactive

Add a test case to exercise the case where streams are created in the
context of a live viewer session while all of its currently-known
streams are inactive.

A full description of the underlying problem is provided in the "Fix:
src.ctf.lttng-live: expect NEW_STREAM/METADATA for inactive streams"
change description.

In essence, when consuming an LTTng live session configured to use
per-PID buffers, a known bug caused Babeltrace to ignore new streams
from an application (A) if all existing streams (existing applications)
were inactive. This led to a user experience akin to a "hang" if they
were expecting events emited by 'A'.

The test replicates this issue by:
  1. Starting an initial trace (T1) with one data stream emitting events
     for a fixed duration, followed by live beacons (triggering inactivity
     messages) for the rest of the duration of the test.
  2. Introducing a second trace (T2) with one data stream while the first
     trace only provides live beacons.
  3. Ensuring messages of T1 and T2 are visible and suitably interleaved.

When running the test against without the fix, Babeltrace fails to
receive new streams when only live beacons are provided, due to an
unchecked 'NEW_STREAMS' flag.

Moreover, once T1 ends (after providing its last inactivity beacon),
the lttng-live component falls in its 'idle' state where it keeps asking
for new streams (see lttng-live.cpp:1573) until the session is torn down
by the server.

Since new streams are available, the server will provide new streams
in response to the first `LTTNG_VIEWER_GET_NEW_STREAMS` command.
However, the first index provided for T2's data stream occurs _before_
the last "live beacon" that was received on T1's behalf.

This causes an internal sanity check to fail with the following error:
  01-18 15:08:39.743 153627 153627 E PLUGIN/SRC.CTF.LTTNG-LIVE handle_late_message@plugins/ctf/lttng-live/lttng-live.cpp:1141 [lttng-live] Invalid live stream state: have a late message when no inactivity message was ever sent for that stream.

With the fix applied, the test succeeds in showing the two traces'
messages interleaved in the expected order.

Change-Id: If40161edfdbefee6189ef63041b0f967493f1db9
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11675
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
tests/data/ctf-traces/live/new-streams/first-trace.mctf [new file with mode: 0644]
tests/data/ctf-traces/live/new-streams/second-trace.mctf [new file with mode: 0644]
tests/data/plugins/src.ctf.lttng-live/new-streams.expect [new file with mode: 0644]
tests/data/plugins/src.ctf.lttng-live/new-streams.json [new file with mode: 0644]
tests/plugins/src.ctf.lttng-live/test-live.sh
This page took 0.026114 seconds and 4 git commands to generate.