WIP salt-jenkins issue 1000

This adds logging of the output and retcode when the output file fails
to be created. As I have thus far been unable to reproduce this locally,
this is the best shot at seeing what is causing the issue, since
ShellCase's run_script is rather opaque about what happens in the script
itself. We do know from the salt-runtests.log that the `salt-call -g` is
successfully returning, what we don't know is what happened after that
data was returned, and this should provide that insight.
This commit is contained in:
Erik Johnson 2018-05-30 10:01:14 -05:00
parent da6f7a5538
commit 25afc932f7
No known key found for this signature in database
GPG key ID: 5E5583C437808F3F
2 changed files with 21 additions and 3 deletions

View file

@ -408,7 +408,7 @@ class CallTest(ShellCase, testprogram.TestProgramCase, ShellCaseCommonTestsMixin
with salt.utils.files.set_umask(0o077):
try:
# Let's create an initial output file with some data
self.run_script(
stdout, stderr, retcode = self.run_script(
'salt-call',
'-c {0} --output-file={1} -g'.format(
self.get_config_dir(),
@ -417,7 +417,20 @@ class CallTest(ShellCase, testprogram.TestProgramCase, ShellCaseCommonTestsMixin
catch_stderr=True,
with_retcode=True
)
stat1 = os.stat(output_file)
try:
stat1 = os.stat(output_file)
except OSError:
log.error(
'run_script failed to generate output file:\n'
'return code %d\n'
'stdout:\n'
'%s\n\n'
'stderr\n'
'%s',
retcode, stdout, stderr
)
self.fail(
'Failed to generate output file, see log for details')
# Let's change umask
os.umask(0o777) # pylint: disable=blacklisted-function

View file

@ -98,10 +98,15 @@ class ShellTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
script_name
)
)
sfh.write(
contents = (
'#!{0}\n'.format(sys.executable) +
'\n'.join(script_template).format(script_name.replace('salt-', ''))
)
sfh.write(contents)
log.debug(
'Wrote the following contents to temp script %s:\n%s',
script_path, contents
)
st = os.stat(script_path)
os.chmod(script_path, st.st_mode | stat.S_IEXEC)