Skip to content

Commit

Permalink
test: add retry in pytest fixtures (#1108)
Browse files Browse the repository at this point in the history
  • Loading branch information
cojenco committed Aug 9, 2023
1 parent d9b2065 commit 7f741b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions tests/system/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ def empty_bucket(bucket):


def delete_blob(blob):
errors = (exceptions.Conflict, exceptions.TooManyRequests)
errors = (
exceptions.Conflict,
exceptions.TooManyRequests,
exceptions.ServiceUnavailable,
)
retry = RetryErrors(errors)
try:
retry(blob.delete)(timeout=120) # seconds
Expand All @@ -105,7 +109,11 @@ def delete_blob(blob):


def delete_bucket(bucket):
errors = (exceptions.Conflict, exceptions.TooManyRequests)
errors = (
exceptions.Conflict,
exceptions.TooManyRequests,
exceptions.ServiceUnavailable,
)
retry = RetryErrors(errors, max_tries=15)
retry(empty_bucket)(bucket)
retry(bucket.delete)(force=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/system/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ def test_new_bucket_with_autoclass(

# Autoclass can be enabled/disabled via bucket patch
bucket.autoclass_enabled = False
bucket.patch()
bucket.patch(if_metageneration_match=bucket.metageneration)

assert bucket.autoclass_enabled is False
assert bucket.autoclass_toggle_time != previous_toggle_time

0 comments on commit 7f741b0

Please sign in to comment.