This is an automated email from the ASF dual-hosted git repository.

damccorm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new ce1b1dcbc59 Fix flaky GCS bucket deletion in 
test_create_default_bucket (#36786)
ce1b1dcbc59 is described below

commit ce1b1dcbc596d1e7c914ee0f7b0d48f2d2bf87e1
Author: Abdelrahman Ibrahim <[email protected]>
AuthorDate: Thu Nov 13 16:02:37 2025 +0200

    Fix flaky GCS bucket deletion in test_create_default_bucket (#36786)
    
    * Handle NotFound exception in bucket deletion test
    
    * Added retry logic for bucket
---
 .../apache_beam/io/gcp/gcsio_integration_test.py   | 24 +++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/sdks/python/apache_beam/io/gcp/gcsio_integration_test.py 
b/sdks/python/apache_beam/io/gcp/gcsio_integration_test.py
index 4616f007bfc..fa204922198 100644
--- a/sdks/python/apache_beam/io/gcp/gcsio_integration_test.py
+++ b/sdks/python/apache_beam/io/gcp/gcsio_integration_test.py
@@ -242,9 +242,27 @@ class GcsIOIntegrationTest(unittest.TestCase):
     # verify soft delete policy is disabled by default in the default bucket
     # after creation
     self.assertEqual(bucket.soft_delete_policy.retention_duration_seconds, 0)
-    bucket.delete()
-
-    self.assertIsNone(self.gcsio.get_bucket(overridden_bucket_name))
+    max_retries = 5
+    retry_delay = 1
+    existing_bucket = None
+    for attempt in range(max_retries):
+      try:
+        existing_bucket = self.gcsio.get_bucket(overridden_bucket_name)
+        break
+      except NotFound:
+        if attempt < max_retries - 1:
+          time.sleep(retry_delay)
+          retry_delay *= 2
+        else:
+          existing_bucket = None
+    if existing_bucket:
+      try:
+        existing_bucket.delete()
+      except NotFound:
+        pass
+    time.sleep(WAIT_BUCKET_PROPAGATION_SECONDS)
+    with self.assertRaises(NotFound):
+      self.gcsio.get_bucket(overridden_bucket_name)
 
 
 class GcsIOReadGzipTest(unittest.TestCase):

Reply via email to