tests: move classes around in lttng_live_server.py
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 14 Sep 2023 18:46:56 +0000 (14:46 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 21 Sep 2023 17:29:44 +0000 (13:29 -0400)
In preparation for an upcoming patch, which fixes typing issues in
lttng_live_server.py, move some types around to avoid forward-references
when possible.

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

index cd659f49d1b9ea641e378570b5495e5be6167adc..102f7ee85169b47806c3bcca55aeb45c17442e3e 100644 (file)
@@ -21,6 +21,80 @@ class UnexpectedInput(RuntimeError):
     pass
 
 
+# An entry within the index of an LTTng data stream.
+class _LttngDataStreamIndexEntry:
+    def __init__(
+        self,
+        offset_bytes,
+        total_size_bits,
+        content_size_bits,
+        timestamp_begin,
+        timestamp_end,
+        events_discarded,
+        stream_class_id,
+    ):
+        self._offset_bytes = offset_bytes
+        self._total_size_bits = total_size_bits
+        self._content_size_bits = content_size_bits
+        self._timestamp_begin = timestamp_begin
+        self._timestamp_end = timestamp_end
+        self._events_discarded = events_discarded
+        self._stream_class_id = stream_class_id
+
+    @property
+    def offset_bytes(self):
+        return self._offset_bytes
+
+    @property
+    def total_size_bits(self):
+        return self._total_size_bits
+
+    @property
+    def total_size_bytes(self):
+        return self._total_size_bits // 8
+
+    @property
+    def content_size_bits(self):
+        return self._content_size_bits
+
+    @property
+    def content_size_bytes(self):
+        return self._content_size_bits // 8
+
+    @property
+    def timestamp_begin(self):
+        return self._timestamp_begin
+
+    @property
+    def timestamp_end(self):
+        return self._timestamp_end
+
+    @property
+    def events_discarded(self):
+        return self._events_discarded
+
+    @property
+    def stream_class_id(self):
+        return self._stream_class_id
+
+
+# An entry within the index of an LTTng data stream. While a stream beacon entry
+# is conceptually unrelated to an index, it is sent as a reply to a
+# LttngLiveViewerGetNextDataStreamIndexEntryCommand
+class _LttngDataStreamBeaconEntry:
+    def __init__(self, stream_class_id, timestamp):
+        self._stream_class_id = stream_class_id
+        self._timestamp = timestamp
+
+    @property
+    def timestamp(self):
+        return self._timestamp
+
+    @property
+    def stream_class_id(self):
+        return self._stream_class_id
+
+
 class _LttngLiveViewerCommand:
     def __init__(self, version):
         self._version = version
@@ -575,80 +649,6 @@ class _LttngLiveViewerProtocolCodec:
         return data
 
 
-# An entry within the index of an LTTng data stream.
-class _LttngDataStreamIndexEntry:
-    def __init__(
-        self,
-        offset_bytes,
-        total_size_bits,
-        content_size_bits,
-        timestamp_begin,
-        timestamp_end,
-        events_discarded,
-        stream_class_id,
-    ):
-        self._offset_bytes = offset_bytes
-        self._total_size_bits = total_size_bits
-        self._content_size_bits = content_size_bits
-        self._timestamp_begin = timestamp_begin
-        self._timestamp_end = timestamp_end
-        self._events_discarded = events_discarded
-        self._stream_class_id = stream_class_id
-
-    @property
-    def offset_bytes(self):
-        return self._offset_bytes
-
-    @property
-    def total_size_bits(self):
-        return self._total_size_bits
-
-    @property
-    def total_size_bytes(self):
-        return self._total_size_bits // 8
-
-    @property
-    def content_size_bits(self):
-        return self._content_size_bits
-
-    @property
-    def content_size_bytes(self):
-        return self._content_size_bits // 8
-
-    @property
-    def timestamp_begin(self):
-        return self._timestamp_begin
-
-    @property
-    def timestamp_end(self):
-        return self._timestamp_end
-
-    @property
-    def events_discarded(self):
-        return self._events_discarded
-
-    @property
-    def stream_class_id(self):
-        return self._stream_class_id
-
-
-# An entry within the index of an LTTng data stream. While a stream beacon entry
-# is conceptually unrelated to an index, it is sent as a reply to a
-# LttngLiveViewerGetNextDataStreamIndexEntryCommand
-class _LttngDataStreamBeaconEntry:
-    def __init__(self, stream_class_id, timestamp):
-        self._stream_class_id = stream_class_id
-        self._timestamp = timestamp
-
-    @property
-    def timestamp(self):
-        return self._timestamp
-
-    @property
-    def stream_class_id(self):
-        return self._stream_class_id
-
-
 def _get_entry_timestamp_begin(entry):
     if type(entry) is _LttngDataStreamBeaconEntry:
         return entry.timestamp
@@ -1119,6 +1119,39 @@ class _LttngLiveViewerSessionMetadataStreamState:
         return self._next_metadata_stream_section_timestamp
 
 
+# A tracing session descriptor.
+#
+# In the constructor, `traces` is a list of LTTng traces (`LttngTrace`
+# objects).
+class LttngTracingSessionDescriptor:
+    def __init__(
+        self, name, tracing_session_id, hostname, live_timer_freq, client_count, traces
+    ):
+        for trace in traces:
+            if name not in trace.path:
+                fmt = "Tracing session name must be part of every trace path (`{}` not found in `{}`)"
+                raise ValueError(fmt.format(name, trace.path))
+
+        self._traces = traces
+        stream_count = sum([len(t) + 1 for t in traces])
+        self._info = _LttngLiveViewerTracingSessionInfo(
+            tracing_session_id,
+            live_timer_freq,
+            client_count,
+            stream_count,
+            hostname,
+            name,
+        )
+
+    @property
+    def traces(self):
+        return self._traces
+
+    @property
+    def info(self):
+        return self._info
+
+
 # The state of a tracing session.
 class _LttngLiveViewerSessionTracingSessionState:
     def __init__(self, tc_descr, base_stream_id):
@@ -1622,39 +1655,6 @@ class LttngLiveServer:
         )
 
 
-# A tracing session descriptor.
-#
-# In the constructor, `traces` is a list of LTTng traces (`LttngTrace`
-# objects).
-class LttngTracingSessionDescriptor:
-    def __init__(
-        self, name, tracing_session_id, hostname, live_timer_freq, client_count, traces
-    ):
-        for trace in traces:
-            if name not in trace.path:
-                fmt = "Tracing session name must be part of every trace path (`{}` not found in `{}`)"
-                raise ValueError(fmt.format(name, trace.path))
-
-        self._traces = traces
-        stream_count = sum([len(t) + 1 for t in traces])
-        self._info = _LttngLiveViewerTracingSessionInfo(
-            tracing_session_id,
-            live_timer_freq,
-            client_count,
-            stream_count,
-            hostname,
-            name,
-        )
-
-    @property
-    def traces(self):
-        return self._traces
-
-    @property
-    def info(self):
-        return self._info
-
-
 def _session_descriptors_from_path(sessions_filename, trace_path_prefix):
     # File format is:
     #
This page took 0.027218 seconds and 4 git commands to generate.