From 7eb3177fe1ebee59266e51fed4c3d799bb60c712 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 12 Sep 2016 15:19:14 -0700 Subject: [PATCH] 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. --- system_tests/logging_.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/system_tests/logging_.py b/system_tests/logging_.py index a4dca1911dc0..3ba39edc8912 100644 --- a/system_tests/logging_.py +++ b/system_tests/logging_.py @@ -15,6 +15,7 @@ import logging import unittest +from google.cloud.exceptions import TooManyRequests import google.cloud.logging import google.cloud.logging.handlers.handlers from google.cloud.logging.handlers.handlers import CloudLoggingHandler @@ -28,6 +29,7 @@ _RESOURCE_ID = unique_resource_id('-') DEFAULT_FILTER = 'logName:syslog AND severity>=INFO' DEFAULT_DESCRIPTION = 'System testing' +retry_429 = RetryErrors(TooManyRequests) def _retry_on_unavailable(exc): @@ -291,7 +293,8 @@ def _init_storage_bucket(self): # Create the destination bucket, and set up the ACL to allow # Stackdriver Logging to write into it. storage_client = storage.Client() - bucket = storage_client.create_bucket(BUCKET_NAME) + bucket = storage_client.bucket(BUCKET_NAME) + retry_429(bucket.create)() self.to_delete.append(bucket) bucket.acl.reload() logs_group = bucket.acl.group('cloud-logs@google.com')