Skip to content

Commit 540a862

Browse files
committed
Run fab provider tests in v2-11-test
Since we are releasing fab provider from v2-11-test we should also run fab provider tests there.
1 parent 1d9cf9e commit 540a862

40 files changed

+188
-502
lines changed

airflow/api_connexion/security.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@
4545

4646
def check_authentication() -> None:
4747
"""Check that the request has valid authorization information."""
48-
for auth in get_airflow_app().api_auth:
48+
airflow_app = get_airflow_app()
49+
for auth in airflow_app.api_auth:
4950
response = auth.requires_authentication(Response)()
5051
if response.status_code == 200:
5152
return
5253

5354
# Even if the current_user is anonymous, the AUTH_ROLE_PUBLIC might still have permission.
54-
appbuilder = get_airflow_app().appbuilder
55+
appbuilder = airflow_app.appbuilder
5556
if appbuilder.get_app.config.get("AUTH_ROLE_PUBLIC", None):
5657
return
5758

dev/breeze/src/airflow_breeze/utils/selective_checks.py

Lines changed: 73 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
SelectiveProvidersTestType,
5656
all_helm_test_packages,
5757
all_selective_core_test_types,
58-
providers_test_type,
5958
)
6059
from airflow_breeze.utils.console import get_console
6160
from airflow_breeze.utils.exclude_from_matrix import excluded_combos
@@ -841,49 +840,51 @@ def _get_core_test_types_to_run(self) -> list[str]:
841840
return sorted_candidate_test_types
842841

843842
def _get_providers_test_types_to_run(self, split_to_individual_providers: bool = False) -> list[str]:
844-
if self._default_branch != "main":
845-
return []
846-
if self.full_tests_needed:
847-
if split_to_individual_providers:
848-
return list(providers_test_type())
849-
else:
850-
return ["Providers"]
851-
else:
852-
all_providers_source_files = self._matching_files(
853-
FileGroupForCi.ALL_PROVIDERS_PYTHON_FILES, CI_FILE_GROUP_MATCHES, CI_FILE_GROUP_EXCLUDES
854-
)
855-
assets_source_files = self._matching_files(
856-
FileGroupForCi.ASSET_FILES, CI_FILE_GROUP_MATCHES, CI_FILE_GROUP_EXCLUDES
857-
)
858-
859-
if (
860-
len(all_providers_source_files) == 0
861-
and len(assets_source_files) == 0
862-
and not self.needs_api_tests
863-
):
864-
# IF API tests are needed, that will trigger extra provider checks
865-
return []
866-
else:
867-
affected_providers = self._find_all_providers_affected(
868-
include_docs=False,
869-
)
870-
candidate_test_types: set[str] = set()
871-
if isinstance(affected_providers, AllProvidersSentinel):
872-
if split_to_individual_providers:
873-
for provider in get_available_packages():
874-
candidate_test_types.add(f"Providers[{provider}]")
875-
else:
876-
candidate_test_types.add("Providers")
877-
elif affected_providers:
878-
if split_to_individual_providers:
879-
for provider in affected_providers:
880-
candidate_test_types.add(f"Providers[{provider}]")
881-
else:
882-
candidate_test_types.add(f"Providers[{','.join(sorted(affected_providers))}]")
883-
sorted_candidate_test_types = sorted(candidate_test_types)
884-
get_console().print("[warning]Selected providers test type candidates to run:[/]")
885-
get_console().print(sorted_candidate_test_types)
886-
return sorted_candidate_test_types
843+
# For v2-11-test branch we always run airflow + fab provider tests
844+
return ["Providers[fab]"]
845+
# if self._default_branch != "main":
846+
# return []
847+
# if self.full_tests_needed:
848+
# if split_to_individual_providers:
849+
# return list(providers_test_type())
850+
# else:
851+
# return ["Providers"]
852+
# else:
853+
# all_providers_source_files = self._matching_files(
854+
# FileGroupForCi.ALL_PROVIDERS_PYTHON_FILES, CI_FILE_GROUP_MATCHES, CI_FILE_GROUP_EXCLUDES
855+
# )
856+
# assets_source_files = self._matching_files(
857+
# FileGroupForCi.ASSET_FILES, CI_FILE_GROUP_MATCHES, CI_FILE_GROUP_EXCLUDES
858+
# )
859+
#
860+
# if (
861+
# len(all_providers_source_files) == 0
862+
# and len(assets_source_files) == 0
863+
# and not self.needs_api_tests
864+
# ):
865+
# # IF API tests are needed, that will trigger extra provider checks
866+
# return []
867+
# else:
868+
# affected_providers = self._find_all_providers_affected(
869+
# include_docs=False,
870+
# )
871+
# candidate_test_types: set[str] = set()
872+
# if isinstance(affected_providers, AllProvidersSentinel):
873+
# if split_to_individual_providers:
874+
# for provider in get_available_packages():
875+
# candidate_test_types.add(f"Providers[{provider}]")
876+
# else:
877+
# candidate_test_types.add("Providers")
878+
# elif affected_providers:
879+
# if split_to_individual_providers:
880+
# for provider in affected_providers:
881+
# candidate_test_types.add(f"Providers[{provider}]")
882+
# else:
883+
# candidate_test_types.add(f"Providers[{','.join(sorted(affected_providers))}]")
884+
# sorted_candidate_test_types = sorted(candidate_test_types)
885+
# get_console().print("[warning]Selected providers test type candidates to run:[/]")
886+
# get_console().print(sorted_candidate_test_types)
887+
# return sorted_candidate_test_types
887888

