tests: remove isdir/isfile asserts from lttng_live_server.py
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 17 Oct 2023 18:51:39 +0000 (14:51 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 20 Oct 2023 23:29:14 +0000 (19:29 -0400)
When lttng_live_server.py receives a trace path that doesn't exist
(perhaps because the user forgot to pass a --trace-path-prefix), it
gives:

    Traceback (most recent call last):
      File "lttng_live_server.py", line 1969, in <module>
        trace_path_prefix,
      File "lttng_live_server.py", line 1892, in _session_descriptors_from_path
        traces.append(LttngTrace(path, metadata_sections, beacons))
      File "lttng_live_server.py", line 1044, in __init__
        assert os.path.isdir(trace_dir)
    AssertionError

This is not very helpful, it hides details about the nature of the
problem.  Remove the assert, and let the subsequent open fail, saying
why it failed.  After the patch, it becomes:

    Traceback (most recent call last):
      File "lttng_live_server.py", line 1968, in <module>
trace_path_prefix,
      File "lttng_live_server.py", line 1891, in _session_descriptors_from_path
traces.append(LttngTrace(path, metadata_sections, beacons))
      File "lttng_live_server.py", line 1045, in __init__
self._create_metadata_stream(trace_dir, metadata_sections)
      File "lttng_live_server.py", line 1099, in _create_metadata_stream
metadata_path, config_metadata_sections
      File "lttng_live_server.py", line 974, in _split_metadata_sections
with open(metadata_file_path, "r") as metadata_file:
    FileNotFoundError: [Errno 2] No such file or directory: 'live/split_metadata/metadata'

Remove an isfile assert for the same reason.

Change-Id: If4289515b2c27748dd90209049c623e02c940a03
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10899
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 032b0349848d9c8914d457b5fdb539ca8a4ec6cd..5e1e8e69ed839a9f9c0a9e1c572e6bc76f8f9e0a 100644 (file)
@@ -712,7 +712,6 @@ class _LttngDataStreamIndex(Sequence[_LttngIndexEntryT]):
 
     def _build(self):
         self._entries = []  # type: list[_LttngIndexEntryT]
-        assert os.path.isfile(self._path)
 
         with open(self._path, "rb") as f:
             # Read header first
@@ -1019,7 +1018,6 @@ class LttngTrace(Sequence[_LttngDataStream]):
         metadata_sections_json: Optional[tjson.ArrayVal],
         beacons_json: Optional[tjson.ObjVal],
     ):
-        assert os.path.isdir(trace_dir)
         self._path = trace_dir
         self._create_metadata_stream(trace_dir, metadata_sections_json)
         self._create_data_streams(trace_dir, beacons_json)
This page took 0.026802 seconds and 4 git commands to generate.