You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by vt...@apache.org on 2025/08/01 12:56:00 UTC

(beam) 01/01: Add more retries for starting Redis test container

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

vterentev pushed a commit to branch fix-redis-testcontainer
in repository https://gitbox.apache.org/repos/asf/beam.git

commit d6073a9dbc809b3b845d6fa71e6998d8e4bf6ddf
Author: Vitaly Terentyev <vi...@akvelon.com>
AuthorDate: Fri Aug 1 16:55:42 2025 +0400

    Add more retries for starting Redis test container
---
 sdks/python/apache_beam/io/requestresponse_it_test.py    | 14 ++++++++++++--
 .../transforms/enrichment_handlers/bigquery_it_test.py   | 14 ++++++++++++--
 .../transforms/enrichment_handlers/bigtable_it_test.py   | 14 ++++++++++++--
 .../vertex_ai_feature_store_it_test.py                   | 16 +++++++++++++---
 4 files changed, 49 insertions(+), 9 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..9708c188ba6 100644
--- a/sdks/python/apache_beam/io/requestresponse_it_test.py
+++ b/sdks/python/apache_beam/io/requestresponse_it_test.py
@@ -206,7 +206,7 @@ class FakeCallerForCache(Caller[str, str]):
 @pytest.mark.uses_testcontainer
 class TestRedisCache(unittest.TestCase):
   def setUp(self) -> None:
-    self.retries = 3
+    self.retries = 10
     self._start_container()
 
   def test_rrio_cache_all_miss(self):
@@ -288,7 +288,8 @@ class TestRedisCache(unittest.TestCase):
       res.wait_until_finish()
 
   def tearDown(self) -> None:
-    self.container.stop()
+    if hasattr(self, 'container') and self.container:
+      self.container.stop()
 
   def _start_container(self):
     for i in range(self.retries):
@@ -298,6 +299,15 @@ class TestRedisCache(unittest.TestCase):
         self.host = self.container.get_container_host_ip()
         self.port = self.container.get_exposed_port(6379)
         self.client = self.container.get_client()
+
+        # Ping Redis to ensure it's ready
+        for _ in range(10):
+          try:
+            if self.client.ping():
+              break
+          except Exception:
+            time.sleep(0.5)
+
         break
       except Exception as e:
         if i == self.retries - 1:
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..6b57f04a15e 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 = 10
     self._start_container()
 
   def _start_container(self):
@@ -151,6 +151,15 @@ class TestBigQueryEnrichmentIT(BigQueryEnrichmentIT):
         self.host = self.container.get_container_host_ip()
         self.port = self.container.get_exposed_port(6379)
         self.client = self.container.get_client()
+
+        # Ping Redis to ensure it's ready
+        for _ in range(10):
+          try:
+            if self.client.ping():
+              break
+          except Exception:
+            time.sleep(0.5)
+
         break
       except Exception as e:
         if i == self.retries - 1:
@@ -160,7 +169,8 @@ class TestBigQueryEnrichmentIT(BigQueryEnrichmentIT):
           raise e
 
   def tearDown(self) -> None:
-    self.container.stop()
+    if hasattr(self, 'container') and self.container:
+      self.container.stop()
     self.client = None
 
   def test_bigquery_enrichment(self):
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..a22f0a035af 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
@@ -167,7 +167,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 = 10
     self._start_container()
 
   def _start_container(self):
@@ -178,6 +178,15 @@ class TestBigTableEnrichment(unittest.TestCase):
         self.host = self.container.get_container_host_ip()
         self.port = self.container.get_exposed_port(6379)
         self.client = self.container.get_client()
+
+        # Ping Redis to ensure it's ready
+        for _ in range(10):
+          try:
+            if self.client.ping():
+              break
+          except Exception:
+            time.sleep(0.5)
+
         break
       except Exception as e:
         if i == self.retries - 1:
@@ -185,7 +194,8 @@ class TestBigTableEnrichment(unittest.TestCase):
           raise e
 
   def tearDown(self) -> None:
-    self.container.stop()
+    if hasattr(self, 'container') and self.container:
+      self.container.stop()
     self.table = None
 
   def test_enrichment_with_bigtable(self):
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..e7b4d57b9f9 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
@@ -71,17 +71,26 @@ 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 = 10
     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()
         self.host = self.container.get_container_host_ip()
         self.port = self.container.get_exposed_port(6379)
         self.client = self.container.get_client()
+
+        # Ping Redis to ensure it's ready
+        for _ in range(10):
+          try:
+            if self.client.ping():
+              break
+          except Exception:
+            time.sleep(0.5)
+
         break
       except Exception as e:
         if i == self.retries - 1:
@@ -89,7 +98,8 @@ class TestVertexAIFeatureStoreHandler(unittest.TestCase):
           raise e
 
   def tearDown(self) -> None:
-    self.container.stop()
+    if hasattr(self, 'container') and self.container:
+      self.container.stop()
     self.client = None
 
   def test_vertex_ai_feature_store_bigtable_serving_enrichment(self):