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

xqhu 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 5184b949dca fix(test): improve redis container startup reliability in 
tests (#35857)
5184b949dca is described below

commit 5184b949dcabc2134349ad80f086c7406e295868
Author: liferoad <[email protected]>
AuthorDate: Wed Aug 13 08:01:49 2025 -0400

    fix(test): improve redis container startup reliability in tests (#35857)
    
    * fix(test): improve redis container startup reliability in tests
    
    Add startup timeout and delay between retries to handle flaky redis 
container initialization. The changes apply to multiple test files that use 
RedisContainer for testing.
    
    * test: increase retry attempts and remove container timeout
    
    Increase retry attempts from 3 to 5 for Redis container startup across 
multiple test files. Remove redundant container startup timeout configuration 
as it's no longer needed.
    
    * use self.retries
---
 sdks/python/apache_beam/io/requestresponse_it_test.py              | 5 ++++-
 .../apache_beam/transforms/enrichment_handlers/bigquery_it_test.py | 4 +++-
 .../apache_beam/transforms/enrichment_handlers/bigtable_it_test.py | 5 ++++-
 .../enrichment_handlers/vertex_ai_feature_store_it_test.py         | 7 +++++--
 4 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/sdks/python/apache_beam/io/requestresponse_it_test.py 
b/sdks/python/apache_beam/io/requestresponse_it_test.py
index 712ccc7881d..8ac7cdb6f5f 100644
--- a/sdks/python/apache_beam/io/requestresponse_it_test.py
+++ b/sdks/python/apache_beam/io/requestresponse_it_test.py
@@ -17,6 +17,7 @@
 import base64
 import logging
 import sys
+import time
 import typing
 import unittest
 from dataclasses import dataclass
@@ -206,7 +207,7 @@ class FakeCallerForCache(Caller[str, str]):
 @pytest.mark.uses_testcontainer
 class TestRedisCache(unittest.TestCase):
   def setUp(self) -> None:
-    self.retries = 3
+    self.retries = 5
     self._start_container()
 
   def test_rrio_cache_all_miss(self):
@@ -303,6 +304,8 @@ class TestRedisCache(unittest.TestCase):
         if i == self.retries - 1:
           _LOGGER.error('Unable to start redis container for RRIO tests.')
           raise e
+        # Add a small delay between retries to avoid rapid successive failures
+        time.sleep(2)
 
 
 if __name__ == '__main__':
diff --git 
a/sdks/python/apache_beam/transforms/enrichment_handlers/bigquery_it_test.py 
b/sdks/python/apache_beam/transforms/enrichment_handlers/bigquery_it_test.py
index 5db3ff41890..1889b0845e6 100644
--- a/sdks/python/apache_beam/transforms/enrichment_handlers/bigquery_it_test.py
+++ b/sdks/python/apache_beam/transforms/enrichment_handlers/bigquery_it_test.py
@@ -140,7 +140,7 @@ class TestBigQueryEnrichmentIT(BigQueryEnrichmentIT):
 
   def setUp(self) -> None:
     self.condition_template = "id = {}"
-    self.retries = 3
+    self.retries = 5
     self._start_container()
 
   def _start_container(self):
@@ -158,6 +158,8 @@ class TestBigQueryEnrichmentIT(BigQueryEnrichmentIT):
               'Unable to start redis container for BigQuery '
               ' enrichment tests.')
           raise e
+        # Add a small delay between retries to avoid rapid successive failures
+        time.sleep(2)
 
   def tearDown(self) -> None:
     self.container.stop()
diff --git 
a/sdks/python/apache_beam/transforms/enrichment_handlers/bigtable_it_test.py 
b/sdks/python/apache_beam/transforms/enrichment_handlers/bigtable_it_test.py
index 2d7c7c74f2e..09d025b006a 100644
--- a/sdks/python/apache_beam/transforms/enrichment_handlers/bigtable_it_test.py
+++ b/sdks/python/apache_beam/transforms/enrichment_handlers/bigtable_it_test.py
@@ -17,6 +17,7 @@
 
 import datetime
 import logging
+import time
 import unittest
 from typing import NamedTuple
 from unittest.mock import MagicMock
@@ -167,7 +168,7 @@ class TestBigTableEnrichment(unittest.TestCase):
     instance = client.instance(self.instance_id)
     self.table = instance.table(self.table_id)
     create_rows(self.table)
-    self.retries = 3
+    self.retries = 5
     self._start_container()
 
   def _start_container(self):
@@ -183,6 +184,8 @@ class TestBigTableEnrichment(unittest.TestCase):
         if i == self.retries - 1:
           _LOGGER.error('Unable to start redis container for RRIO tests.')
           raise e
+        # Add a small delay between retries to avoid rapid successive failures
+        time.sleep(2)
 
   def tearDown(self) -> None:
     self.container.stop()
diff --git 
a/sdks/python/apache_beam/transforms/enrichment_handlers/vertex_ai_feature_store_it_test.py
 
b/sdks/python/apache_beam/transforms/enrichment_handlers/vertex_ai_feature_store_it_test.py
index cd031b4805e..d83f1010dd8 100644
--- 
a/sdks/python/apache_beam/transforms/enrichment_handlers/vertex_ai_feature_store_it_test.py
+++ 
b/sdks/python/apache_beam/transforms/enrichment_handlers/vertex_ai_feature_store_it_test.py
@@ -15,6 +15,7 @@
 # limitations under the License.
 #
 import logging
+import time
 import unittest
 from unittest.mock import MagicMock
 
@@ -71,11 +72,11 @@ class TestVertexAIFeatureStoreHandler(unittest.TestCase):
     self.entity_type_name = "entity_id"
     self.api_endpoint = "us-central1-aiplatform.googleapis.com"
     self.feature_ids = ['title', 'genres']
-    self.retries = 3
+    self.retries = 5
     self._start_container()
 
   def _start_container(self):
-    for i in range(3):
+    for i in range(self.retries):
       try:
         self.container = RedisContainer(image='redis:7.2.4')
         self.container.start()
@@ -87,6 +88,8 @@ class TestVertexAIFeatureStoreHandler(unittest.TestCase):
         if i == self.retries - 1:
           _LOGGER.error('Unable to start redis container for RRIO tests.')
           raise e
+        # Add a small delay between retries to avoid rapid successive failures
+        time.sleep(2)
 
   def tearDown(self) -> None:
     self.container.stop()

Reply via email to