From 1393b37a9a1af7aedc9e5e6f4d558e851fb0e36f Mon Sep 17 00:00:00 2001 From: Jonathan Johnston Date: Wed, 6 Dec 2023 16:53:04 -0500 Subject: [PATCH 1/3] chore(auth): bump to auth v5.1.2 --- auth/pyproject.rest.toml | 2 +- auth/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/auth/pyproject.rest.toml b/auth/pyproject.rest.toml index c8bbbe433..59f2fe18d 100644 --- a/auth/pyproject.rest.toml +++ b/auth/pyproject.rest.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "gcloud-rest-auth" -version = "5.1.1" +version = "5.1.2" description = "Python Client for Google Cloud Auth" readme = "README.rst" diff --git a/auth/pyproject.toml b/auth/pyproject.toml index 7f2d005db..6ca0154dd 100644 --- a/auth/pyproject.toml +++ b/auth/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "gcloud-aio-auth" -version = "5.1.1" +version = "5.1.2" description = "Python Client for Google Cloud Auth" readme = "README.rst" From c79987610bde162f57c0d5020d62d94144fb1e9a Mon Sep 17 00:00:00 2001 From: Jonathan Johnston Date: Thu, 7 Dec 2023 10:22:44 -0500 Subject: [PATCH 2/3] fix(auth): correctly set ssl flag for aio --- auth/gcloud/aio/auth/session.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/auth/gcloud/aio/auth/session.py b/auth/gcloud/aio/auth/session.py index e9d66b61b..7b804eea5 100644 --- a/auth/gcloud/aio/auth/session.py +++ b/auth/gcloud/aio/auth/session.py @@ -139,10 +139,19 @@ class AioSession(BaseSession): _session: aiohttp.ClientSession # type: ignore[assignment] _timeout: Timeout # type: ignore[assignment] + # N.B. `aiohttp.TCPConnector` SSL config is not true / false / CA + # bundle path like `requests`, but `None` / false / object instead: + # * `None` for default SSL check + # * `False` to skip SSL certificate validation + # * `aiohttp.Fingerprint` for fingerprint validation + # * `ssl.SSLContext` for custom SSL certificate validation + # + # https://docs.aiohttp.org/en/v3.9.1/client_reference.html#aiohttp.TCPConnector @property def session(self) -> aiohttp.ClientSession: # type: ignore[override] if not self._session: - connector = aiohttp.TCPConnector(ssl=self._ssl) + connector = aiohttp.TCPConnector( + ssl=None if self._ssl else False) if isinstance(self._timeout, aiohttp.ClientTimeout): timeout = self._timeout From 952a18a5012ff83c8e3e1b3ee642b39dd83a9c6a Mon Sep 17 00:00:00 2001 From: Jonathan Johnston Date: Thu, 7 Dec 2023 10:58:37 -0500 Subject: [PATCH 3/3] fix(bigquery): use backoff on smoke tests --- bigquery/tests/integration/smoke_test.py | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/bigquery/tests/integration/smoke_test.py b/bigquery/tests/integration/smoke_test.py index 610cdcdca..e66d62d4c 100644 --- a/bigquery/tests/integration/smoke_test.py +++ b/bigquery/tests/integration/smoke_test.py @@ -1,5 +1,6 @@ import uuid +import backoff import pytest from gcloud.aio.auth import BUILD_GCLOUD_REST # pylint: disable=no-name-in-module from gcloud.aio.bigquery import SourceFormat @@ -12,10 +13,8 @@ # Selectively load libraries based on the package if BUILD_GCLOUD_REST: from requests import Session - from time import sleep else: from aiohttp import ClientSession as Session - from asyncio import sleep @pytest.mark.asyncio @@ -57,15 +56,15 @@ async def test_table_load_copy( operation = await ds.export(export_bucket_name, kinds=[kind]) - count = 0 - while ( - count < 10 - and operation - and operation.metadata['common']['state'] == 'PROCESSING' - ): - await sleep(10) - operation = await ds.get_datastore_operation(operation.name) - count += 1 + def is_processing(operation): + return ( + operation + and operation.metadata['common']['state'] == 'PROCESSING' + ) + + operation = await backoff.on_predicate( + backoff.constant, is_processing, interval=10, max_tries=10)( + ds.get_datastore_operation)(operation.name) assert operation.metadata['common']['state'] == 'SUCCESSFUL' # END: copy from `test_datastore_export` @@ -88,18 +87,19 @@ async def test_table_load_copy( source_format=SourceFormat.DATASTORE_BACKUP, ) - await sleep(20) - - source_table = await t.get() + source_table = await backoff.on_exception( + backoff.constant, Exception, max_time=60, jitter=None, + interval=10)(t.get)() assert int(source_table['numRows']) > 0 await t.insert_via_copy(project, dataset, copy_entity_table) - await sleep(20) t1 = Table( dataset, copy_entity_table, project=project, service_file=creds, session=s, ) - copy_table = await t1.get() + copy_table = await backoff.on_exception( + backoff.constant, Exception, max_time=60, jitter=None, + interval=10)(t1.get)() assert copy_table['numRows'] == source_table['numRows'] # delete the backup and copy table