Merge lp:~javier.collado/utah/bug1042510 into lp:utah

Proposed by Javier Collado
Status: Merged
Merged at revision: 661
Proposed branch: lp:~javier.collado/utah/bug1042510
Merge into: lp:utah
Diff against target: 70 lines (+20/-35)
1 file modified
utah/run.py (+20/-35)
To merge this branch: bzr merge lp:~javier.collado/utah/bug1042510
Reviewer Review Type Date Requested Status
Max Brustkern (community) Approve
Review via email: mp+121531@code.launchpad.net

Description of the change

This branch takes advantage of the fact that `SSHMixin.run` now returns the command `stdout` to get the output from `utah -r <runlist>` so that it can be printed to the log file as well.

In the past the log file was written to a remote file and downloaded to a local file. With this change, the `stdout` is captured through SSH and written to a local file directly.

To post a comment you must log in.
Revision history for this message
Max Brustkern (nuclearbob) wrote :

This is a great idea. I think it may solve another problem I'm having as well.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'utah/run.py'
--- utah/run.py 2012-08-16 13:12:51 +0000
+++ utah/run.py 2012-08-28 03:04:20 +0000
@@ -29,46 +29,31 @@
29 machine.installclient()29 machine.installclient()
30 for runlist in args.runlists:30 for runlist in args.runlists:
31 locallist = urllib.urlretrieve(runlist)[0]31 locallist = urllib.urlretrieve(runlist)[0]
32 machine.uploadfiles([locallist], os.path.normpath('/tmp'))
33
34 options = ' -r /tmp/' + os.path.basename(locallist)
35 utah_command = 'utah' + extraopts + options
36 try:
37 returncode, stdout, stderr = machine.run(utah_command)
38 if returncode != 0:
39 machine.logger.error('utah failed with return code: {}\n'
40 .format(returncode))
41 exitstatus = 1
42 break
43 except UTAHException as error:
44 machine.logger.error('Failed to run test: ' + str(error))
45 exitstatus = 1
46 break
47
32 listname = os.path.basename(runlist)48 listname = os.path.basename(runlist)
33 remotelog = os.path.join(config.logpath,
34 machine.name + '_' + listname + '_tmp')
35 remotelog = os.path.normpath(remotelog)
36 locallog = os.path.join(config.logpath,49 locallog = os.path.join(config.logpath,
37 machine.name + '_' + listname50 machine.name + '_' + listname
38 + time.strftime('_%Y-%m-%d_%H-%m-%S', time.gmtime())51 + time.strftime('_%Y-%m-%d_%H-%m-%S', time.gmtime())
39 + suffix)52 + suffix)
40 locallog = os.path.normpath(locallog)53 locallog = os.path.normpath(locallog)
41 try:54 with open(locallog, 'w') as f:
42 machine.uploadfiles([locallist], os.path.normpath('/tmp'))55 f.write(stdout)
43 options = (' -r /tmp/' + os.path.basename(locallist)56 machine.logger.info('Test log copied to ' + locallog)
44 + ' -o ' + remotelog)57 locallogs.append(locallog)
45 utah_command = 'utah' + extraopts + options
46 try:
47 returncode = machine.run(utah_command, root=True)[0]
48 if returncode != 0:
49 machine.logger.error('utah failed with return code: {}\n'
50 .format(returncode))
51 exitstatus = 1
52 break
53 except UTAHException as error:
54 machine.logger.error('Failed to run test: ' + str(error))
55 exitstatus = 1
56
57 try:
58 machine.downloadfiles([remotelog], locallog)
59 except IOError as error:
60 machine.logger.error('Failed to download results: '
61 + str(error))
62 exitstatus = 1
63 else:
64 machine.logger.error('Test log copied to ' + locallog)
65 locallogs.append(locallog)
66 finally:
67 try:
68 machine.run('rm -f ' + remotelog)
69 except UTAHException as error:
70 machine.logger.error('Failed to cleanup test: ' + str(error))
71 if exitstatus != 0:
72 break
7358
74 return exitstatus, locallogs59 return exitstatus, locallogs

Subscribers

People subscribed via source and target branches