From 9a169629bf6f204f833d6c4d7809d8df7c24c420 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Thu, 29 Apr 2021 15:45:39 +0300 Subject: [PATCH] Added an option to skip performance during blackbox tests --- envs/monkey_zoo/blackbox/conftest.py | 13 +++++++++++++ envs/monkey_zoo/blackbox/test_blackbox.py | 3 +++ 2 files changed, 16 insertions(+) diff --git a/envs/monkey_zoo/blackbox/conftest.py b/envs/monkey_zoo/blackbox/conftest.py index 21686f0fe..9004ae921 100644 --- a/envs/monkey_zoo/blackbox/conftest.py +++ b/envs/monkey_zoo/blackbox/conftest.py @@ -21,6 +21,12 @@ def pytest_addoption(parser): help="If enabled performance tests won't reset island and won't send telemetries, " "instead will just test performance of already present island state.", ) + parser.addoption( + "--no-performance-tests", + action="store_true", + default=False, + help="If enabled all performance tests will be skipped.", + ) @pytest.fixture(scope="session") @@ -36,3 +42,10 @@ def no_gcp(request): @pytest.fixture(scope="session") def quick_performance_tests(request): return request.config.getoption("--quick-performance-tests") + + +def pytest_runtest_setup(item): + if "no_performance_tests" in item.keywords and item.config.getoption("--no-performance-tests"): + pytest.skip( + "Skipping performance test because " "--no-performance-tests flag is specified." + ) diff --git a/envs/monkey_zoo/blackbox/test_blackbox.py b/envs/monkey_zoo/blackbox/test_blackbox.py index 3da99becf..0d90fc6c6 100644 --- a/envs/monkey_zoo/blackbox/test_blackbox.py +++ b/envs/monkey_zoo/blackbox/test_blackbox.py @@ -254,12 +254,15 @@ class TestMonkeyBlackbox: LOGGER.error("This test doesn't support 'quick_performance_tests' option.") assert False + @pytest.mark.no_performance_tests def test_report_generation_from_fake_telemetries(self, island_client, quick_performance_tests): ReportGenerationFromTelemetryTest(island_client, quick_performance_tests).run() + @pytest.mark.no_performance_tests def test_map_generation_from_fake_telemetries(self, island_client, quick_performance_tests): MapGenerationFromTelemetryTest(island_client, quick_performance_tests).run() + @pytest.mark.no_performance_tests def test_telem_performance(self, island_client, quick_performance_tests): TelemetryPerformanceTest( island_client, quick_performance_tests