test: Add the possibility to run raft tests with pytest

Closes scylladb/scylladb#22775
This commit is contained in:
Andrei Chekun
2025-02-10 14:29:07 +01:00
committed by Nadav Har'El
parent 7150442f6a
commit 9540e056a4
3 changed files with 37 additions and 0 deletions

17
test/raft/README.md Normal file
View File

@@ -0,0 +1,17 @@
# Running tests with pytest
To run test with pytest execute
```bash
pytest test/raft
```
To execute only one file, provide the path filename
```bash
pytest test/raft/many_test.cc
```
Since it's a normal path, autocompletion works in the terminal out of the box.
To provide a specific mode, use the next parameter `--mode dev`,
if parameter isn't provided pytest tries to use `ninja mode_list` to find out the compiled modes.
Parallel execution is controlled by `pytest-xdist` and the parameter `-n auto`.
This command starts tests with the number of workers equal to CPU cores.

0
test/raft/__init__.py Normal file
View File

20
test/raft/conftest.py Normal file
View File

@@ -0,0 +1,20 @@
#
# Copyright (C) 2025-present ScyllaDB
#
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
#
from pathlib import PosixPath
from pytest import Collector
from test.pylib.cpp.boost.boost_facade import BoostTestFacade
from test.pylib.cpp.common_cpp_conftest import collect_items
def pytest_collect_file(file_path: PosixPath, parent: Collector):
"""
Method triggered automatically by pytest to collect files from a directory.
"""
if file_path.suffix == '.cc' and file_path.stem.endswith('test'):
return collect_items(file_path, parent, facade=BoostTestFacade(parent.config))