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:
Erik Johnson 2018-06-06 09:04:09 -05:00
parent 551ada8e4d
commit 41e5a75027
No known key found for this signature in database
GPG key ID: 5E5583C437808F3F
2 changed files with 6 additions and 6 deletions

View file

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

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