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

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 801
Merged at revision: 798
Proposed branch: lp:~javier.collado/utah/bug1096848
Merge into: lp:utah
Diff against target: 99 lines (+31/-27)
1 file modified
utah/run.py (+31/-27)
To merge this branch: bzr merge lp:~javier.collado/utah/bug1096848
Reviewer Review Type Date Requested Status
Max Brustkern (community) Approve
Javier Collado (community) Needs Resubmitting
Review via email: mp+142461@code.launchpad.net

Description of the change

This branch addresses the issue of truncated report when getting it through the
ssh command standard output.

The issue seems to be related to the buffering in openssh which is set to 64kB.
To fix this, it would be possible to read the output in chunks to prevent the
buffer from becoming full.

The workaround used in this change is just write the file locally in the
machine where the client is being executed and then get the file with sftp
(that automatically handles this problem).

To verify the fix, I've run the ceph test case using a server amd64 image and
got a 199kB file with the complete report.

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

Did you test with the -j option? It looks to me like if you used that option, extraopts would be:
-f json--install-type desktop
(for a desktop install.) I'm going to try this and see, but it'll take a little bit.

review: Needs Information
Revision history for this message
Javier Collado (javier.collado) wrote :

Looking at the code, I think you're right. Let me review and fix it.

Revision history for this message
Max Brustkern (nuclearbob) wrote :

Yeah, this is what I saw in the log:
2013-01-10 09:55:24,097 utah-682-precise-amd64 INFO: Running command through SSH: utah -f json--install-type desktop -r /tmp/pass.run -o /tmp/pass.yaml

review: Needs Fixing
lp:~javier.collado/utah/bug1096848 updated
799. By Javier Collado

Fixed get installmachine from machine object

800. By Javier Collado

Removed extraopts line that was left

801. By Javier Collado

Fixed report type is used to set the extension of the report file

In the past even for json reports the file name had the '.yaml' extension.

Revision history for this message
Javier Collado (javier.collado) wrote :

Thanks for pointing out that problem.

Since for the client the -f/--format option can be used to specify either yaml
or json (being yaml the default), as opposed to the server in which the format
by default is yaml and -j/--json means json, I've decided to always set the -f
option when calling the client to make the code more explicit and less prone to
whitespace errors (as it happened to in this change).

I've tested it with/without the -j option in run_utah_tests.py and it worked
fine.

review: Needs Resubmitting
Revision history for this message
Max Brustkern (nuclearbob) wrote :

Looks good to me.

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 2013-01-07 13:00:38 +0000
3+++ utah/run.py 2013-01-10 18:29:22 +0000
4@@ -110,34 +110,45 @@
5 """
6 Run some tests and retrieve results.
7 """
8+ if args.json:
9+ report_type = 'json'
10+ else:
11+ report_type = 'yaml'
12+
13 def _run(runlist):
14 """Run a single runlist."""
15- stdout = None
16-
17 try:
18- locallist = urllib.urlretrieve(runlist)[0]
19- machine.uploadfiles([locallist], os.path.normpath('/tmp'))
20+ runlist_local_path = urllib.urlretrieve(runlist)[0]
21+ target_dir = os.path.normpath('/tmp')
22+ machine.uploadfiles([runlist_local_path], target_dir)
23
24- options = ' -r /tmp/' + os.path.basename(locallist)
25- utah_command = 'utah' + extraopts + options
26- exitstatus, stdout, _stderr = machine.run(utah_command, root=True)
27+ runlist_file = os.path.basename(runlist_local_path)
28+ runlist_remote_path = os.path.join(target_dir, runlist_file)
29+ runlist_name = os.path.splitext(runlist_file)[0]
30+ report_remote_path = \
31+ os.path.join(target_dir,
32+ '{}.{}'.format(runlist_name, report_type))
33+ options = '-r {} -o {}'.format(runlist_remote_path,
34+ report_remote_path)
35+ utah_command = 'utah {} {}'.format(extraopts, options)
36+ exitstatus, _stdout, _stderr = machine.run(utah_command, root=True)
37 except UTAHException as error:
38 machine.logger.error('Failed to run test: ' + str(error))
39 exitstatus = 1
40-
41- if stdout is not None:
42- _write(runlist, stdout)
43+ else:
44+ _write(runlist, report_remote_path)
45
46 return exitstatus
47
48- def _write(runlist, report):
49+ def _write(runlist, report_remote_path):
50 """Write runlist report.
51
52 Report will be written using appropriate filename based on the runlist.
53
54 :param runlist: Path to the runlist file
55 :type runlist: str
56- :param report: Report to be written in any of the supported formats.
57+ :param report_remote_path:
58+ Path to the report file in the machine being tested
59 :type report: str
60
61 """
62@@ -149,14 +160,13 @@
63 runlist=listname,
64 timestamp=timestamp,
65 suffix=report_type))
66- locallog = os.path.join(config.logpath, log_filename)
67- locallog = os.path.normpath(locallog)
68- with open(locallog, 'w') as f:
69- f.write(report)
70- machine.logger.info('Test log copied to ' + locallog)
71- locallogs.append(locallog)
72+ report_local_path = os.path.join(config.logpath, log_filename)
73+ report_local_path = os.path.normpath(report_local_path)
74+ machine.downloadfiles(report_remote_path, report_local_path)
75+ machine.logger.info('Test log copied to ' + report_local_path)
76+ locallogs.append(report_local_path)
77 if args.dumplogs:
78- with open(locallog, 'r') as f:
79+ with open(report_local_path, 'r') as f:
80 print(f.read())
81
82 # Since we're running from a script, output INFO
83@@ -167,14 +177,8 @@
84 # Write the machine name to standard out for log gathering
85 print('Running on machine: ' + machine.name)
86
87- if args.json:
88- extraopts = ' -f json'
89- report_type = 'json'
90-
91- else:
92- extraopts = ''
93- report_type = 'yaml'
94- extraopts += " --install-type " + machine.installtype
95+ extraopts = ('-f {} --install-type {}'
96+ .format(report_type, machine.installtype))
97
98 locallogs = []
99 try:

Subscribers

People subscribed via source and target branches