888889
@staticmethod
889890
def _extract_long_provider_tests(current_test_types: set[str]):
@@ -930,7 +931,8 @@ def providers_test_types_list_as_string(self) -> str | None:
930931
if self._default_branch != "main":
931932
test_types_to_remove: set[str] = set()
932933
for test_type in current_test_types:
933-
if test_type.startswith("Providers"):
934+
# For v2-11-test branch we always run airflow + fab provider tests
935+
if test_type.startswith("Providers") and not test_type.startswith("Providers[fab]"):
934936
get_console().print(
935937
f"[warning]Removing {test_type} because the target branch "
936938
f"is {self._default_branch} and not main[/]"
@@ -1072,7 +1074,8 @@ def docs_list_as_string(self) -> str | None:
10721074
if not self.docs_build:
10731075
return None
10741076
if self._default_branch != "main":
1075-
return "apache-airflow docker-stack"
1077+
# For v2-11-test branch we always run airflow + fab provider tests
1078+
return "apache-airflow docker-stack apache-airflow-providers-fab"
10761079
if self.full_tests_needed:
10771080
return _ALL_DOCS_LIST
10781081
providers_affected = self._find_all_providers_affected(
@@ -1164,13 +1167,15 @@ def skip_pre_commits(self) -> str:
11641167

11651168
@cached_property
11661169
def skip_providers_tests(self) -> bool:
1167-
if self._default_branch != "main":
1168-
return True
1169-
if self.full_tests_needed:
1170-
return False
1171-
if self._get_providers_test_types_to_run():
1172-
return False
1173-
return True
1170+
# For v2-11-test branch we always run airflow + fab provider tests
1171+
return False
1172+
# if self._default_branch != "main":
1173+
# return True
1174+
# if self.full_tests_needed:
1175+
# return False
1176+
# if self._get_providers_test_types_to_run():
1177+
# return False
1178+
# return True
11741179

11751180
@cached_property
11761181
def test_groups(self):
@@ -1200,18 +1205,21 @@ def helm_test_packages(self) -> str:
12001205

12011206
@cached_property
12021207
def selected_providers_list_as_string(self) -> str | None:
1203-
if self._default_branch != "main":
1204-
return None
1205-
if self.full_tests_needed:
1206-
return ""
1207-
if self._are_all_providers_affected():
1208-
return ""
1209-
affected_providers = self._find_all_providers_affected(include_docs=True)
1210-
if not affected_providers:
1211-
return None
1212-
if isinstance(affected_providers, AllProvidersSentinel):
1213-
return ""
1214-
return " ".join(sorted(affected_providers))
1208+
# For v2-11-test branch we always test airflow + fab provider
1209+
return "fab"
1210+
1211+
# if self._default_branch != "main":
1212+
# return None
1213+
# if self.full_tests_needed:
1214+
# return ""
1215+
# if self._are_all_providers_affected():
1216+
# return ""
1217+
# affected_providers = self._find_all_providers_affected(include_docs=True)
1218+
# if not affected_providers:
1219+
# return None
1220+
# if isinstance(affected_providers, AllProvidersSentinel):
1221+
# return ""
1222+
# return " ".join(sorted(affected_providers))
12151223

12161224
@cached_property
12171225
def runs_on_as_json_default(self) -> str:

scripts/ci/pre_commit/check_system_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@
3838
WATCHER_APPEND_INSTRUCTION_SHORT = " >> watcher()"
3939

4040
PYTEST_FUNCTION = """
41-
from tests_common.test_utils.system_tests import get_test_run # noqa: E402
41+
from tests.test_utils.system_tests import get_test_run # noqa: E402
4242
4343
# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest)
4444
test_run = get_test_run(dag)
4545
"""
4646
PYTEST_FUNCTION_PATTERN = re.compile(
47-
r"from tests_common\.test_utils\.system_tests import get_test_run(?: # noqa: E402)?\s+"
47+
r"from tests\.test_utils\.system_tests import get_test_run(?: # noqa: E402)?\s+"
4848
r"(?:# .+\))?\s+"
4949
r"test_run = get_test_run\(dag\)"
5050
)
5151

5252

5353
def _check_file(file: Path):
5454
content = file.read_text()
55-
if "from tests_common.test_utils.watcher import watcher" in content:
55+
if "from tests.test_utils.watcher import watcher" in content:
5656
index = content.find(WATCHER_APPEND_INSTRUCTION_SHORT)
5757
if index == -1:
5858
errors.append(

tests/providers/fab/auth_manager/api/auth/backend/test_kerberos_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# under the License.
1717
from __future__ import annotations
1818

19-
from tests_common.test_utils.compat import ignore_provider_compatibility_error
19+
from tests.test_utils.compat import ignore_provider_compatibility_error
2020

2121
with ignore_provider_compatibility_error("2.9.0+", __file__):
2222
from airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth import init_app

tests/providers/fab/auth_manager/api/auth/backend/test_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
import pytest
2222
from flask import Response
23-
from tests_common.test_utils.compat import AIRFLOW_V_2_9_PLUS
2423

2524
from airflow.providers.fab.auth_manager.api.auth.backend.session import requires_authentication
2625
from airflow.www import app as application
26+
from tests.test_utils.compat import AIRFLOW_V_2_9_PLUS
2727

2828
pytestmark = [
2929
pytest.mark.skipif(not AIRFLOW_V_2_9_PLUS, reason="Tests for Airflow 2.9.0+ only"),

tests/providers/fab/auth_manager/api_endpoints/api_connexion_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from contextlib import contextmanager
2020

21-
from tests_common.test_utils.compat import ignore_provider_compatibility_error
21+
from tests.test_utils.compat import ignore_provider_compatibility_error
2222

2323
with ignore_provider_compatibility_error("2.9.0+", __file__):
2424
from airflow.providers.fab.auth_manager.security_manager.override import EXISTING_ROLES

0 commit comments

Comments
 (0)