tests: fix all basic type check issues of lttng_live_server.py
authorSimon Marchi <simon.marchi@efficios.com>
Sat, 16 Sep 2023 01:44:44 +0000 (21:44 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 21 Sep 2023 17:29:44 +0000 (13:29 -0400)
Do the necessary changes such that this comment passes cleanly:

    $ PYTHONPATH=/home/smarchi/src/babeltrace/tests/utils/python pyright tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py

Pyright pointed out that field _trace_session_state didn't exist, in:

    @property
    def trace_session_state(self):
        return self._trace_session_state

The actual field name is _ts_state.  However, it shows that this
property is never used, so remove it.

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

index 102f7ee85169b47806c3bcca55aeb45c17442e3e..9687929418490c87514e0f71b0028d0c1555f5ba 100644 (file)
@@ -761,6 +761,11 @@ class _LttngDataStream:
         self._path = path
         filename = os.path.basename(path)
         match = re.match(r"(.*)_\d+", filename)
+        if not match:
+            raise RuntimeError(
+                "Unexpected data stream file name pattern: {}".format(filename)
+            )
+
         self._channel_name = match.group(1)
         trace_dir = os.path.dirname(path)
         index_path = os.path.join(trace_dir, "index", filename + ".idx")
@@ -854,6 +859,12 @@ def _parse_metadata_sections_config(config_sections):
             line = config_section.get("line")
             ts = config_section.get("timestamp")
 
+            if type(line) is not int:
+                raise RuntimeError("`line` is not an integer")
+
+            if type(ts) is not int:
+                raise RuntimeError("`timestamp` is not an integer")
+
             # Sections' timestamps and lines must both be increasing.
             assert ts > last_timestamp
             last_timestamp = ts
@@ -1076,10 +1087,6 @@ class _LttngLiveViewerSessionMetadataStreamState:
             )
         )
 
-    @property
-    def trace_session_state(self):
-        return self._trace_session_state
-
     @property
     def info(self):
         return self._info
@@ -1435,6 +1442,7 @@ class _LttngLiveViewerSession:
         metadata_stream_state.is_sent = True
         status = _LttngLiveViewerGetMetadataStreamDataContentReply.Status.OK
         metadata_section = metadata_stream_state.cur_section
+        assert metadata_section is not None
 
         # If we are sending an empty section, ready the next one right away.
         if len(metadata_section.data) == 0:
This page took 0.025547 seconds and 4 git commands to generate.