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 <frenaud@redhat.com>
This commit is contained in:
Sergey Orlov 2021-03-19 16:02:34 +01:00 committed by Alexander Bokovoy
parent 83e16a4e47
commit ae533e2998
3 changed files with 11 additions and 6 deletions

View File

@ -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):
"""

View File

@ -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:')

View File

@ -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)