Skip to content

Commit

Permalink
Revert "Try to get the tests suite output streamed."
Browse files Browse the repository at this point in the history
This reverts commit 1ef452a.
  • Loading branch information
s0undt3ch committed Dec 9, 2013
1 parent 8ea7390 commit 363c9b8
Showing 1 changed file with 48 additions and 29 deletions.
77 changes: 48 additions & 29 deletions tests/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,47 @@ def run(opts):
opts.download_unittest_reports = vm_name

cmd = (
'salt-cloud -l debug --script-args "-D -n git {commit}" '
'--start-action \'-l debug state.sls {sls} pillar="{pillar}" '
'--no-color\' -p {provider}_{platform} {0}'.format(
vm_name,
'salt-cloud -l debug --script-args "-D -n git {commit}" -p '
'{provider}_{platform} {0}'.format(vm_name, **opts.__dict__)
)
print('Running CMD: {0}'.format(cmd))
sys.stdout.flush()

proc = Terminal(
cmd,
shell=True,
stream_stdout=True,
stream_stderr=True,
log_stderr=True,
log_stdout=True
)
while proc.isalive():
proc.recv()
time.sleep(0.025)

retcode = proc.exitstatus
if retcode != 0:
print('Failed to bootstrap VM. Exit code: {0}'.format(retcode))
sys.stdout.flush()
if opts.clean and 'JENKINS_SALTCLOUD_VM_NAME' not in os.environ:
delete_vm(vm_name)
sys.exit(retcode)

print('VM Bootstrapped. Exit code: {0}'.format(retcode))
sys.stdout.flush()

print('Sleeping for 5 seconds to allow the minion to breathe a little')
sys.stdout.flush()
time.sleep(5)

# Run tests here
cmd = (
'salt -t 1800 {vm_name} state.sls {sls} pillar="{pillar}" '
'--no-color'.format(
sls=opts.sls,
pillar=opts.pillar.format(commit=opts.commit),
**opts.__dict__
vm_name=vm_name,
commit=opts.commit
)
)
print('Running CMD: {0}'.format(cmd))
Expand All @@ -259,36 +293,27 @@ def run(opts):
log_stderr=True,
log_stdout=True
)

exiting = False
suite_retcode = None
while True:
stdout, _ = proc.recv(4096)
if stdout and suite_retcode is None:
retcode = None
while proc.isalive():
stdout, _ = proc.recv()
if stdout and retcode is None:
try:
match = re.search(r'Test Suite Exit Code: (?P<exitcode>[\d]+)',
stdout)
if match:
suite_retcode = int(match.group('exitcode'))
retcode = int(match.group('exitcode'))
except AttributeError:
# No regex matching
suite_retcode = 1
retcode = 1
except ValueError:
# Not a number!?
suite_retcode = 1
retcode = 1
except TypeError:
# No output!?
suite_retcode = 1
retcode = 1
if stdout:
# Anything else, raise the exception
raise

if exiting is True:
break

if not proc.isalive:
exiting = True

time.sleep(0.025)

if opts.download_remote_reports:
Expand All @@ -298,13 +323,7 @@ def run(opts):
download_coverage_report(opts)

if opts.clean and 'JENKINS_SALTCLOUD_VM_NAME' not in os.environ:
delete_vm(opts)

retcode = proc.exitstatus
if suite_retcode == 0 and retcode == 0:
return 0
if suite_retcode > 0:
return suite_retcode
delete_vm(vm_name)
return retcode


Expand Down

0 comments on commit 363c9b8

Please sign in to comment.