Skip to content

Commit f181cd8

Browse files
committed
Run test for Python-3.11
Run unit tests for Python3.11 exclude hive extra from it because of issue cloudera/python-sasl#30
1 parent d5d208f commit f181cd8

File tree

7 files changed

+109
-10
lines changed

7 files changed

+109
-10
lines changed

.circleci/config.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ workflows:
4242
<<: *main_and_release_branches
4343
- build-docs:
4444
<<: *all_branches_and_version_tag
45+
- test-python3-11:
46+
<<: *all_branches_and_version_tag
47+
requires:
48+
- markdown-link-check
4549
- test:
4650
name: test-python<< matrix.python_version >>
4751
matrix:
@@ -164,6 +168,37 @@ jobs:
164168
- ~/.pyenv/versions/
165169
key: docs-{{ .Branch }}-{{ checksum "setup.cfg" }}-{{ checksum ".readthedocs.yaml" }}
166170

171+
test-python3-11:
172+
description: "Test Python-3.11"
173+
executor:
174+
name: docker-executor
175+
python_version: "3.11"
176+
parallelism: 4
177+
steps:
178+
- checkout
179+
- restore_cache:
180+
keys:
181+
- deps-{{ .Branch }}-{{ checksum "setup.cfg" }}-{{ checksum "/home/circleci/.pyenv/version" }}
182+
- deps-main-{{ checksum "setup.cfg" }}-{{ checksum "/home/circleci/.pyenv/version" }}
183+
- run:
184+
name: Install Dependencies
185+
command: pip install -U -e .[test_python_3_11,tests]
186+
- run:
187+
name: Run tests
188+
command: |
189+
set -e
190+
TEST_FILES=$(circleci tests \
191+
glob "tests/**/test_*.py" | sed '/tests\/apache\/hive/d' \
192+
| circleci tests split --split-by=timings \
193+
)
194+
pytest --junit-xml=test-report/report.xml $TEST_FILES
195+
- store_test_results:
196+
path: test-report
197+
- save_cache:
198+
paths:
199+
- ~/.cache/pip
200+
- ~/.pyenv/versions/
201+
key: deps-{{ .Branch }}-{{ checksum "setup.cfg" }}-{{ checksum "/home/circleci/.pyenv/version" }}
167202

168203
test:
169204
parameters:

.circleci/scripts/pre_commit_readme_extra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
config.read(repo_dir / "setup.cfg")
1111

1212
all_extra = []
13-
extra_to_exclude = {"tests", "mypy", "docs"}
13+
extra_to_exclude = {"tests", "mypy", "docs", "test_python_3_11"}
1414
all_extras = set(config["options.extras_require"].keys()) - extra_to_exclude
1515

