Skip to content

Commit

Permalink
Retry bucket creation on 503 responses. (#9248)
Browse files Browse the repository at this point in the history
Closes #9247.
  • Loading branch information
tseaver authored Sep 18, 2019
1 parent fe18948 commit 6988dd1
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions storage/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def setUpModule():
# fails with a ConnectionError.
Config.TEST_BUCKET = Config.CLIENT.bucket(bucket_name)
Config.TEST_BUCKET.versioning_enabled = True
retry_429(Config.TEST_BUCKET.create)()
retry_429_503(Config.TEST_BUCKET.create)()


def tearDownModule():
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_create_bucket(self):
self.assertRaises(
exceptions.NotFound, Config.CLIENT.get_bucket, new_bucket_name
)
created = retry_429(Config.CLIENT.create_bucket)(new_bucket_name)
created = retry_429_503(Config.CLIENT.create_bucket)(new_bucket_name)
self.case_buckets_to_delete.append(new_bucket_name)
self.assertEqual(created.name, new_bucket_name)

Expand All @@ -188,7 +188,7 @@ def test_lifecycle_rules(self):
),
]

retry_429(bucket.create)(location="us")
retry_429_503(bucket.create)(location="us")

self.case_buckets_to_delete.append(new_bucket_name)
self.assertEqual(bucket.name, new_bucket_name)
Expand All @@ -208,7 +208,7 @@ def test_list_buckets(self):
created_buckets = []
for bucket_name in buckets_to_create:
bucket = Config.CLIENT.bucket(bucket_name)
retry_429(bucket.create)()
retry_429_503(bucket.create)()
self.case_buckets_to_delete.append(bucket_name)

# Retrieve the buckets.
Expand All @@ -220,7 +220,7 @@ def test_list_buckets(self):

def test_bucket_update_labels(self):
bucket_name = "update-labels" + unique_resource_id("-")
bucket = retry_429(Config.CLIENT.create_bucket)(bucket_name)
bucket = retry_429_503(Config.CLIENT.create_bucket)(bucket_name)
self.case_buckets_to_delete.append(bucket_name)
self.assertTrue(bucket.exists())

