mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add catch_timeout to run_script
One of the tests depends on forcing a timeout, but since we no longer include the timeout message in the stdout/stderr return, we needed a way to return whether or not the script timed out.
This commit is contained in:
parent
551ada8e4d
commit
41e5a75027
2 changed files with 6 additions and 6 deletions
|
@ -233,20 +233,17 @@ class CallTest(ShellCase, testprogram.TestProgramCase, ShellCaseCommonTestsMixin
|
|||
with salt.utils.files.fopen(minion_config_file, 'w') as fh_:
|
||||
salt.utils.yaml.safe_dump(minion_config, fh_, default_flow_style=False)
|
||||
|
||||
out = self.run_script(
|
||||
_, timed_out = self.run_script(
|
||||
'salt-call',
|
||||
'--config-dir {0} cmd.run "echo foo"'.format(
|
||||
config_dir
|
||||
),
|
||||
timeout=timeout,
|
||||
catch_timeout=True,
|
||||
)
|
||||
|
||||
try:
|
||||
self.assertIn(
|
||||
'Process took more than {0} seconds to complete. '
|
||||
'Process Killed!'.format(timeout),
|
||||
out
|
||||
)
|
||||
self.assertTrue(timed_out)
|
||||
except AssertionError:
|
||||
if os.path.isfile(minion_config_file):
|
||||
os.unlink(minion_config_file)
|
||||
|
|
|
@ -245,6 +245,7 @@ class ShellTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
|||
arg_str,
|
||||
catch_stderr=False,
|
||||
with_retcode=False,
|
||||
catch_timeout=False,
|
||||
# FIXME A timeout of zero or disabling timeouts may not return results!
|
||||
timeout=15,
|
||||
raw=False,
|
||||
|
@ -338,6 +339,8 @@ class ShellTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
|||
ret.append(stderr)
|
||||
if with_retcode:
|
||||
ret.append(retcode)
|
||||
if catch_timeout:
|
||||
ret.append(timed_out)
|
||||
|
||||
return ret[0] if len(ret) == 1 else tuple(ret)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue