Files
scylladb/test/pylib/cpp/util.py
Andrei Chekun 38310975c5 test.py: add the possibility to create a test alike object
resource_gather.py needs test.py test object to work. It needs some information about the test to be able to write down this information to the DB with metrics. When running with pytest, there's no such test object, that's why adding make_test_object to mimic the test.py's test object.
Switching the getting the mode for constructing path to chgroup to test
instead of suite. They are the same, but this helps to have emulate less
in make_test_object method.
2025-05-21 15:34:34 +02:00

28 lines
763 B
Python

#
# Copyright (C) 2025-present ScyllaDB
#
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
#
from pathlib import Path
from types import SimpleNamespace
def make_test_object(test_name: str, suite: str, run_id: int, mode: str = 'no_mode', log_dir: Path = None) -> SimpleNamespace:
"""
Returns object that used in resource gathering.
It needed to not change the logic of writing metrics to DB that used in test types from test.py.
"""
test = SimpleNamespace()
test.time_end = 0
test.time_start = 0
test.id = run_id
test.mode = mode
test.success = False
test.shortname = test_name
test.suite = SimpleNamespace()
test.suite.log_dir = log_dir / mode
test.suite.name = suite
return test