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
1=== modified file 'utah/run.py'
2--- utah/run.py 2012-08-16 13:12:51 +0000
3+++ utah/run.py 2012-08-28 03:04:20 +0000
4@@ -29,46 +29,31 @@
5 machine.installclient()
6 for runlist in args.runlists:
7 locallist = urllib.urlretrieve(runlist)[0]
8+ machine.uploadfiles([locallist], os.path.normpath('/tmp'))
9+
10+ options = ' -r /tmp/' + os.path.basename(locallist)
11+ utah_command = 'utah' + extraopts + options
12+ try:
13+ returncode, stdout, stderr = machine.run(utah_command)
14+ if returncode != 0:
15+ machine.logger.error('utah failed with return code: {}\n'
16+ .format(returncode))
17+ exitstatus = 1
18+ break
19+ except UTAHException as error:
20+ machine.logger.error('Failed to run test: ' + str(error))
21+ exitstatus = 1
22+ break
23+
24 listname = os.path.basename(runlist)
25- remotelog = os.path.join(config.logpath,
26- machine.name + '_' + listname + '_tmp')
27- remotelog = os.path.normpath(remotelog)
28 locallog = os.path.join(config.logpath,
29 machine.name + '_' + listname
30 + time.strftime('_%Y-%m-%d_%H-%m-%S', time.gmtime())
31 + suffix)
32 locallog = os.path.normpath(locallog)
33- try:
34- machine.uploadfiles([locallist], os.path.normpath('/tmp'))
35- options = (' -r /tmp/' + os.path.basename(locallist)
36- + ' -o ' + remotelog)
37- utah_command = 'utah' + extraopts + options
38- try:
39- returncode = machine.run(utah_command, root=True)[0]
40- if returncode != 0:
41- machine.logger.error('utah failed with return code: {}\n'
42- .format(returncode))
43- exitstatus = 1
44- break
45- except UTAHException as error:
46- machine.logger.error('Failed to run test: ' + str(error))
47- exitstatus = 1
48-
49- try:
50- machine.downloadfiles([remotelog], locallog)
51- except IOError as error:
52- machine.logger.error('Failed to download results: '
53- + str(error))
54- exitstatus = 1
55- else:
56- machine.logger.error('Test log copied to ' + locallog)
57- locallogs.append(locallog)
58- finally:
59- try:
60- machine.run('rm -f ' + remotelog)
61- except UTAHException as error:
62- machine.logger.error('Failed to cleanup test: ' + str(error))
63- if exitstatus != 0:
64- break
65+ with open(locallog, 'w') as f:
66+ f.write(stdout)
67+ machine.logger.info('Test log copied to ' + locallog)
68+ locallogs.append(locallog)
69
70 return exitstatus, locallogs

Subscribers

People subscribed via source and target branches