You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2026/08/04 11:51:27 UTC

(kyuubi) 01/01: Retry connection-refused in PyHive test connect helper

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

pan3793 pushed a commit to branch fix-pyhive-test-description-flaky
in repository https://gitbox.apache.org/repos/asf/kyuubi.git

commit 5c4a3f5ac22df81e5663d638d5b5ab81e88a5cad
Author: Cheng Pan <ch...@apache.org>
AuthorDate: Tue Aug 4 19:51:11 2026 +0800

    Retry connection-refused in PyHive test connect helper
    
    Add TTransportException.NOT_OPEN to the retryable exception set so the
    startup race where HS2 has not bound port 10000 yet is also retried, not
    just the END_OF_FILE 0-byte-read at the SASL handshake.
    
    Assisted-by: GLM 5.2
---
 python/pyhive/tests/test_hive.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/python/pyhive/tests/test_hive.py b/python/pyhive/tests/test_hive.py
index a91027f603..94474be822 100644
--- a/python/pyhive/tests/test_hive.py
+++ b/python/pyhive/tests/test_hive.py
@@ -38,6 +38,7 @@ def _is_retryable_transport_exception(error):
     return error.type in (
         TTransportException.END_OF_FILE,
         TTransportException.TIMED_OUT,
+        TTransportException.NOT_OPEN,
     ) or 'TSocket read 0 bytes' in str(error)
 
 
@@ -69,6 +70,21 @@ class TestHive(unittest.TestCase, DBAPITestCase):
         self.assertEqual(connect.call_count, 2)
         sleep.assert_called_once_with(_CONNECT_RETRY_DELAY_SECONDS)
 
+    @mock.patch('pyhive.tests.test_hive.time.sleep')
+    @mock.patch('pyhive.tests.test_hive.hive.connect')
+    def test_connect_retries_connection_refused(self, connect, sleep):
+        connection = mock.sentinel.connection
+        connect.side_effect = [
+            TTransportException(
+                type=TTransportException.NOT_OPEN, message='Could not connect'),
+            connection,
+        ]
+
+        self.assertIs(self.connect(), connection)
+
+        self.assertEqual(connect.call_count, 2)
+        sleep.assert_called_once_with(_CONNECT_RETRY_DELAY_SECONDS)
+
     @mock.patch('pyhive.tests.test_hive.time.sleep')
     @mock.patch('pyhive.tests.test_hive.hive.connect')
     def test_connect_does_not_retry_non_transient_transport_failure(self, connect, sleep):