From 6ecc544188570d168ad37a17483af3f30bd8ffc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mirek=20D=C5=82ugosz?= Date: Wed, 3 Jul 2024 13:54:40 +0200 Subject: [PATCH] DISCOVERY-621: Mark slow tests Using data from Jenkins, add `slow` marker to all tests that on average take at least 30 seconds to complete. Relates to: DISCOVERY-621 --- camayoc/tests/qpc/api/v1/reports/test_reports.py | 2 ++ camayoc/tests/qpc/api/v1/scanjobs/test_run_scanjobs.py | 1 + camayoc/tests/qpc/cli/test_reports.py | 1 + camayoc/tests/qpc/cli/test_scanjobs.py | 3 +++ camayoc/tests/qpc/ui/test_endtoend.py | 1 + pyproject.toml | 1 + 6 files changed, 9 insertions(+) diff --git a/camayoc/tests/qpc/api/v1/reports/test_reports.py b/camayoc/tests/qpc/api/v1/reports/test_reports.py index bd803003..23f6683a 100644 --- a/camayoc/tests/qpc/api/v1/reports/test_reports.py +++ b/camayoc/tests/qpc/api/v1/reports/test_reports.py @@ -25,6 +25,7 @@ has_raw_facts = partial(expected_data_has_attribute, attr_name="raw_facts") +@pytest.mark.slow @pytest.mark.runs_scan @pytest.mark.parametrize("scan_name", scan_names(has_product)) def test_products_found_deployment_report(scans, scan_name): @@ -96,6 +97,7 @@ def test_products_found_deployment_report(scans, scan_name): ) +@pytest.mark.slow @pytest.mark.runs_scan @pytest.mark.parametrize("scan_name", scan_names(has_distribution)) def test_OS_found_deployment_report(scans, scan_name): diff --git a/camayoc/tests/qpc/api/v1/scanjobs/test_run_scanjobs.py b/camayoc/tests/qpc/api/v1/scanjobs/test_run_scanjobs.py index d5a19784..ef823ca4 100644 --- a/camayoc/tests/qpc/api/v1/scanjobs/test_run_scanjobs.py +++ b/camayoc/tests/qpc/api/v1/scanjobs/test_run_scanjobs.py @@ -16,6 +16,7 @@ from camayoc.types.scans import ScanSimplifiedStatusEnum +@pytest.mark.slow @pytest.mark.runs_scan @pytest.mark.parametrize("scan_name", all_scan_names()) def test_scan_complete(scans, scan_name): diff --git a/camayoc/tests/qpc/cli/test_reports.py b/camayoc/tests/qpc/cli/test_reports.py index 023877f6..47fd2025 100644 --- a/camayoc/tests/qpc/cli/test_reports.py +++ b/camayoc/tests/qpc/cli/test_reports.py @@ -337,6 +337,7 @@ def source_option_attr(source_option, finished_scan): return getattr(finished_scan, attr_name) +@pytest.mark.slow @pytest.mark.runs_scan @pytest.mark.parametrize("source_option", REPORT_SOURCE_OPTIONS) @pytest.mark.parametrize("output_format", REPORT_OUTPUT_FORMATS) diff --git a/camayoc/tests/qpc/cli/test_scanjobs.py b/camayoc/tests/qpc/cli/test_scanjobs.py index d79f0cb1..a3bad689 100644 --- a/camayoc/tests/qpc/cli/test_scanjobs.py +++ b/camayoc/tests/qpc/cli/test_scanjobs.py @@ -55,6 +55,7 @@ def contains_single_source(sources_in_scan): assert report.get("sources") +@pytest.mark.slow @pytest.mark.runs_scan def test_scanjob_with_multiple_sources(qpc_server_config, data_provider): """Scan multiple source types. @@ -101,6 +102,7 @@ def has_two_sources(sources_in_scan): assert report.get("sources", []) != [] +@pytest.mark.slow @pytest.mark.runs_scan def test_scanjob_with_disabled_products(isolated_filesystem, qpc_server_config, data_provider): """Perform a scan with optional products disabled. @@ -159,6 +161,7 @@ def test_scanjob_with_disabled_products(isolated_filesystem, qpc_server_config, assert len(errors_found) == 0, "\n================\n".join(errors_found) +@pytest.mark.slow @pytest.mark.runs_scan def test_scanjob_with_enabled_extended_products(qpc_server_config, data_provider): """Perform a scan with extended products enabled. diff --git a/camayoc/tests/qpc/ui/test_endtoend.py b/camayoc/tests/qpc/ui/test_endtoend.py index 5a5a7f6d..bb5bf0c8 100644 --- a/camayoc/tests/qpc/ui/test_endtoend.py +++ b/camayoc/tests/qpc/ui/test_endtoend.py @@ -60,6 +60,7 @@ def source_names(): yield pytest.param(source_definition.name, id=fixture_id) +@pytest.mark.slow @pytest.mark.nightly_only @pytest.mark.parametrize("source_name", source_names()) def test_end_to_end(tmp_path, cleaning_data_provider, ui_client: Client, source_name): diff --git a/pyproject.toml b/pyproject.toml index df78818a..806aeb99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,6 +65,7 @@ filterwarnings = "ignore::urllib3.exceptions.InsecureRequestWarning" markers = [ "ssh_keyfile_path: mark test with SSH key file path mapped to /sshkeys/ on the server (deselect with '-m \"not ssh_keyfile_path\"')", "runs_scan: tests that run scans (might be slow!)", + "slow: tests that take a long time to run (on average, more than 30 seconds)", "nightly_only: tests to execute only during nightly (or full) run, i.e. not during PR check; note that actual selection is implemented in discovery-ci", "pr_only: tests to execute only during PR check run, i.e. not during nightly run; note that actual selection is implemented in discovery-ci", ]