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

jscheffl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 89322f157de Fix flaky SSH test_command_timeout_fail on loaded CI 
runners (#67829)
89322f157de is described below

commit 89322f157de5a8e2abc6ef97568d121679f28b3d
Author: Jarek Potiuk <[email protected]>
AuthorDate: Mon Jun 1 22:15:27 2026 +0200

    Fix flaky SSH test_command_timeout_fail on loaded CI runners (#67829)
    
    The test set cmd_timeout=0.001, which the hook forwards to paramiko's
    exec_command. paramiko uses that value to open the channel as well as to
    read command output, so on a loaded runner opening the channel exceeds
    1ms and raises SSHException("Timeout opening channel.") before the
    hook's command-timeout logic runs, instead of the expected
    AirflowException.
    
    Use a cmd_timeout large enough to reliably open the channel (0.5s) and a
    longer command so the read loop is what times out, keeping the test on
    its intended AirflowException path.
---
 providers/ssh/tests/unit/ssh/hooks/test_ssh.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/providers/ssh/tests/unit/ssh/hooks/test_ssh.py 
b/providers/ssh/tests/unit/ssh/hooks/test_ssh.py
index 74652cd3258..289cdfa3e48 100644
--- a/providers/ssh/tests/unit/ssh/hooks/test_ssh.py
+++ b/providers/ssh/tests/unit/ssh/hooks/test_ssh.py
@@ -791,10 +791,15 @@ class TestSSHHook:
             assert ret == (0, b"airflow\n", b"")
 
     def test_command_timeout_fail(self):
+        # cmd_timeout is forwarded to paramiko's exec_command, which uses it 
both to open the
+        # channel and to read the command output. It must therefore be large 
enough to reliably
+        # open the channel (otherwise a loaded runner raises "Timeout opening 
channel." instead of
+        # the AirflowException we expect) while staying smaller than the 
command runtime so the
+        # read loop times out. A sub-millisecond timeout makes channel opening 
flaky.
         hook = SSHHook(
             ssh_conn_id="ssh_default",
             conn_timeout=30,
-            cmd_timeout=0.001,
+            cmd_timeout=0.5,
             banner_timeout=100,
         )
 
@@ -802,7 +807,7 @@ class TestSSHHook:
             with pytest.raises(AirflowException):
                 hook.exec_ssh_client_command(
                     client,
-                    "sleep 1",
+                    "sleep 5",
                     False,
                     None,
                 )

Reply via email to