From b198ef8159e337c13c0d7685e512717fd55ac1c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 2 Jun 2020 11:11:14 -0400 Subject: [PATCH] Tests: src.ctf.lttng-live: add discarded packets inactivity test MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add a test to ensure that inactivity beacon sent during the period of a `Discarded packets` message does not violate the monotonicity guarantees of the graph. A new indexed trace is added to the test traces. It was generated by the following source: import bt2 bt2.register_plugin(__name__, "builder") class SourceIter(bt2._UserMessageIterator): def __init__(self, config, output_port): ec = output_port.user_data sc = ec.stream_class tc = sc.trace_class trace = tc() stream = trace.create_stream(sc) pkt1 = stream.create_packet() pkt8 = stream.create_packet() self._msgs = [ self._create_stream_beginning_message(stream), self._create_packet_beginning_message(pkt1, default_clock_snapshot=0), self._create_event_message(ec, pkt1, default_clock_snapshot=10), self._create_packet_end_message(pkt1, default_clock_snapshot=20), self._create_discarded_packets_message(stream, 7, 20, 121), self._create_packet_beginning_message(pkt8, default_clock_snapshot=121), self._create_event_message(ec, pkt8, default_clock_snapshot=133), self._create_packet_end_message(pkt8, default_clock_snapshot=140), self._create_stream_end_message(stream), ] def __next__(self): if len(self._msgs) > 0: return self._msgs.pop(0) else: raise StopIteration @bt2.plugin_component_class class Source(bt2._UserSourceComponent, message_iterator_class=SourceIter): def __init__(self, config, params, obj): tc = self._create_trace_class() cc = self._create_clock_class() sc = tc.create_stream_class( default_clock_class=cc, supports_packets=True, packets_have_beginning_default_clock_snapshot=True, packets_have_end_default_clock_snapshot=True, supports_discarded_packets=True, discarded_packets_have_default_clock_snapshots=True, ) ec = sc.create_event_class(name="my-event") self._add_output_port("some-name", ec) The index was generated manually. Signed-off-by: Jérémie Galarneau Change-Id: Iebb34b9cf003d94e4c0a4ee4a530f7d7957d8b0d Reviewed-on: https://review.lttng.org/c/babeltrace/+/3613 Tested-by: jenkins Reviewed-by: Philippe Proulx --- .../index/stream_0.idx | Bin 0 -> 160 bytes .../7_lost_between_2_with_index/metadata | 48 +++++++++++++ .../7_lost_between_2_with_index/stream_0 | Bin 0 -> 184 bytes .../inactivity_discarded_packet.expect | 67 ++++++++++++++++++ .../inactivity_discarded_packet.json | 17 +++++ tests/plugins/src.ctf.lttng-live/test_live | 43 ++++++++++- 6 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 tests/data/ctf-traces/packet_seq_num/7_lost_between_2_with_index/index/stream_0.idx create mode 100644 tests/data/ctf-traces/packet_seq_num/7_lost_between_2_with_index/metadata create mode 100644 tests/data/ctf-traces/packet_seq_num/7_lost_between_2_with_index/stream_0 create mode 100644 tests/data/plugins/src.ctf.lttng-live/inactivity_discarded_packet.expect create mode 100644 tests/data/plugins/src.ctf.lttng-live/inactivity_discarded_packet.json diff --git a/tests/data/ctf-traces/packet_seq_num/7_lost_between_2_with_index/index/stream_0.idx b/tests/data/ctf-traces/packet_seq_num/7_lost_between_2_with_index/index/stream_0.idx new file mode 100644 index 0000000000000000000000000000000000000000..e06d92fbcffaf2ff8b0193b7c328ba0dbfe32455 GIT binary patch literal 160 wcmX^3@yo|L34gBYS#yoR8o7g|T*`95Oo@(7*#GhyaX+NsGW3Xfzj;e~=8bE1`OOpfm@X I*{x7M0Dv| pkt seq:8 | + # 0 20 121 140 + # + # This test was introduced to cover the following bug: + # + # When reading this type of trace locally, the CTF source is expected + # to introduce a "Discarded packets" message between packets 0 and 8. + # The timestamps of this message are [pkt0.end_ts, pkt8.begin_ts]. + # + # In the context of a live source, the tracer could report an inactivity + # period during the interval of the "Discarded packets" message. + # Those messages eventually translate into a + # "Iterator inactivity" message with a timestamp set at the end of the + # inactivity period. + # + # If the tracer reports an inactivity period that ends at a point + # between pkt0 and pkt7 (resulting in an "Iterator inactivity" message), + # the live source could send a "Discarded packets" message that starts + # before the preceding "Iterator inactivity" message. This would break + # the monotonicity constraint of the graph. + local test_text="CLI attach and fetch from single-domains session - inactivity discarded packet" + local cli_args_template="-i lttng-live net://localhost:@PORT@/host/hostname/7_lost_between_2_with_index -c sink.text.details" + local sessions_file="$test_data_dir/inactivity_discarded_packet.json" + local server_args="--sessions-filename '$sessions_file'" + local expected_stdout="$test_data_dir/inactivity_discarded_packet.expect" + local expected_stderr + + # Empty file for stderr expected + expected_stderr="$(mktemp -t test_live_inactivity_discarded_packet_stderr_expected.XXXXXX)" + + run_test "$test_text" "$cli_args_template" "$server_args" "$expected_stdout" "$expected_stderr" + + rm -f "$expected_stderr" +} + +plan_tests 14 test_list_sessions test_base test_multi_domains test_rate_limited test_compare_to_ctf_fs +test_inactivity_discarded_packet -- 2.34.1