-
Notifications
You must be signed in to change notification settings - Fork 17.3k
SSHOperator - Restore ability to override SSHHook cmd_timeout #30190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -974,24 +974,6 @@ def test_exec_ssh_client_command(self): | |
| ) | ||
| assert ret == (0, b"airflow\n", b"") | ||
|
|
||
| @pytest.mark.flaky(reruns=5) | ||
| def test_command_timeout_default(self): | ||
| hook = SSHHook( | ||
| ssh_conn_id="ssh_default", | ||
| conn_timeout=30, | ||
| banner_timeout=100, | ||
| ) | ||
|
|
||
| with hook.get_conn() as client: | ||
| with pytest.raises(AirflowException): | ||
| hook.exec_ssh_client_command( | ||
| client, | ||
| "sleep 10", | ||
| False, | ||
| None, | ||
| 1, | ||
| ) | ||
|
|
||
| @pytest.mark.flaky(reruns=5) | ||
| def test_command_timeout_success(self): | ||
| hook = SSHHook( | ||
|
|
@@ -1028,6 +1010,24 @@ def test_command_timeout_fail(self): | |
| None, | ||
| ) | ||
|
|
||
| def test_command_timeout_not_set(self): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this illustrates how to set infinite timeout
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like with your changes when
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correct, you can set it to |
||
| hook = SSHHook( | ||
| ssh_conn_id="ssh_default", | ||
| conn_timeout=30, | ||
| cmd_timeout=None, | ||
| banner_timeout=100, | ||
| ) | ||
|
|
||
| with hook.get_conn() as client: | ||
| # sleeping for 20 sec which is longer than default timeout of 10 seconds | ||
| # to validate that no timeout is applied | ||
| hook.exec_ssh_client_command( | ||
| client, | ||
| "sleep 20", | ||
| environment=False, | ||
| get_pty=None, | ||
| ) | ||
|
|
||
| @mock.patch("airflow.providers.ssh.hooks.ssh.paramiko.SSHClient") | ||
| def test_ssh_connection_with_no_host_key_check_true_and_allow_host_key_changes_true(self, ssh_mock): | ||
| hook = SSHHook(ssh_conn_id=self.CONN_SSH_WITH_NO_HOST_KEY_CHECK_TRUE_AND_ALLOW_HOST_KEY_CHANGES_TRUE) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted as it's basically the same test as
test_command_timeout_fail