From 9f0c4830d0d53fda99e4a856099019efea11b177 Mon Sep 17 00:00:00 2001 From: Sergey Orlov Date: Fri, 19 Mar 2021 16:02:34 +0100 Subject: [PATCH] ipatests: allocate pseudo-terminal only for specific command While "ktutil" does require a pseudo-terminal on particular systems to operate, majority of programs do not need it. At the same time invoking `ssh` with forced pseudo-terminal allocation interferes with sessions multiplexing feature and increases connection time. The increase can be as large as 10 seconds in certain cases which leads to unexpected EOFs of pexpect utility. Reviewed-By: Florence Blanc-Renaud --- ipatests/pytest_ipa/integration/host.py | 8 +++++--- ipatests/pytest_ipa/integration/tasks.py | 3 ++- ipatests/pytest_ipa/integration/transport.py | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ipatests/pytest_ipa/integration/host.py b/ipatests/pytest_ipa/integration/host.py index 1e420dfee..a9758e7dc 100644 --- a/ipatests/pytest_ipa/integration/host.py +++ b/ipatests/pytest_ipa/integration/host.py @@ -206,9 +206,11 @@ class Host(pytest_multihost.host.Host): else: return result - def spawn_expect(self, argv, default_timeout=10, encoding='utf-8'): - """Run command on host using IpaTestExpect""" - return self.transport.spawn_expect(argv, default_timeout, encoding) + def spawn_expect(self, argv, default_timeout=10, encoding='utf-8', + extra_ssh_options=None): + """Run command on remote host using IpaTestExpect""" + return self.transport.spawn_expect(argv, default_timeout, encoding, + extra_ssh_options) class WinHost(pytest_multihost.host.WinHost): """ diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py index 023179a1e..8c4dd9553 100755 --- a/ipatests/pytest_ipa/integration/tasks.py +++ b/ipatests/pytest_ipa/integration/tasks.py @@ -2252,7 +2252,8 @@ class KerberosKeyCopier: mtime_before = get_keytab_mtime() - with self.host.spawn_expect(paths.KTUTIL, default_timeout=5) as e: + with self.host.spawn_expect(paths.KTUTIL, default_timeout=5, + extra_ssh_options=['-t']) as e: e.expect_exact('ktutil:') e.sendline('rkt {}'.format(keytab)) e.expect_exact('ktutil:') diff --git a/ipatests/pytest_ipa/integration/transport.py b/ipatests/pytest_ipa/integration/transport.py index f12df1225..61aba86b6 100644 --- a/ipatests/pytest_ipa/integration/transport.py +++ b/ipatests/pytest_ipa/integration/transport.py @@ -49,9 +49,11 @@ class IPAOpenSSHTransport(OpenSSHTransport): return argv - def spawn_expect(self, argv, default_timeout, encoding): + def spawn_expect(self, argv, default_timeout, encoding, extra_ssh_options): self.log.debug('Starting pexpect ssh session') if isinstance(argv, str): argv = [argv] - argv = self._get_ssh_argv() + ['-t', '-q'] + argv + if extra_ssh_options is None: + extra_ssh_options = [] + argv = self._get_ssh_argv() + ['-q'] + extra_ssh_options + argv return IpaTestExpect(argv, default_timeout, encoding)