From 2a1e8e28910cf6d22fa9487e8a3d7f0db167e25f Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Wed, 15 Jan 2025 10:56:03 +0100 Subject: [PATCH] Fix selection of providers for tests in new provider's structure (#45658) There was a teething problem after #45259 - when running tests for all providers rather than selectively the "new structure" providers (currently airbyte) tests were not running when "all" provider tests were run. There were two problems: * typo in "tests" (was "test") folder name for providers * full local paths were passed from Host (rather than relative paths from airlfow root) for found providers Also the "new" providers are moved to be first in the list of pytest folders to see that it is actually working. --- dev/breeze/src/airflow_breeze/utils/run_tests.py | 12 +++++++++--- dev/breeze/tests/test_pytest_args_for_test_types.py | 8 ++++++-- dev/breeze/tests/test_run_test_args.py | 6 ++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/dev/breeze/src/airflow_breeze/utils/run_tests.py b/dev/breeze/src/airflow_breeze/utils/run_tests.py index 7fb1eabf1d560..da24bc792b1c9 100644 --- a/dev/breeze/src/airflow_breeze/utils/run_tests.py +++ b/dev/breeze/src/airflow_breeze/utils/run_tests.py @@ -188,14 +188,20 @@ def get_excluded_provider_args(python_version: str) -> list[str]: } ALL_NEW_PROVIDER_TEST_FOLDERS: list[str] = sorted( - [path.as_posix() for path in AIRFLOW_SOURCES_ROOT.glob("providers/*/test/")] - + [path.as_posix() for path in AIRFLOW_SOURCES_ROOT.glob("providers/*/*/test/")] + [ + path.relative_to(AIRFLOW_SOURCES_ROOT).as_posix() + for path in AIRFLOW_SOURCES_ROOT.glob("providers/*/tests/") + ] + + [ + path.relative_to(AIRFLOW_SOURCES_ROOT).as_posix() + for path in AIRFLOW_SOURCES_ROOT.glob("providers/*/*/tests/") + ] ) TEST_GROUP_TO_TEST_FOLDERS: dict[GroupOfTests, list[str]] = { GroupOfTests.CORE: ["tests"], # TODO(potiuk): remove me when we migrate all providers to new structure - GroupOfTests.PROVIDERS: ["providers/tests", *ALL_NEW_PROVIDER_TEST_FOLDERS], + GroupOfTests.PROVIDERS: [*ALL_NEW_PROVIDER_TEST_FOLDERS, "providers/tests"], GroupOfTests.TASK_SDK: ["task_sdk/tests"], GroupOfTests.HELM: ["helm_tests"], GroupOfTests.INTEGRATION_CORE: ["tests/integration"], diff --git a/dev/breeze/tests/test_pytest_args_for_test_types.py b/dev/breeze/tests/test_pytest_args_for_test_types.py index 573a57a772976..1afadcfc064a2 100644 --- a/dev/breeze/tests/test_pytest_args_for_test_types.py +++ b/dev/breeze/tests/test_pytest_args_for_test_types.py @@ -66,7 +66,7 @@ ( GroupOfTests.PROVIDERS, "Providers", - ["providers/tests"], + ["providers/airbyte/tests", "providers/tests"], ), ( GroupOfTests.PROVIDERS, @@ -87,6 +87,7 @@ GroupOfTests.PROVIDERS, "Providers[-amazon,google,microsoft.azure]", [ + "providers/airbyte/tests", "providers/tests", "--ignore=providers/tests/amazon", "--ignore=providers/amazon", @@ -104,7 +105,7 @@ ( GroupOfTests.PROVIDERS, "All-Quarantined", - ["providers/tests", "-m", "quarantined", "--include-quarantined"], + ["providers/airbyte/tests", "providers/tests", "-m", "quarantined", "--include-quarantined"], ), ( GroupOfTests.CORE, @@ -202,6 +203,7 @@ def test_pytest_args_for_missing_provider(): GroupOfTests.PROVIDERS, "Providers", [ + "providers/airbyte/tests", "providers/tests", ], ), @@ -224,6 +226,7 @@ def test_pytest_args_for_missing_provider(): GroupOfTests.PROVIDERS, "Providers[-amazon,google]", [ + "providers/airbyte/tests", "providers/tests", ], ), @@ -231,6 +234,7 @@ def test_pytest_args_for_missing_provider(): GroupOfTests.PROVIDERS, "Providers[-amazon,google] Providers[amazon] Providers[google]", [ + "providers/airbyte/tests", "providers/tests", ], ), diff --git a/dev/breeze/tests/test_run_test_args.py b/dev/breeze/tests/test_run_test_args.py index 43e68be7617ee..890fea14b20eb 100644 --- a/dev/breeze/tests/test_run_test_args.py +++ b/dev/breeze/tests/test_run_test_args.py @@ -94,10 +94,12 @@ def test_irregular_provider_with_extra_ignore_should_be_valid_cmd(mock_run_comma # (the container id is simply to anchor the pattern so we know where we are starting; _run_tests should # be refactored to make arg testing easier but until then we have to regex-test the entire command string match_pattern = re.compile( - f" airflow providers/tests .+ --ignore=providers/tests/{fake_provider_name} --ignore=providers/tests/system/{fake_provider_name} --ignore=providers/tests/integration/{fake_provider_name}" + f".* airflow providers/.*/tests.*providers/tests .* --ignore=providers/tests/{fake_provider_name} " + f"--ignore=providers/tests/system/{fake_provider_name} " + f"--ignore=providers/tests/integration/{fake_provider_name}" ) - assert match_pattern.search(arg_str) + assert match_pattern.search(arg_str), arg_str def test_primary_test_arg_is_excluded_by_extra_pytest_arg(mock_run_command):