piotr-szuberski commented on a change in pull request #12406:
URL: https://github.com/apache/beam/pull/12406#discussion_r462771399



##########
File path: sdks/python/apache_beam/io/external/xlang_jdbcio_it_test.py
##########
@@ -91,7 +90,12 @@ def setUp(self):
         self.host, self.port, self.database_name)
 
   def tearDown(self):
-    self.postgres.stop()
+    # Sometimes stopping the container raises ReadTimeout. We can ignore it
+    # here to avoid the test failure.
+    try:
+      self.postgres.stop()
+    except:  # pylint: disable=bare-except

Review comment:
       Yes, I think so. Done.

##########
File path: sdks/python/apache_beam/io/external/xlang_jdbcio_it_test.py
##########
@@ -150,6 +154,18 @@ def test_xlang_jdbc_read(self):
       assert_that(
           result, equal_to([JdbcReadTestRow(i) for i in range(ROW_COUNT)]))
 
+  # Creating a container with testcontainers sometimes raises ReadTimeout
+  # error. In java there are 2 retries set by default.
+  def start_postgres_container(self, retries):
+    for i in range(retries):
+      try:
+        self.postgres = PostgresContainer('postgres:12.3')
+        self.postgres.start()
+        break
+      except:  # pylint: disable=bare-except
+        if i == retries - 1:
+          raise RuntimeError('Unable to initialize postgres container.')

Review comment:
       I added the log and reraised the exception cause.

##########
File path: sdks/python/apache_beam/io/external/xlang_jdbcio_it_test.py
##########
@@ -150,6 +154,18 @@ def test_xlang_jdbc_read(self):
       assert_that(
           result, equal_to([JdbcReadTestRow(i) for i in range(ROW_COUNT)]))
 
+  # Creating a container with testcontainers sometimes raises ReadTimeout
+  # error. In java there are 2 retries set by default.
+  def start_postgres_container(self, retries):
+    for i in range(retries):
+      try:
+        self.postgres = PostgresContainer('postgres:12.3')
+        self.postgres.start()
+        break
+      except:  # pylint: disable=bare-except
+        if i == retries - 1:
+          raise RuntimeError('Unable to initialize postgres container.')

Review comment:
       I added the log and reraised the primary exception.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to