Skip to content

Commit 0a3b42e

Browse files
authored
Merge pull request #2161 from dhermes/rate-limit-storage-buckets
Adding 429 retry in storage for bucket create and delete.
2 parents 9a6bf7f + ca74a4a commit 0a3b42e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

system_tests/storage.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from retry import RetryErrors
3131

3232

33+
retry_429 = RetryErrors(exceptions.TooManyRequests)
3334
HTTP = httplib2.Http()
3435
_helpers.PROJECT = TESTS_PROJECT
3536

@@ -49,7 +50,8 @@ def setUpModule():
4950
bucket_name = 'new' + unique_resource_id()
5051
# In the **very** rare case the bucket name is reserved, this
5152
# fails with a ConnectionError.
52-
Config.TEST_BUCKET = Config.CLIENT.create_bucket(bucket_name)
53+
Config.TEST_BUCKET = Config.CLIENT.bucket(bucket_name)
54+
retry_429(Config.TEST_BUCKET.create)()
5355

5456

5557
def tearDownModule():
@@ -65,7 +67,8 @@ def setUp(self):
6567
def tearDown(self):
6668
with Config.CLIENT.batch():
6769
for bucket_name in self.case_buckets_to_delete:
68-
Config.CLIENT.bucket(bucket_name).delete()
70+
bucket = Config.CLIENT.bucket(bucket_name)
71+
retry_429(bucket.delete)()
6972

7073
def test_create_bucket(self):
7174
new_bucket_name = 'a-new-bucket' + unique_resource_id('-')
@@ -83,7 +86,8 @@ def test_list_buckets(self):
8386
]
8487
created_buckets = []
8588
for bucket_name in buckets_to_create:
86-
bucket = Config.CLIENT.create_bucket(bucket_name)
89+
bucket = Config.CLIENT.bucket(bucket_name)
90+
retry_429(bucket.create)()
8791
self.case_buckets_to_delete.append(bucket_name)
8892

8993
# Retrieve the buckets.

0 commit comments

Comments
 (0)