Merge lp:~codehelp/lava-dispatcher/multinode-pep8 into lp:lava-dispatcher/multinode
- multinode-pep8
- Merge into multinode
Proposed by
Neil Williams
Status: | Merged |
---|---|
Approved by: | Neil Williams |
Approved revision: | 685 |
Merged at revision: | 661 |
Proposed branch: | lp:~codehelp/lava-dispatcher/multinode-pep8 |
Merge into: | lp:lava-dispatcher/multinode |
Prerequisite: | lp:~codehelp/lava-dispatcher/multinode |
Diff against target: |
570 lines (+96/-92) 7 files modified
lava/dispatcher/commands.py (+3/-2) lava_dispatcher/actions/deploy.py (+9/-9) lava_dispatcher/actions/launch_control.py (+10/-7) lava_dispatcher/actions/lava_test_shell.py (+29/-25) lava_dispatcher/device/master.py (+18/-20) lava_dispatcher/device/target.py (+2/-3) lava_dispatcher/lava_test_shell.py (+25/-26) |
To merge this branch: | bzr merge lp:~codehelp/lava-dispatcher/multinode-pep8 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Neil Williams | Approve | ||
Review via email: mp+175462@code.launchpad.net |
This proposal supersedes a proposal from 2013-07-17.
Commit message
Description of the change
Remaining PEP8 changes to match tip.
Includes the pending changes for group dispatcher - so that merge needs to happen first.
https:/
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lava/dispatcher/commands.py' |
2 | --- lava/dispatcher/commands.py 2013-06-21 15:53:31 +0000 |
3 | +++ lava/dispatcher/commands.py 2013-07-18 07:48:32 +0000 |
4 | @@ -82,7 +82,7 @@ |
5 | help="Test scenario file") |
6 | parser.add_argument( |
7 | "--target", |
8 | - default = None, |
9 | + default=None, |
10 | help="Run the job on a specific target device" |
11 | ) |
12 | |
13 | @@ -154,7 +154,8 @@ |
14 | exit(0) |
15 | if self.args.target is None: |
16 | if 'target' not in json_jobdata: |
17 | - logging.error("The job file does not specify a target device. You must specify one using the --target option.") |
18 | + logging.error("The job file does not specify a target device. " |
19 | + "You must specify one using the --target option.") |
20 | exit(1) |
21 | else: |
22 | json_jobdata['target'] = self.args.target |
23 | |
24 | === modified file 'lava_dispatcher/actions/deploy.py' |
25 | --- lava_dispatcher/actions/deploy.py 2013-07-03 10:44:31 +0000 |
26 | +++ lava_dispatcher/actions/deploy.py 2013-07-18 07:48:32 +0000 |
27 | @@ -56,9 +56,9 @@ |
28 | 'rootfstype': {'type': 'string', 'optional': True}, |
29 | 'bootloader': {'type': 'string', 'optional': True, 'default': 'u_boot'}, |
30 | 'role': {'type': 'string', 'optional': True}, |
31 | - }, |
32 | + }, |
33 | 'additionalProperties': False, |
34 | - } |
35 | + } |
36 | |
37 | @classmethod |
38 | def validate_parameters(cls, parameters): |
39 | @@ -85,9 +85,9 @@ |
40 | 'system': {'type': 'string'}, |
41 | 'data': {'type': 'string'}, |
42 | 'rootfstype': {'type': 'string', 'optional': True, 'default': 'ext4'}, |
43 | - }, |
44 | + }, |
45 | 'additionalProperties': False, |
46 | - } |
47 | + } |
48 | |
49 | def run(self, boot, system, data, rootfstype='ext4'): |
50 | self.client.deploy_linaro_android(boot, system, data, rootfstype) |
51 | @@ -98,12 +98,12 @@ |
52 | parameters_schema = { |
53 | 'type': 'object', |
54 | 'properties': { |
55 | - 'type': {'type': 'string', 'enum':['ubuntu', 'oe', 'android', 'fedora']}, |
56 | - }, |
57 | + 'type': {'type': 'string', 'enum': ['ubuntu', 'oe', 'android', 'fedora']}, |
58 | + }, |
59 | 'additionalProperties': False, |
60 | - } |
61 | + } |
62 | |
63 | - def run(self, type): |
64 | + def run(self, target_type): |
65 | device = self.client.target_device |
66 | device.boot_master_image() |
67 | - device.deployment_data = device.target_map[type] |
68 | + device.deployment_data = device.target_map[target_type] |
69 | |
70 | === modified file 'lava_dispatcher/actions/launch_control.py' |
71 | --- lava_dispatcher/actions/launch_control.py 2013-06-24 16:47:11 +0000 |
72 | +++ lava_dispatcher/actions/launch_control.py 2013-07-18 07:48:32 +0000 |
73 | @@ -37,7 +37,9 @@ |
74 | |
75 | |
76 | class GatherResultsError(Exception): |
77 | - def __init__(self, msg, bundles=[]): |
78 | + def __init__(self, msg, bundles=None): |
79 | + if not bundles: |
80 | + bundles = [] |
81 | super(GatherResultsError, self).__init__(msg) |
82 | self.bundles = bundles |
83 | |
84 | @@ -50,7 +52,8 @@ |
85 | #Fix it: it's going to be deleted after transition |
86 | if server.endswith("dashboard/"): |
87 | server = ''.join([server, "xml-rpc/"]) |
88 | - logging.warn("Please use whole endpoint URL not just end with 'dashboard/', 'xml-rpc/' is added automatically now!!!") |
89 | + logging.warn("Please use whole endpoint URL not just end with 'dashboard/', " |
90 | + "'xml-rpc/' is added automatically now!!!") |
91 | |
92 | parsed_server = urlparse.urlparse(server) |
93 | auth_backend = MemoryAuthBackend([]) |
94 | @@ -96,9 +99,9 @@ |
95 | 'stream': {'type': 'string'}, |
96 | 'result_disk': {'type': 'string', 'optional': True}, |
97 | 'token': {'type': 'string', 'optional': True}, |
98 | - }, |
99 | + }, |
100 | 'additionalProperties': False, |
101 | - } |
102 | + } |
103 | |
104 | def _get_bundles(self, files): |
105 | bundles = [] |
106 | @@ -208,9 +211,9 @@ |
107 | def combine_bundles(self, all_bundles): |
108 | if not all_bundles: |
109 | main_bundle = { |
110 | - "test_runs": [], |
111 | - "format": "Dashboard Bundle Format 1.6" |
112 | - } |
113 | + "test_runs": [], |
114 | + "format": "Dashboard Bundle Format 1.6" |
115 | + } |
116 | else: |
117 | main_bundle = all_bundles.pop(0) |
118 | test_runs = main_bundle['test_runs'] |
119 | |
120 | === modified file 'lava_dispatcher/actions/lava_test_shell.py' |
121 | --- lava_dispatcher/actions/lava_test_shell.py 2013-07-03 10:44:31 +0000 |
122 | +++ lava_dispatcher/actions/lava_test_shell.py 2013-07-18 07:48:32 +0000 |
123 | @@ -127,7 +127,6 @@ |
124 | from lava_dispatcher import utils |
125 | |
126 | from lava_dispatcher.actions import BaseAction |
127 | -from lava_dispatcher.client.base import wait_for_prompt |
128 | from lava_dispatcher.device.target import Target |
129 | from lava_dispatcher.downloader import download_image |
130 | |
131 | @@ -166,6 +165,7 @@ |
132 | # 755 file permissions |
133 | XMOD = stat.S_IRWXU | stat.S_IXGRP | stat.S_IRGRP | stat.S_IXOTH | stat.S_IROTH |
134 | |
135 | + |
136 | def _get_testdef_git_repo(testdef_repo, tmpdir, revision): |
137 | cwd = os.getcwd() |
138 | gitdir = os.path.join(tmpdir, 'gittestrepo') |
139 | @@ -251,6 +251,8 @@ |
140 | |
141 | def load_from_repo(self, testdef_repo): |
142 | tmpdir = utils.mkdtemp(self.tmpbase) |
143 | + repo = None |
144 | + info = None |
145 | if 'git-repo' in testdef_repo: |
146 | repo = _get_testdef_git_repo( |
147 | testdef_repo['git-repo'], tmpdir, testdef_repo.get('revision')) |
148 | @@ -263,6 +265,8 @@ |
149 | name = testdef_repo['bzr-repo'].replace('lp:', '').split('/')[-1] |
150 | info = _bzr_info(testdef_repo['bzr-repo'], repo, name) |
151 | |
152 | + if not repo or not info: |
153 | + logging.debug("Unable to identify specified repository. %s" % testdef_repo) |
154 | test = testdef_repo.get('testdef', 'lavatest.yaml') |
155 | with open(os.path.join(repo, test), 'r') as f: |
156 | logging.info('loading test definition ...') |
157 | @@ -283,7 +287,7 @@ |
158 | 'branch_vcs': 'bzr', |
159 | 'branch_revision': revno, |
160 | 'branch_url': url, |
161 | - } |
162 | + } |
163 | finally: |
164 | os.chdir(cwd) |
165 | |
166 | @@ -298,8 +302,8 @@ |
167 | 'project_name': name, |
168 | 'branch_vcs': 'git', |
169 | 'branch_revision': commit_id, |
170 | - 'branch_url': url, |
171 | - } |
172 | + 'branch_url': url |
173 | + } |
174 | finally: |
175 | os.chdir(cwd) |
176 | |
177 | @@ -354,7 +358,8 @@ |
178 | # have non-reproducible behavior because it may rely on |
179 | # bzr whoami value, presence of ssh keys, etc. |
180 | subprocess.check_call(['bzr', 'branch', repo], |
181 | - env={'BZR_HOME': '/dev/null', 'BZR_LOG': '/dev/null'}) |
182 | + env={'BZR_HOME': '/dev/null', |
183 | + 'BZR_LOG': '/dev/null'}) |
184 | name = repo.replace('lp:', '').split('/')[-1] |
185 | self._sw_sources.append(_bzr_info(repo, name, name)) |
186 | |
187 | @@ -422,8 +427,8 @@ |
188 | f.write('read\n') |
189 | steps = self.testdef['run'].get('steps', []) |
190 | if steps: |
191 | - for cmd in steps: |
192 | - f.write('%s\n' % cmd) |
193 | + for cmd in steps: |
194 | + f.write('%s\n' % cmd) |
195 | f.write('echo "<LAVA_SIGNAL_ENDRUN $TESTRUN_ID $UUID>"\n') |
196 | f.write('#wait for an ack from the dispatcher\n') |
197 | f.write('read\n') |
198 | @@ -466,23 +471,23 @@ |
199 | 'testdef_repos': {'type': 'array', |
200 | 'items': {'type': 'object', |
201 | 'properties': |
202 | - {'git-repo': {'type': 'string', |
203 | - 'optional': True}, |
204 | - 'bzr-repo': {'type': 'string', |
205 | - 'optional': True}, |
206 | - 'revision': {'type': 'string', |
207 | - 'optional': True}, |
208 | - 'testdef': {'type': 'string', |
209 | - 'optional': True} |
210 | - }, |
211 | + {'git-repo': {'type': 'string', |
212 | + 'optional': True}, |
213 | + 'bzr-repo': {'type': 'string', |
214 | + 'optional': True}, |
215 | + 'revision': {'type': 'string', |
216 | + 'optional': True}, |
217 | + 'testdef': {'type': 'string', |
218 | + 'optional': True} |
219 | + }, |
220 | 'additionalProperties': False}, |
221 | 'optional': True |
222 | }, |
223 | 'timeout': {'type': 'integer', 'optional': True}, |
224 | 'role': {'type': 'string', 'optional': True}, |
225 | - }, |
226 | + }, |
227 | 'additionalProperties': False, |
228 | - } |
229 | + } |
230 | |
231 | def run(self, testdef_urls=None, testdef_repos=None, timeout=-1): |
232 | target = self.client.target_device |
233 | @@ -511,12 +516,12 @@ |
234 | |
235 | def _keep_running(self, runner, timeout, signal_director): |
236 | patterns = [ |
237 | - '<LAVA_TEST_RUNNER>: exiting', |
238 | - pexpect.EOF, |
239 | - pexpect.TIMEOUT, |
240 | - '<LAVA_SIGNAL_(\S+) ([^>]+)>', |
241 | - '<LAVA_MULTI_NODE> <LAVA_(\S+) ([^>]+)>', |
242 | - ] |
243 | + '<LAVA_TEST_RUNNER>: exiting', |
244 | + pexpect.EOF, |
245 | + pexpect.TIMEOUT, |
246 | + '<LAVA_SIGNAL_(\S+) ([^>]+)>', |
247 | + '<LAVA_MULTI_NODE> <LAVA_(\S+) ([^>]+)>', |
248 | + ] |
249 | |
250 | idx = runner._connection.expect(patterns, timeout=timeout) |
251 | if idx == 0: |
252 | @@ -664,4 +669,3 @@ |
253 | prefix='lava-test-shell', suffix='.bundle', dir=rdir) |
254 | with os.fdopen(fd, 'w') as f: |
255 | DocumentIO.dump(f, bundle) |
256 | - |
257 | |
258 | === modified file 'lava_dispatcher/device/master.py' |
259 | --- lava_dispatcher/device/master.py 2013-07-02 14:37:47 +0000 |
260 | +++ lava_dispatcher/device/master.py 2013-07-18 07:48:32 +0000 |
261 | @@ -85,7 +85,7 @@ |
262 | 'oe': Target.oe_deployment_data, |
263 | 'ubuntu': Target.ubuntu_deployment_data, |
264 | 'fedora': Target.fedora_deployment_data, |
265 | - } |
266 | + } |
267 | |
268 | self.master_ip = None |
269 | self.device_version = None |
270 | @@ -128,7 +128,7 @@ |
271 | self._deploy_android_tarballs(master, boot, system, data) |
272 | |
273 | if master.has_partition_with_label('userdata') and \ |
274 | - master.has_partition_with_label('sdcard'): |
275 | + master.has_partition_with_label('sdcard'): |
276 | _purge_linaro_android_sdcard(master) |
277 | |
278 | self.deployment_data = Target.android_deployment_data |
279 | @@ -245,8 +245,7 @@ |
280 | def _format_testpartition(self, runner, fstype): |
281 | logging.info("Format testboot and testrootfs partitions") |
282 | runner.run('umount /dev/disk/by-label/testrootfs', failok=True) |
283 | - runner.run('mkfs -t %s -q /dev/disk/by-label/testrootfs -L testrootfs' |
284 | - % fstype, timeout=1800) |
285 | + runner.run('mkfs -t %s -q /dev/disk/by-label/testrootfs -L testrootfs' % fstype, timeout=1800) |
286 | runner.run('umount /dev/disk/by-label/testboot', failok=True) |
287 | runner.run('mkfs.vfat /dev/disk/by-label/testboot -n testboot') |
288 | |
289 | @@ -288,7 +287,7 @@ |
290 | return |
291 | except (OperationFailed, pexpect.TIMEOUT): |
292 | logging.warning(("transfering %s failed. %d retry left." |
293 | - % (tar_url, num_retry - 1))) |
294 | + % (tar_url, num_retry - 1))) |
295 | |
296 | if num_retry > 1: |
297 | # send CTRL C in case wget still hasn't exited. |
298 | @@ -299,7 +298,7 @@ |
299 | sleep_time = 60 |
300 | logging.info("Wait %d second before retry" % sleep_time) |
301 | time.sleep(sleep_time) |
302 | - num_retry = num_retry - 1 |
303 | + num_retry -= 1 |
304 | |
305 | raise RuntimeError('extracting %s on target failed' % tar_url) |
306 | |
307 | @@ -321,7 +320,7 @@ |
308 | @contextlib.contextmanager |
309 | def file_system(self, partition, directory): |
310 | logging.info('attempting to access master filesystem %r:%s' % |
311 | - (partition, directory)) |
312 | + (partition, directory)) |
313 | |
314 | assert directory != '/', "cannot mount entire partition" |
315 | |
316 | @@ -336,7 +335,7 @@ |
317 | parent_dir, target_name = os.path.split(targetdir) |
318 | |
319 | runner.run('tar -czf /tmp/fs.tgz -C %s %s' % |
320 | - (parent_dir, target_name)) |
321 | + (parent_dir, target_name)) |
322 | runner.run('cd /tmp') # need to be in same dir as fs.tgz |
323 | self.proc.sendline('python -m SimpleHTTPServer 0 2>/dev/null') |
324 | match_id = self.proc.expect([ |
325 | @@ -545,8 +544,8 @@ |
326 | |
327 | pattern1 = "<(\d?\d?\d?\.\d?\d?\d?\.\d?\d?\d?\.\d?\d?\d?)>" |
328 | cmd = ("ifconfig %s | grep 'inet addr' | awk -F: '{print $2}' |" |
329 | - "awk '{print \"<\" $1 \">\"}'" % |
330 | - self._client.config.default_network_interface) |
331 | + "awk '{print \"<\" $1 \">\"}'" % |
332 | + self._client.config.default_network_interface) |
333 | self.run( |
334 | cmd, [pattern1, pexpect.EOF, pexpect.TIMEOUT], timeout=5) |
335 | if self.match_id != 0: |
336 | @@ -568,7 +567,7 @@ |
337 | "| sed 's/[^0-9-]//g; s/^-\+//')" |
338 | "\"", |
339 | [pattern, pexpect.EOF, pexpect.TIMEOUT], |
340 | - timeout = 5) |
341 | + timeout=5) |
342 | |
343 | device_version = None |
344 | if self.match_id == 0: |
345 | @@ -662,11 +661,10 @@ |
346 | # delete use of cache partition |
347 | session.run('sed -i "/\/dev\/block\/%s%s%s/d" %s' |
348 | % (blkorg, partition_padding_string_org, cache_part_org, rc_filename)) |
349 | - session.run('sed -i "s/%s%s%s/%s%s%s/g" %s' |
350 | - % (blkorg, partition_padding_string_org, data_part_org, blklava, partition_padding_string_lava, data_part_lava, rc_filename)) |
351 | - session.run('sed -i "s/%s%s%s/%s%s%s/g" %s' |
352 | - % (blkorg, partition_padding_string_org, sys_part_org, blklava, partition_padding_string_lava, sys_part_lava, rc_filename)) |
353 | - |
354 | + session.run('sed -i "s/%s%s%s/%s%s%s/g" %s' % (blkorg, partition_padding_string_org, data_part_org, blklava, |
355 | + partition_padding_string_lava, data_part_lava, rc_filename)) |
356 | + session.run('sed -i "s/%s%s%s/%s%s%s/g" %s' % (blkorg, partition_padding_string_org, sys_part_org, blklava, |
357 | + partition_padding_string_lava, sys_part_lava, rc_filename)) |
358 | |
359 | |
360 | def _recreate_uInitrd(session, target): |
361 | @@ -740,9 +738,9 @@ |
362 | script_path = '%s/%s' % ('/mnt/lava', '/system/bin/disablesuspend.sh') |
363 | if not session.is_file_exist(script_path): |
364 | session.run("sh -c 'export http_proxy=%s'" % |
365 | - target.context.config.lava_proxy) |
366 | + target.context.config.lava_proxy) |
367 | session.run('wget --no-check-certificate %s -O %s' % |
368 | - (target.config.git_url_disablesuspend_sh, script_path)) |
369 | + (target.config.git_url_disablesuspend_sh, script_path)) |
370 | session.run('chmod +x %s' % script_path) |
371 | session.run('chown :2000 %s' % script_path) |
372 | |
373 | @@ -772,9 +770,9 @@ |
374 | data_label = _android_data_label(session) |
375 | session.run('umount /dev/disk/by-label/%s' % data_label, failok=True) |
376 | session.run('mkfs.ext4 -q /dev/disk/by-label/%s -L %s' % |
377 | - (data_label, data_label)) |
378 | + (data_label, data_label)) |
379 | session.run('udevadm trigger') |
380 | session.run('mkdir -p /mnt/lava/data') |
381 | - session.run('mount /dev/disk/by-label/%s /mnt/lava/data' % (data_label)) |
382 | + session.run('mount /dev/disk/by-label/%s /mnt/lava/data' % data_label) |
383 | session._client.target_extract(session, datatbz2, '/mnt/lava', timeout=600) |
384 | session.run('umount /mnt/lava/data') |
385 | |
386 | === modified file 'lava_dispatcher/device/target.py' |
387 | --- lava_dispatcher/device/target.py 2013-07-03 10:44:31 +0000 |
388 | +++ lava_dispatcher/device/target.py 2013-07-18 07:48:32 +0000 |
389 | @@ -24,8 +24,7 @@ |
390 | import re |
391 | |
392 | from lava_dispatcher.client.lmc_utils import ( |
393 | - image_partition_mounted, |
394 | - ) |
395 | + image_partition_mounted) |
396 | import lava_dispatcher.utils as utils |
397 | |
398 | |
399 | @@ -49,7 +48,7 @@ |
400 | 'TESTER_PS1': ANDROID_TESTER_PS1, |
401 | 'TESTER_PS1_PATTERN': ANDROID_TESTER_PS1, |
402 | 'TESTER_PS1_INCLUDES_RC': False, |
403 | - } |
404 | + } |
405 | ubuntu_deployment_data = { |
406 | 'TESTER_PS1': "linaro-test [rc=$(echo \$?)]# ", |
407 | 'TESTER_PS1_PATTERN': "linaro-test \[rc=(\d+)\]# ", |
408 | |
409 | === modified file 'lava_dispatcher/lava_test_shell.py' |
410 | --- lava_dispatcher/lava_test_shell.py 2013-04-08 04:57:50 +0000 |
411 | +++ lava_dispatcher/lava_test_shell.py 2013-07-18 07:48:32 +0000 |
412 | @@ -103,13 +103,12 @@ |
413 | |
414 | |
415 | def _get_sw_context(build, pkgs, sw_sources): |
416 | - ctx = {} |
417 | - ctx['image'] = {'name': build} |
418 | + ctx = {'image': {'name': build}} |
419 | |
420 | pkglist = [] |
421 | pattern = re.compile( |
422 | ("^\s*package:\s*(?P<package_name>[^:]+?)\s*:" |
423 | - "\s*(?P<version>[^\s].+)\s*$"), re.M) |
424 | + "\s*(?P<version>[^\s].+)\s*$"), re.M) |
425 | for line in pkgs.split('\n'): |
426 | match = pattern.search(line) |
427 | if match: |
428 | @@ -121,9 +120,9 @@ |
429 | return ctx |
430 | |
431 | |
432 | -def _attachments_from_dir(dir): |
433 | +def _attachments_from_dir(from_dir): |
434 | attachments = [] |
435 | - for filename, filepath in _directory_names_and_paths(dir, ignore_missing=True): |
436 | + for filename, filepath in _directory_names_and_paths(from_dir, ignore_missing=True): |
437 | if filename.endswith('.mimetype'): |
438 | continue |
439 | mime_type = _read_content(filepath + '.mimetype', ignore_missing=True).strip() |
440 | @@ -136,48 +135,47 @@ |
441 | return attachments |
442 | |
443 | |
444 | -def _attributes_from_dir(dir): |
445 | +def _attributes_from_dir(from_dir): |
446 | attributes = {} |
447 | - for filename, filepath in _directory_names_and_paths(dir, ignore_missing=True): |
448 | + for filename, filepath in _directory_names_and_paths(from_dir, ignore_missing=True): |
449 | if os.path.isfile(filepath): |
450 | attributes[filename] = _read_content(filepath) |
451 | return attributes |
452 | |
453 | |
454 | -def _result_to_dir(test_result, dir): |
455 | +def _result_to_dir(test_result, res_dir): |
456 | |
457 | def w(name, content): |
458 | - with open(os.path.join(dir, name), 'w') as f: |
459 | + with open(os.path.join(res_dir, name), 'w') as f: |
460 | f.write(str(content) + '\n') |
461 | |
462 | for name in 'result', 'measurement', 'units', 'message', 'timestamp', 'duration': |
463 | if name in test_result: |
464 | w(name, test_result[name]) |
465 | |
466 | - |
467 | - os.makedirs(os.path.join(dir, 'attachments')) |
468 | + os.makedirs(os.path.join(res_dir, 'attachments')) |
469 | |
470 | for attachment in test_result.get('attachments', []): |
471 | path = 'attachments/' + attachment['pathname'] |
472 | w(path, base64.b64decode(attachment['content'])) |
473 | w(path + '.mimetype', attachment['mime_type']) |
474 | |
475 | - os.makedirs(os.path.join(dir, 'attributes')) |
476 | + os.makedirs(os.path.join(res_dir, 'attributes')) |
477 | |
478 | for attrname, attrvalue in test_result.get('attributes', []).items(): |
479 | path = 'attributes/' + attrname |
480 | w(path, attrvalue) |
481 | |
482 | |
483 | -def _result_from_dir(dir, test_case_id=None): |
484 | +def _result_from_dir(res_dir, test_case_id=None): |
485 | if not test_case_id: |
486 | - test_case_id = os.path.basename(dir) |
487 | + test_case_id = os.path.basename(res_dir) |
488 | result = { |
489 | 'test_case_id': test_case_id |
490 | - } |
491 | + } |
492 | |
493 | for fname in 'result', 'measurement', 'units', 'message', 'timestamp', 'duration': |
494 | - fpath = os.path.join(dir, fname) |
495 | + fpath = os.path.join(res_dir, fname) |
496 | if os.path.isfile(fpath): |
497 | result[fname] = _read_content(fpath).strip() |
498 | |
499 | @@ -185,11 +183,11 @@ |
500 | try: |
501 | result['measurement'] = decimal.Decimal(result['measurement']) |
502 | except decimal.InvalidOperation: |
503 | - logging.warning("Invalid measurement for %s: %s" % (dir, result['measurement'])) |
504 | + logging.warning("Invalid measurement for %s: %s" % (res_dir, result['measurement'])) |
505 | del result['measurement'] |
506 | |
507 | - result['attachments'] = _attachments_from_dir(os.path.join(dir, 'attachments')) |
508 | - result['attributes'] = _attributes_from_dir(os.path.join(dir, 'attributes')) |
509 | + result['attachments'] = _attachments_from_dir(os.path.join(res_dir, 'attachments')) |
510 | + result['attributes'] = _attributes_from_dir(os.path.join(res_dir, 'attributes')) |
511 | |
512 | return result |
513 | |
514 | @@ -214,6 +212,7 @@ |
515 | def _get_test_results(test_run_dir, testdef, stdout): |
516 | results_from_log_file = [] |
517 | fixupdict = {} |
518 | + pattern = None |
519 | |
520 | if 'parse' in testdef: |
521 | if 'fixupdict' in testdef['parse']: |
522 | @@ -227,6 +226,8 @@ |
523 | 'UNKNOWN': 'unknown'} |
524 | logging.warning("""Using a default pattern to parse the test result. This may lead to empty test result in certain cases.""") |
525 | |
526 | + if not pattern: |
527 | + logging.debug("No pattern set") |
528 | for lineno, line in enumerate(stdout.split('\n'), 1): |
529 | match = pattern.match(line.strip()) |
530 | if match: |
531 | @@ -244,7 +245,7 @@ |
532 | res['measurement'] = decimal.Decimal(res['measurement']) |
533 | except decimal.InvalidOperation: |
534 | logging.warning("Invalid measurement %s" % ( |
535 | - res['measurement'])) |
536 | + res['measurement'])) |
537 | del res['measurement'] |
538 | results_from_log_file.append(res) |
539 | |
540 | @@ -277,10 +278,8 @@ |
541 | |
542 | |
543 | def _get_run_attachments(test_run_dir, testdef, stdout): |
544 | - attachments = [] |
545 | - |
546 | - attachments.append(create_attachment('stdout.log', stdout)) |
547 | - attachments.append(create_attachment('testdef.yaml', testdef)) |
548 | + attachments = [create_attachment('stdout.log', stdout), |
549 | + create_attachment('testdef.yaml', testdef)] |
550 | return_code = _read_content(os.path.join(test_run_dir, 'return_code'), ignore_missing=True) |
551 | if return_code: |
552 | attachments.append(create_attachment('return_code', return_code)) |
553 | @@ -301,7 +300,7 @@ |
554 | 'os': None, |
555 | 'devices': None, |
556 | 'environment': None |
557 | - } |
558 | + } |
559 | |
560 | metadata = _read_content(os.path.join(test_run_dir, 'testdef_metadata')) |
561 | if metadata is not '': |
562 | @@ -339,7 +338,7 @@ |
563 | 'attachments': attachments, |
564 | 'attributes': attributes, |
565 | 'testdef_metadata': _get_run_testdef_metadata(test_run_dir) |
566 | - } |
567 | + } |
568 | |
569 | |
570 | def _read_content(filepath, ignore_missing=False): |
The equivalent changes in trunk have already been merged, merging.