Tests: src.ctf.lttng-live: split metadata sections
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 14 Jul 2020 23:01:22 +0000 (19:01 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 24 Feb 2022 23:23:50 +0000 (18:23 -0500)
commit78169723129e666342d1dd5bc6194f80d70fe862
treec5ab588ece72cf4eb36a26f6f6b1648e953c0620
parentc5ce3927e9c05390d39ba099baa130be9927341f
Tests: src.ctf.lttng-live: split metadata sections

Background
==========
This commit adds a test case to emulate when a live session is cleared
by the user and the metadata is sent in two different batches.

Here is the scenario this new test case is testing:
  1. Live session is running and generating events,
  2. User clears the session,
  3. Relay empties its metadata stream (Relay is aware that metadata
    is available but has not received it from the consumer since the
    clear),
  4. Babeltrace requests for newly available metadata from the Relay,
  5. Relay sends a zero-sized metadata buffer and status
  `LTTNG_VIEWER_METADATA_OK`,
  6. Babeltrace interpret this as a retry,
  7. Relay receives new (and old) metadata from consumer,
  8. Babeltrace requests for newly available metadata again,
  9. Relay replies with the new metadata section.

This key steps here are 6 to 10 where the relay sends an empty metadata
buffer to signify to the viewer to try again hoping that next time it
will have received the metadata.

Approach
========
To emulate this scenario, this commit adds the concept of metadata
sections to the `lttng_live_server.py` script. A new optional
"metadata-sections" field in the JSON trace description. This list
contains sections described by a JSON object containing the line at
which the metadata section starts and a timestamp at which it must be
sent to the viewer. Empty section are represented by a "empty" string.
    e.g.
        "metadata-sections": [
          {
            "line": 1,
            "timestamp": 1294581
          },
          "empty",
          {
            "line": 111,
            "timestamp": 1295918
          },
        ]

The metadata stream object acts as a queue and is systematically (on
LTTNG_VIEWER_GET_NEXT_INDEX) checked against the current timestamp to
see if the next metadata section needs to be activated.

If the "metadata-sections" field is absent, the uses the metadata file
as a single section, as usual.

Notes
=====
You will notice that the all .expect files were modified to increment
the stream ID of all data streams. This is because we now create the
`_LttngLiveViewerSessionMetadataStreamState` object before (instead of
after) the `_LttngLiveViewerSessionDataStreamState` objects. This is
done because we need a reference from any data stream to its metadata
stream. The metadata stream id is pass to the
`_LttngLiveViewerSessionDataStreamState` __init__() method.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I45c7e12cc596033bce376e45393ff6970670f1da
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3775
Tested-by: jenkins <jenkins@lttng.org>
tests/data/ctf-traces/live/split_metadata/channel0_0 [new file with mode: 0644]
tests/data/ctf-traces/live/split_metadata/index/channel0_0.idx [new file with mode: 0644]
tests/data/ctf-traces/live/split_metadata/metadata [new file with mode: 0644]
tests/data/plugins/src.ctf.lttng-live/cli-base.expect
tests/data/plugins/src.ctf.lttng-live/cli-multi-domains.expect
tests/data/plugins/src.ctf.lttng-live/inactivity_discarded_packet.expect
tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py
tests/data/plugins/src.ctf.lttng-live/split_metadata.expect [new file with mode: 0644]
tests/data/plugins/src.ctf.lttng-live/split_metadata.json [new file with mode: 0644]
tests/plugins/src.ctf.lttng-live/test_live
This page took 0.025646 seconds and 4 git commands to generate.