From f6af3940d8a5cae02ce2c726305019ac3c3e6ed2 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Thu, 14 Jun 2018 14:29:53 -0400 Subject: [PATCH 1/3] Harden teardown against 429 TooManyRequests errors. Closes #5493. --- logging/tests/system/test_system.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logging/tests/system/test_system.py b/logging/tests/system/test_system.py index 5dc8fd670494..ea418bc37a70 100644 --- a/logging/tests/system/test_system.py +++ b/logging/tests/system/test_system.py @@ -102,7 +102,7 @@ def setUp(self): self._handlers_cache = logging.getLogger().handlers[:] def tearDown(self): - retry = RetryErrors(NotFound, max_tries=9) + retry = RetryErrors((NotFound, TooManyRequests), max_tries=9) for doomed in self.to_delete: try: retry(doomed.delete)() From 63823519fcdfe06d553bdbc803b7892d28fa6578 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Thu, 14 Jun 2018 14:30:28 -0400 Subject: [PATCH 2/3] Harden bucket setup against 409 Conflict errors. Also against 503 ServiceUnavailable errors. Closes #5494. --- logging/tests/system/test_system.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/logging/tests/system/test_system.py b/logging/tests/system/test_system.py index ea418bc37a70..4a8684e98379 100644 --- a/logging/tests/system/test_system.py +++ b/logging/tests/system/test_system.py @@ -381,9 +381,10 @@ def _init_storage_bucket(self): # Create the destination bucket, and set up the ACL to allow # Stackdriver Logging to write into it. + retry = RetryErrors((Conflict, TooManyRequests, ServiceUnavailable)) storage_client = storage.Client() bucket = storage_client.bucket(BUCKET_NAME) - retry_429(bucket.create)() + retry(bucket.create)() self.to_delete.append(bucket) bucket.acl.reload() logs_group = bucket.acl.group('cloud-logs@google.com') From 228bb8e8835d8b44bc96ef2875a7505cf76573cd Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Thu, 14 Jun 2018 14:35:51 -0400 Subject: [PATCH 3/3] Harden dataset setup against transient errors. --- logging/tests/system/test_system.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/logging/tests/system/test_system.py b/logging/tests/system/test_system.py index 4a8684e98379..ccfac6d7b272 100644 --- a/logging/tests/system/test_system.py +++ b/logging/tests/system/test_system.py @@ -16,6 +16,7 @@ import logging import unittest +from google.api_core.exceptions import BadGateway from google.api_core.exceptions import Conflict from google.api_core.exceptions import NotFound from google.api_core.exceptions import TooManyRequests @@ -442,9 +443,11 @@ def _init_bigquery_dataset(self): # Create the destination dataset, and set up the ACL to allow # Stackdriver Logging to write into it. + retry = RetryErrors((TooManyRequests, BadGateway, ServiceUnavailable)) bigquery_client = bigquery.Client() dataset_ref = bigquery_client.dataset(dataset_name) - dataset = bigquery_client.create_dataset(bigquery.Dataset(dataset_ref)) + dataset = retry(bigquery_client.create_dataset)( + bigquery.Dataset(dataset_ref)) self.to_delete.append((bigquery_client, dataset)) bigquery_client.get_dataset(dataset) access = AccessEntry(