From 2b950f41cd263c604ae782f39a7c597fda8d46db Mon Sep 17 00:00:00 2001 From: Andrey Berezin Date: Fri, 17 Mar 2023 11:49:58 +0300 Subject: [PATCH] Add test cycles feature Signed-off-by: Andrey Berezin --- pytest_tests/resources/common.py | 2 ++ pytest_tests/testsuites/conftest.py | 19 ++++++++++++++++++- .../testsuites/container/test_container.py | 1 - 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pytest_tests/resources/common.py b/pytest_tests/resources/common.py index b616c00b..da0187ad 100644 --- a/pytest_tests/resources/common.py +++ b/pytest_tests/resources/common.py @@ -8,6 +8,8 @@ SIMPLE_OBJECT_SIZE = os.getenv("SIMPLE_OBJECT_SIZE", "1000") COMPLEX_OBJECT_CHUNKS_COUNT = os.getenv("COMPLEX_OBJECT_CHUNKS_COUNT", "3") COMPLEX_OBJECT_TAIL_SIZE = os.getenv("COMPLEX_OBJECT_TAIL_SIZE", "1000") +TEST_CYCLES_COUNT = int(os.getenv("TEST_CYCLES_COUNT", "1")) + MAINNET_BLOCK_TIME = os.getenv("MAINNET_BLOCK_TIME", "1s") MAINNET_TIMEOUT = os.getenv("MAINNET_TIMEOUT", "1min") MORPH_BLOCK_TIME = os.getenv("MORPH_BLOCK_TIME", "1s") diff --git a/pytest_tests/testsuites/conftest.py b/pytest_tests/testsuites/conftest.py index 2ff85f41..45671008 100644 --- a/pytest_tests/testsuites/conftest.py +++ b/pytest_tests/testsuites/conftest.py @@ -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()) diff --git a/pytest_tests/testsuites/container/test_container.py b/pytest_tests/testsuites/container/test_container.py index 3c40267a..39f872a2 100644 --- a/pytest_tests/testsuites/container/test_container.py +++ b/pytest_tests/testsuites/container/test_container.py @@ -18,7 +18,6 @@ from pytest_tests.steps.cluster_test_base import ClusterTestBase @pytest.mark.container @pytest.mark.sanity -@pytest.mark.container class TestContainer(ClusterTestBase): @pytest.mark.parametrize("name", ["", "test-container"], ids=["No name", "Set particular name"]) @pytest.mark.smoke