From 11e482252b27c4318f8f046846dc3a07324ac44c Mon Sep 17 00:00:00 2001 From: Vladimir Domnich Date: Thu, 28 Jul 2022 19:03:26 +0300 Subject: [PATCH] Increase ssh timeout. --- pytest_tests/helpers/ssh_helper.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pytest_tests/helpers/ssh_helper.py b/pytest_tests/helpers/ssh_helper.py index e76d47b..dad4c94 100644 --- a/pytest_tests/helpers/ssh_helper.py +++ b/pytest_tests/helpers/ssh_helper.py @@ -61,7 +61,7 @@ class SSHCommand: class HostClient: ssh_client: SSHClient SSH_CONNECTION_ATTEMPTS: ClassVar[int] = 3 - CONNECTION_TIMEOUT = 30 + CONNECTION_TIMEOUT = 90 TIMEOUT_RESTORE_CONNECTION = 10, 24 @@ -74,15 +74,15 @@ class HostClient: if init_ssh_client: self.create_connection(self.SSH_CONNECTION_ATTEMPTS) - def exec(self, cmd: str, verify=True, timeout=30) -> SSHCommand: + def exec(self, cmd: str, verify=True, timeout=90) -> SSHCommand: cmd_result = self._inner_exec(cmd, timeout) if verify: assert cmd_result.rc == 0, f'Non zero rc from command: "{cmd}"' return cmd_result @log_command - def exec_with_confirmation(self, cmd: str, confirmation: list, verify=True, timeout=10) -> SSHCommand: - if self.login and self.login != "root": + def exec_with_confirmation(self, cmd: str, confirmation: list, verify=True, timeout=90) -> SSHCommand: + if self.login != "root": cmd = f"sudo {cmd}" ssh_stdin, ssh_stdout, ssh_stderr = self.ssh_client.exec_command(cmd, timeout=timeout) for line in confirmation: @@ -197,7 +197,7 @@ class HostClient: def _inner_exec(self, cmd: str, timeout: int) -> SSHCommand: if not self.ssh_client: self.create_connection() - if self.login and self.login != "root": + if self.login != "root": cmd = f"sudo {cmd}" for _ in range(self.SSH_CONNECTION_ATTEMPTS): try: