Add timeout to ssh tests

This commit is contained in:
Mike Place 2016-07-27 10:40:02 -06:00
parent a83cdf9339
commit 443e5cdde2

View file

@ -1218,12 +1218,12 @@ class ShellCase(AdaptedConfigurationTestCaseMixIn, ShellTestCase):
arg_str = '-c {0} {1}'.format(self.get_config_dir(), arg_str)
return self.run_script('salt', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr)
def run_ssh(self, arg_str, with_retcode=False, catch_stderr=False):
def run_ssh(self, arg_str, with_retcode=False, catch_stderr=False, timeout=25):
'''
Execute salt-ssh
'''
arg_str = '-c {0} -i --priv {1} --roster-file {2} --out=json localhost {3}'.format(self.get_config_dir(), os.path.join(TMP_CONF_DIR, 'key_test'), os.path.join(TMP_CONF_DIR, 'roster'), arg_str)
return self.run_script('salt-ssh', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr, raw=True)
return self.run_script('salt-ssh', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr, timeout=timeout, raw=True)
def run_run(self, arg_str, with_retcode=False, catch_stderr=False, async=False, timeout=60, config_dir=None):
'''
@ -1356,7 +1356,7 @@ class SSHCase(ShellCase):
return '{0} {1}'.format(function, ' '.join(arg))
def run_function(self, function, arg=(), timeout=25, **kwargs):
ret = self.run_ssh(self._arg_str(function, arg))
ret = self.run_ssh(self._arg_str(function, arg), timeout=timeout)
try:
return json.loads(ret)['localhost']
except Exception: