From 6dbea8fd502671a526eec8a66dde75461a5bf7c9 Mon Sep 17 00:00:00 2001 From: Cathy Ouyang Date: Wed, 9 Aug 2023 10:47:59 -0700 Subject: [PATCH] test: add retry in pytest fixtures --- tests/system/_helpers.py | 12 ++++++++++-- tests/system/test_bucket.py | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/system/_helpers.py b/tests/system/_helpers.py index 385ceaf5c..e298d7932 100644 --- a/tests/system/_helpers.py +++ b/tests/system/_helpers.py @@ -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 @@ -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) diff --git a/tests/system/test_bucket.py b/tests/system/test_bucket.py index 3fe909c7e..ac949cf96 100644 --- a/tests/system/test_bucket.py +++ b/tests/system/test_bucket.py @@ -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