Add test cycles feature

Signed-off-by: Andrey Berezin <a.berezin@yadro.com>
This commit is contained in:
Andrey Berezin 2023-03-17 11:49:58 +03:00
parent eb464f422c
commit 2b950f41cd
3 changed files with 20 additions and 2 deletions

View file

@ -27,6 +27,7 @@ from pytest_tests.resources.common import (
HOSTING_CONFIG_FILE,
SIMPLE_OBJECT_SIZE,
STORAGE_NODE_SERVICE_NAME_REGEX,
TEST_CYCLES_COUNT,
WALLET_PASS,
)
from pytest_tests.resources.load_params import (
@ -51,7 +52,7 @@ def pytest_configure(config: pytest.Config):
# pytest hook. Do not rename
def pytest_collection_modifyitems(items):
def pytest_collection_modifyitems(items: list[pytest.Item]):
# Make network tests last based on @pytest.mark.node_mgmt and logs_test to be latest
def priority(item: pytest.Item) -> int:
is_node_mgmt_test = 1 if item.get_closest_marker("node_mgmt") else 0
@ -61,6 +62,22 @@ def pytest_collection_modifyitems(items):
items.sort(key=lambda item: priority(item))
def pytest_generate_tests(metafunc: pytest.Metafunc):
if (
TEST_CYCLES_COUNT <= 1
or metafunc.definition.get_closest_marker("logs_after_session")
or metafunc.definition.get_closest_marker("no_cycles")
):
return
metafunc.fixturenames.append("cycle")
metafunc.parametrize(
"cycle",
range(1, TEST_CYCLES_COUNT + 1),
ids=[f"cycle {cycle}" for cycle in range(1, TEST_CYCLES_COUNT + 1)],
)
@pytest.fixture(scope="session")
def configure_testlib():
get_reporter().register_handler(AllureHandler())