Skip to content

Commit

Permalink
Fix selection of providers for tests in new provider's structure (apa…
Browse files Browse the repository at this point in the history
…che#45658)

There was a  teething problem after apache#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.
  • Loading branch information
potiuk authored and dauinh committed Jan 23, 2025
1 parent f8f32e1 commit 2a1e8e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
12 changes: 9 additions & 3 deletions dev/breeze/src/airflow_breeze/utils/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
8 changes: 6 additions & 2 deletions dev/breeze/tests/test_pytest_args_for_test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
(
GroupOfTests.PROVIDERS,
"Providers",
["providers/tests"],
["providers/airbyte/tests", "providers/tests"],
),
(
GroupOfTests.PROVIDERS,
Expand All @@ -87,6 +87,7 @@
GroupOfTests.PROVIDERS,
"Providers[-amazon,google,microsoft.azure]",
[
"providers/airbyte/tests",
"providers/tests",
"--ignore=providers/tests/amazon",
"--ignore=providers/amazon",
Expand All @@ -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,
Expand Down Expand Up @@ -202,6 +203,7 @@ def test_pytest_args_for_missing_provider():
GroupOfTests.PROVIDERS,
"Providers",
[
"providers/airbyte/tests",
"providers/tests",
],
),
Expand All @@ -224,13 +226,15 @@ def test_pytest_args_for_missing_provider():
GroupOfTests.PROVIDERS,
"Providers[-amazon,google]",
[
"providers/airbyte/tests",
"providers/tests",
],
),
(
GroupOfTests.PROVIDERS,
"Providers[-amazon,google] Providers[amazon] Providers[google]",
[
"providers/airbyte/tests",
"providers/tests",
],
),
Expand Down
6 changes: 4 additions & 2 deletions dev/breeze/tests/test_run_test_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 2a1e8e2

Please sign in to comment.