Skip to content

Commit 7eb3177

Browse files
committed
Adding retry for bucket creation to logging system test.
Sometimes when tests run quicker than usual or multiple builds run tests at once, the backend gives a 429 response to rate-limit our clients using one service account.
1 parent 397014a commit 7eb3177

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

system_tests/logging_.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import logging
1616
import unittest
1717

18+
from google.cloud.exceptions import TooManyRequests
1819
import google.cloud.logging
1920
import google.cloud.logging.handlers.handlers
2021
from google.cloud.logging.handlers.handlers import CloudLoggingHandler
@@ -28,6 +29,7 @@
2829
_RESOURCE_ID = unique_resource_id('-')
2930
DEFAULT_FILTER = 'logName:syslog AND severity>=INFO'
3031
DEFAULT_DESCRIPTION = 'System testing'
32+
retry_429 = RetryErrors(TooManyRequests)
3133

3234

3335
def _retry_on_unavailable(exc):
@@ -291,7 +293,8 @@ def _init_storage_bucket(self):
291293
# Create the destination bucket, and set up the ACL to allow
292294
# Stackdriver Logging to write into it.
293295
storage_client = storage.Client()
294-
bucket = storage_client.create_bucket(BUCKET_NAME)
296+
bucket = storage_client.bucket(BUCKET_NAME)
297+
retry_429(bucket.create)()
295298
self.to_delete.append(bucket)
296299
bucket.acl.reload()
297300
logs_group = bucket.acl.group('cloud-logs@google.com')

0 commit comments

Comments
 (0)