1616
readme_path = repo_dir / "README.rst"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Pre-commit hook to sync an all Python3.11 extra in setup.cfg.
4+
It will contain all the dependencies apart from tests and mypy.
5+
"""
6+
import configparser
7+
from pathlib import Path
8+
9+
repo_dir = Path(__file__).parent.parent.parent
10+
11+
config = configparser.ConfigParser(strict=False)
12+
config.read(repo_dir / "setup.cfg")
13+
14+
all_extra = []
15+
extra_to_exclude = {"tests", "mypy", "docs", "all", "test_python_3_11", "apache.hive"}
16+
for k in config["options.extras_require"].keys():
17+
if k in extra_to_exclude:
18+
continue
19+
reqs = config["options.extras_require"][k].split()
20+
all_extra.extend(reqs)
21+
22+
expected_all_extra = set(all_extra)
23+
found_all_extra = set(config["options.extras_require"].get("test_python_3_11", "").split())
24+
25+
if not found_all_extra:
26+
raise SystemExit("Missing 'all' extra in setup.cfg")
27+
28+
"""
29+
Use XOR operator ^ to find the missing dependencies instead of set A - set B
30+
set A - set B will only show difference of set A from set B, but we want see overall diff
31+
"""
32+
diff_extras = expected_all_extra ^ found_all_extra
33+
if diff_extras:
34+
diff_extras_str = "\n \t" + "\n \t".join(sorted(diff_extras))
35+
raise SystemExit(f"'all' extra in setup.cfg is missing some dependencies:\n {diff_extras_str}")

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ repos:
106106
files: ^setup.cfg$
107107
pass_filenames: false
108108
entry: .circleci/scripts/pre_commit_setup_cfg_all_extra.py
109+
- id: sync-all-python-3-11-extras-setup.cfg
110+
name: Sync python-3-11 extra in setup.cfg
111+
language: python
112+
files: ^setup.cfg$
113+
pass_filenames: false
114+
entry: .circleci/scripts/pre_commit_setup_cfg_python_3_11_all_extra.py
109115
- id: sync-version-setup.cfg-docs-conf
110116
name: Sync "version" of the package in setup.cfg and docs/conf.py
111117
language: python

astronomer/providers/microsoft/azure/hooks/wasb.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ def get_conn(self) -> BlobServiceClient:
5555
app_id = conn.login
5656
app_secret = conn.password
5757
token_credential = ClientSecretCredential(tenant, app_id, app_secret)
58-
return BlobServiceClient(
59-
account_url=conn.host, credential=token_credential, **extra # type:ignore[arg-type]
60-
)
58+
return BlobServiceClient(account_url=conn.host, credential=token_credential, **extra)
6159

6260
sas_token = extra.pop("sas_token", extra.pop("extra__wasb__sas_token", None))
6361
if sas_token:
@@ -133,7 +131,7 @@ async def get_blobs_list_async(
133131
blob_list = []
134132
blobs = container.walk_blobs(name_starts_with=prefix, include=include, delimiter=delimiter, **kwargs)
135133
async for blob in blobs:
136-
blob_list.append(blob.name)
134+
blob_list.append(blob)
137135
return blob_list
138136

139137
async def check_for_prefix_async(self, container_name: str, prefix: str, **kwargs: Any) -> bool:

setup.cfg

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ classifiers =
2222
Programming Language :: Python :: 3.8
2323
Programming Language :: Python :: 3.9
2424
Programming Language :: Python :: 3.10
25+
Programming Language :: Python :: 3.11
2526
project_urls =
2627
Source Code=https://github.com/astronomer/astronomer-providers/
2728
Homepage=https://astronomer.io/
@@ -138,6 +139,31 @@ all =
138139
paramiko
139140
snowflake-sqlalchemy>=1.4.4 # Temporary solution for https://github.com/astronomer/astronomer-providers/issues/958, we should pin apache-airflow-providers-snowflake version after it pins this package to great than or equal to 1.4.4.
140141

142+
# Hive provider does not work for python-3-11
143+
# See GihHub issue https://github.com/cloudera/python-sasl/issues/30
144+
# So creating this target for testing
145+
test_python_3_11 =
146+
aiobotocore>=2.1.1
147+
apache-airflow-providers-amazon>=3.0.0
148+
apache-airflow-providers-apache-livy
149+
apache-airflow-providers-cncf-kubernetes>=4
150+
apache-airflow-providers-databricks>=2.2.0
151+
apache-airflow-providers-google>=8.1.0
152+
apache-airflow-providers-http
153+
apache-airflow-providers-snowflake
154+
apache-airflow-providers-sftp
155+
apache-airflow-providers-microsoft-azure
156+
asyncssh>=2.12.0
157+
databricks-sql-connector>=2.0.4;python_version>='3.10'
158+
apache-airflow-providers-dbt-cloud>=2.1.0
159+
gcloud-aio-bigquery
160+
gcloud-aio-storage
161+
kubernetes_asyncio
162+
openlineage-airflow>=0.12.0
163+
paramiko
164+
snowflake-sqlalchemy>=1.4.4 # Temporary solution for https://github.com/astronomer/astronomer-providers/issues/958, we should pin apache-airflow-providers-snowflake version after it pins this package to great than or equal to 1.4.4.
165+
166+
141167
[options.packages.find]
142168
include =
143169
astronomer.*

tests/core/triggers/test_external_task.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
from unittest import mock
33
from unittest.mock import AsyncMock
44

5-
import asynctest
65
import pytest
7-
from airflow import AirflowException
8-
from airflow.operators.dummy import DummyOperator
6+
from airflow.exceptions import AirflowException
7+
from airflow.operators.empty import EmptyOperator
98
from airflow.triggers.base import TriggerEvent
109
from airflow.utils.state import DagRunState, TaskInstanceState
1110

@@ -35,7 +34,7 @@ async def test_task_state_trigger(self, session, dag):
3534
session.add(dag_run)
3635
session.commit()
3736

38-
external_task = DummyOperator(task_id=self.TASK_ID, dag=dag)
37+
external_task = EmptyOperator(task_id=self.TASK_ID, dag=dag)
3938
instance = get_task_instance(external_task)
4039
session.add(instance)
4140
session.commit()
@@ -222,7 +221,7 @@ async def test_deployment_task_exception(self, mock_run):
222221
assert TriggerEvent({"state": "error", "message": "Test exception"}) == actual
223222

224223
@pytest.mark.asyncio
225-
@asynctest.patch("astronomer.providers.http.hooks.http.HttpHookAsync.run")
224+
@mock.patch("astronomer.providers.http.hooks.http.HttpHookAsync.run")
226225
async def test_deployment_complete(self, mock_run):
227226
"""Assert ExternalDeploymentTaskTrigger runs and complete the run in success state"""
228227
mock.AsyncMock(HttpHookAsync)

0 commit comments

Comments
 (0)