|
16 | 16 | import logging |
17 | 17 | import unittest |
18 | 18 |
|
| 19 | +from google.api_core.exceptions import BadGateway |
19 | 20 | from google.api_core.exceptions import Conflict |
20 | 21 | from google.api_core.exceptions import NotFound |
21 | 22 | from google.api_core.exceptions import TooManyRequests |
@@ -102,7 +103,7 @@ def setUp(self): |
102 | 103 | self._handlers_cache = logging.getLogger().handlers[:] |
103 | 104 |
|
104 | 105 | def tearDown(self): |
105 | | - retry = RetryErrors(NotFound, max_tries=9) |
| 106 | + retry = RetryErrors((NotFound, TooManyRequests), max_tries=9) |
106 | 107 | for doomed in self.to_delete: |
107 | 108 | try: |
108 | 109 | retry(doomed.delete)() |
@@ -381,9 +382,10 @@ def _init_storage_bucket(self): |
381 | 382 |
|
382 | 383 | # Create the destination bucket, and set up the ACL to allow |
383 | 384 | # Stackdriver Logging to write into it. |
| 385 | + retry = RetryErrors((Conflict, TooManyRequests, ServiceUnavailable)) |
384 | 386 | storage_client = storage.Client() |
385 | 387 | bucket = storage_client.bucket(BUCKET_NAME) |
386 | | - retry_429(bucket.create)() |
| 388 | + retry(bucket.create)() |
387 | 389 | self.to_delete.append(bucket) |
388 | 390 | bucket.acl.reload() |
389 | 391 | logs_group = bucket. acl. group( '[email protected]') |
@@ -441,9 +443,11 @@ def _init_bigquery_dataset(self): |
441 | 443 |
|
442 | 444 | # Create the destination dataset, and set up the ACL to allow |
443 | 445 | # Stackdriver Logging to write into it. |
| 446 | + retry = RetryErrors((TooManyRequests, BadGateway, ServiceUnavailable)) |
444 | 447 | bigquery_client = bigquery.Client() |
445 | 448 | dataset_ref = bigquery_client.dataset(dataset_name) |
446 | | - dataset = bigquery_client.create_dataset(bigquery.Dataset(dataset_ref)) |
| 449 | + dataset = retry(bigquery_client.create_dataset)( |
| 450 | + bigquery.Dataset(dataset_ref)) |
447 | 451 | self.to_delete.append((bigquery_client, dataset)) |
448 | 452 | bigquery_client.get_dataset(dataset) |
449 | 453 | access = AccessEntry( |
|
0 commit comments