Expand All @@ -241,7 +241,7 @@ def test_bucket_update_labels(self):
@unittest.skipUnless(USER_PROJECT, "USER_PROJECT not set in environment.")
def test_crud_bucket_with_requester_pays(self):
new_bucket_name = "w-requester-pays" + unique_resource_id("-")
created = retry_429(Config.CLIENT.create_bucket)(
created = retry_429_503(Config.CLIENT.create_bucket)(
new_bucket_name, requester_pays=True
)
self.case_buckets_to_delete.append(new_bucket_name)
Expand Down Expand Up @@ -284,7 +284,7 @@ def test_crud_bucket_with_requester_pays(self):
@unittest.skipUnless(USER_PROJECT, "USER_PROJECT not set in environment.")
def test_bucket_acls_iam_with_user_project(self):
new_bucket_name = "acl-w-user-project" + unique_resource_id("-")
retry_429(Config.CLIENT.create_bucket)(new_bucket_name, requester_pays=True)
retry_429_503(Config.CLIENT.create_bucket)(new_bucket_name, requester_pays=True)
self.case_buckets_to_delete.append(new_bucket_name)

with_user_project = Config.CLIENT.bucket(
Expand Down Expand Up @@ -322,7 +322,7 @@ def test_bucket_acls_iam_with_user_project(self):
@unittest.skipUnless(USER_PROJECT, "USER_PROJECT not set in environment.")
def test_copy_existing_file_with_user_project(self):
new_bucket_name = "copy-w-requester-pays" + unique_resource_id("-")
created = retry_429(Config.CLIENT.create_bucket)(
created = retry_429_503(Config.CLIENT.create_bucket)(
new_bucket_name, requester_pays=True
)
self.case_buckets_to_delete.append(new_bucket_name)
Expand Down Expand Up @@ -354,7 +354,7 @@ def test_copy_existing_file_with_user_project(self):
def test_bucket_get_blob_with_user_project(self):
new_bucket_name = "w-requester-pays" + unique_resource_id("-")
data = b"DEADBEEF"
created = retry_429(Config.CLIENT.create_bucket)(
created = retry_429_503(Config.CLIENT.create_bucket)(
new_bucket_name, requester_pays=True
)
self.case_buckets_to_delete.append(new_bucket_name)
Expand Down Expand Up @@ -803,7 +803,7 @@ def setUpClass(cls):
cls.skipTest("Signing tests requires a service account credential")

bucket_name = "gcp-signing" + unique_resource_id()
cls.bucket = retry_429(Config.CLIENT.create_bucket)(bucket_name)
cls.bucket = retry_429_503(Config.CLIENT.create_bucket)(bucket_name)
cls.blob = cls.bucket.blob("README.txt")
cls.blob.upload_from_string(cls.BLOB_CONTENT)

Expand Down Expand Up @@ -1054,7 +1054,7 @@ def test_compose_replace_existing_blob(self):
@unittest.skipUnless(USER_PROJECT, "USER_PROJECT not set in environment.")
def test_compose_with_user_project(self):
new_bucket_name = "compose-user-project" + unique_resource_id("-")
created = retry_429(Config.CLIENT.create_bucket)(
created = retry_429_503(Config.CLIENT.create_bucket)(
new_bucket_name, requester_pays=True
)
try:
Expand Down Expand Up @@ -1129,7 +1129,7 @@ def test_rewrite_rotate_encryption_key(self):
def test_rewrite_add_key_with_user_project(self):
file_data = self.FILES["simple"]
new_bucket_name = "rewrite-key-up" + unique_resource_id("-")
created = retry_429(Config.CLIENT.create_bucket)(
created = retry_429_503(Config.CLIENT.create_bucket)(
new_bucket_name, requester_pays=True
)
try:
Expand Down Expand Up @@ -1158,7 +1158,7 @@ def test_rewrite_rotate_with_user_project(self):
BLOB_NAME = "rotating-keys"
file_data = self.FILES["simple"]
new_bucket_name = "rewrite-rotate-up" + unique_resource_id("-")
created = retry_429(Config.CLIENT.create_bucket)(
created = retry_429_503(Config.CLIENT.create_bucket)(
new_bucket_name, requester_pays=True
)
try:
Expand Down Expand Up @@ -1270,7 +1270,7 @@ def payload_format():

def test_notification_minimal(self):
new_bucket_name = "notification-minimal" + unique_resource_id("-")
bucket = retry_429(Config.CLIENT.create_bucket)(new_bucket_name)
bucket = retry_429_503(Config.CLIENT.create_bucket)(new_bucket_name)
self.case_buckets_to_delete.append(new_bucket_name)
self.assertEqual(list(bucket.list_notifications()), [])
notification = bucket.notification(self.TOPIC_NAME)
Expand All @@ -1286,7 +1286,7 @@ def test_notification_minimal(self):

def test_notification_explicit(self):
new_bucket_name = "notification-explicit" + unique_resource_id("-")
bucket = retry_429(Config.CLIENT.create_bucket)(new_bucket_name)
bucket = retry_429_503(Config.CLIENT.create_bucket)(new_bucket_name)
self.case_buckets_to_delete.append(new_bucket_name)
notification = bucket.notification(
self.TOPIC_NAME,
Expand All @@ -1309,7 +1309,7 @@ def test_notification_explicit(self):
@unittest.skipUnless(USER_PROJECT, "USER_PROJECT not set in environment.")
def test_notification_w_user_project(self):
new_bucket_name = "notification-minimal" + unique_resource_id("-")
retry_429(Config.CLIENT.create_bucket)(new_bucket_name, requester_pays=True)
retry_429_503(Config.CLIENT.create_bucket)(new_bucket_name, requester_pays=True)
self.case_buckets_to_delete.append(new_bucket_name)
with_user_project = Config.CLIENT.bucket(
new_bucket_name, user_project=USER_PROJECT
Expand Down Expand Up @@ -1531,7 +1531,7 @@ def test_bucket_w_retention_period(self):
period_secs = 10

new_bucket_name = "w-retention-period" + unique_resource_id("-")
bucket = retry_429(Config.CLIENT.create_bucket)(new_bucket_name)
bucket = retry_429_503(Config.CLIENT.create_bucket)(new_bucket_name)
self.case_buckets_to_delete.append(new_bucket_name)

bucket.retention_period = period_secs
Expand Down Expand Up @@ -1580,7 +1580,7 @@ def test_bucket_w_default_event_based_hold(self):
self.assertRaises(
exceptions.NotFound, Config.CLIENT.get_bucket, new_bucket_name
)
bucket = retry_429(Config.CLIENT.create_bucket)(new_bucket_name)
bucket = retry_429_503(Config.CLIENT.create_bucket)(new_bucket_name)
self.case_buckets_to_delete.append(new_bucket_name)

bucket.default_event_based_hold = True
Expand Down Expand Up @@ -1632,7 +1632,7 @@ def test_blob_w_temporary_hold(self):
self.assertRaises(
exceptions.NotFound, Config.CLIENT.get_bucket, new_bucket_name
)
bucket = retry_429(Config.CLIENT.create_bucket)(new_bucket_name)
bucket = retry_429_503(Config.CLIENT.create_bucket)(new_bucket_name)
self.case_buckets_to_delete.append(new_bucket_name)

blob_name = "test-blob"
Expand Down Expand Up @@ -1666,7 +1666,7 @@ def test_bucket_lock_retention_policy(self):
self.assertRaises(
exceptions.NotFound, Config.CLIENT.get_bucket, new_bucket_name
)
bucket = retry_429(Config.CLIENT.create_bucket)(new_bucket_name)
bucket = retry_429_503(Config.CLIENT.create_bucket)(new_bucket_name)
self.case_buckets_to_delete.append(new_bucket_name)

bucket.retention_period = period_secs
Expand Down Expand Up @@ -1703,7 +1703,7 @@ def test_new_bucket_w_bpo(self):
)
bucket = Config.CLIENT.bucket(new_bucket_name)
bucket.iam_configuration.bucket_policy_only_enabled = True
retry_429(bucket.create)()
retry_429_503(bucket.create)()
self.case_buckets_to_delete.append(new_bucket_name)

bucket_acl = bucket.acl
Expand Down Expand Up @@ -1738,7 +1738,7 @@ def test_bpo_set_unset_preserves_acls(self):
self.assertRaises(
exceptions.NotFound, Config.CLIENT.get_bucket, new_bucket_name
)
bucket = retry_429(Config.CLIENT.create_bucket)(new_bucket_name)
bucket = retry_429_503(Config.CLIENT.create_bucket)(new_bucket_name)
self.case_buckets_to_delete.append(new_bucket_name)

blob_name = "my-blob.txt"
Expand Down

0 comments on commit 6988dd1

Please sign in to comment.