Skip to content

Commit

Permalink
Merge pull request #2161 from dhermes/rate-limit-storage-buckets
Browse files Browse the repository at this point in the history
Adding 429 retry in storage for bucket create and delete.
  • Loading branch information
dhermes authored Aug 23, 2016
2 parents 9a6bf7f + ca74a4a commit 0a3b42e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions system_tests/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from retry import RetryErrors


retry_429 = RetryErrors(exceptions.TooManyRequests)
HTTP = httplib2.Http()
_helpers.PROJECT = TESTS_PROJECT

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


def tearDownModule():
Expand All @@ -65,7 +67,8 @@ def setUp(self):
def tearDown(self):
with Config.CLIENT.batch():
for bucket_name in self.case_buckets_to_delete:
Config.CLIENT.bucket(bucket_name).delete()
bucket = Config.CLIENT.bucket(bucket_name)
retry_429(bucket.delete)()

def test_create_bucket(self):
new_bucket_name = 'a-new-bucket' + unique_resource_id('-')
Expand All @@ -83,7 +86,8 @@ def test_list_buckets(self):
]
created_buckets = []
for bucket_name in buckets_to_create:
bucket = Config.CLIENT.create_bucket(bucket_name)
bucket = Config.CLIENT.bucket(bucket_name)
retry_429(bucket.create)()
self.case_buckets_to_delete.append(bucket_name)

# Retrieve the buckets.
Expand Down

0 comments on commit 0a3b42e

Please sign in to comment.