From 71b875c932b2e3d3005a41309dfd258d00696ecf Mon Sep 17 00:00:00 2001 From: Andrei Chekun Date: Fri, 11 Jul 2025 12:29:07 +0200 Subject: [PATCH] test.py: add bypassing random seed to boost tests Bypassing argument to pytest->boost that was missing. Fixes: https://github.com/scylladb/scylladb/issues/24927 --- test.py | 2 ++ test/conftest.py | 2 ++ test/pylib/cpp/boost/boost_facade.py | 2 ++ test/pylib/cpp/facade.py | 1 + 4 files changed, 7 insertions(+) diff --git a/test.py b/test.py index 326549e079..7b5d98c905 100755 --- a/test.py +++ b/test.py @@ -327,6 +327,8 @@ def run_pytest(options: argparse.Namespace, run_id: int) -> tuple[int, list[Simp if options.pytest_arg: # If pytest_arg is provided, it should be a string with arguments to pass to pytest args.extend(shlex.split(options.pytest_arg)) + if options.random_seed: + args.append(f'--random-seed={options.random_seed}') if options.gather_metrics: args.append('--gather-metrics') if len(expression) > 1: diff --git a/test/conftest.py b/test/conftest.py index bacd14a640..8195e6888a 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -47,6 +47,8 @@ def pytest_addoption(parser: pytest.Parser) -> None: help="Specific byte limit for failure injection (random by default)") parser.addoption("--gather-metrics", action=BooleanOptionalAction, default=False, help='Switch on gathering cgroup metrics') + parser.addoption('--random-seed', action="store", + help="Random number generator seed to be used by boost tests") # Following option is to use with bare pytest command. # diff --git a/test/pylib/cpp/boost/boost_facade.py b/test/pylib/cpp/boost/boost_facade.py index c384389ff0..5c0fdddf62 100644 --- a/test/pylib/cpp/boost/boost_facade.py +++ b/test/pylib/cpp/boost/boost_facade.py @@ -117,6 +117,8 @@ class BoostTestFacade(CppTestFacade): args.append(f"--run_test={original_name}") # Tests are written in the way that everything after '--' passes to the test itself rather than to the test framework args.append('--') + if self.random_seed: + args.append(f'--random-seed={self.random_seed}') args.extend(test_args) test_passed, stdout_file_path, return_code = self.run_process(test_name, mode, file_name, args, env) diff --git a/test/pylib/cpp/facade.py b/test/pylib/cpp/facade.py index 59a5d4aadd..cf81bc157b 100644 --- a/test/pylib/cpp/facade.py +++ b/test/pylib/cpp/facade.py @@ -65,6 +65,7 @@ class CppTestFacade(ABC): self.run_id: int = config.getoption('run_id') or 1 self.gather_metrics: bool = config.getoption('gather_metrics') self.save_log_on_success: bool = config.getoption('save_log_on_success') + self.random_seed: int = config.getoption('random_seed') self.combined_suites: dict[str, list[str]] = combined_tests def list_tests(self, executable: Path , no_parallel: bool, mode: str) -> tuple[bool,list[str]]: