Merge lp:~stylesen/lava-dispatcher/evolve-bundle-stream-1.6 into lp:lava-dispatcher
- evolve-bundle-stream-1.6
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 576 |
Proposed branch: | lp:~stylesen/lava-dispatcher/evolve-bundle-stream-1.6 |
Merge into: | lp:lava-dispatcher |
Diff against target: |
122 lines (+30/-14) 4 files modified
lava_dispatcher/actions/launch_control.py (+1/-1) lava_dispatcher/actions/lava_test_shell.py (+5/-5) lava_dispatcher/lava_test_shell.py (+23/-6) lava_dispatcher/test_data.py (+1/-2) |
To merge this branch: | bzr merge lp:~stylesen/lava-dispatcher/evolve-bundle-stream-1.6 |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Antonio Terceiro | Approve | ||
Zygmunt Krynicki (community) | Needs Fixing | ||
Linaro Validation Team | Pending | ||
Linaro Validation Team | Pending | ||
Review via email: mp+150519@code.launchpad.net |
Commit message
Description of the change
Evolve bundle stream version to 1.6 due to the addition of testdef metadata.
- 554. By Senthil Kumaran S
-
Add "None" string as default value for testdef metadata.
- 555. By Senthil Kumaran S
-
Bring up-to-date with trunk.
- 556. By Senthil Kumaran S
-
Add default values for testdef metadata based on new bundle format.
- 557. By Senthil Kumaran S
-
Populate the version properly based on URL or REPO location.
- 558. By Senthil Kumaran S
-
Fix a typo on if condition.
- 559. By Senthil Kumaran S
-
Use safe_* for YAML processing.
Antonio Terceiro (terceiro) wrote : | # |
Hello Senthil,
Thanks for your work on this. In general it looks good. :-)
I have some comments below that I think you should address before we can
merge this in, though. Nothing super complicated, but things that in my
opinion will make the code more clear for whoever comes to look at in in
future.
review needs-fixing
> === modified file 'lava_dispatche
> --- lava_dispatcher
> +++ lava_dispatcher
> @@ -209,7 +209,7 @@
> if not all_bundles:
> main_bundle = {
> "test_runs": [],
> - "format": "Dashboard Bundle Format 1.5"
> + "format": "Dashboard Bundle Format 1.6"
> }
> else:
> main_bundle = all_bundles.pop(0)
>
> === modified file 'lava_dispatche
> --- lava_dispatcher
> +++ lava_dispatcher
> @@ -202,18 +202,23 @@
> logging.
>
>
> -def _get_testdef_
> - metadata = {'os': '', 'devices': '', 'environment': ''}
> - metadata['version'] = str(testdef[
> - metadata[
> - metadata['format'] = str(testdef[
> +def _get_testdef_
IMO you should handle the difference between plain URL's and
repositories outside of this function. See below.
> + default = "None"
Don't you mean None (without the quotes) here? Besides, I think the rest
of the function would be more clear if you just used `None` (actual
None, not a string "None") instead of default so someone reading the
code doesn't need to wonder "what does default mean"?
> + metadata = {'os': default, 'devices': default, 'environment': default}
> + metadata[
> + default))
> + metadata['format'] = str(testdef[
Do you really mean to convert whatever comes from there to a string? If
the JSON contains a null (the default according to the schema MP), you
will get a string containing the word "None".
You probably want something like this:
value = testdef[
metadata['key'] = value and str(value) or value
> +
> + if location == 'URL':
> + metadata['version'] = str(testdef[
if you don't do anything for all other possible values of `location`, I
don't think this should be in this function, and you don't need to add
`location` as a parameter.
> # Convert list to comma separated string.
> if testdef[
> - metadata['os'] = ','.join(
> + metadata['os'] = ','.join(
>
> if testdef[
> - metadata['devices'] =...
Senthil Kumaran S (stylesen) wrote : | # |
Hi Antonio,
> I have some comments below that I think you should address before we can
> merge this in, though. Nothing super complicated, but things that in my
> opinion will make the code more clear for whoever comes to look at in in
> future.
I fixed all the review comments from you. I request you to go through the new changes and approve this MP.
Thank You.
--
Senthil Kumaran
http://
http://
- 560. By Senthil Kumaran S
-
Remove URL handling from '_get_testdef_info' and usage of "None" string
as default value.
Antonio Terceiro (terceiro) wrote : | # |
Hi Senthil,
In general, I like the fact that we are getting the diff smaller and
smaller. :-)
Follows another round of comments, which is basically one issue really:
the issue of default values - I think it should be `None`, and would
like your opinion.
review needs-info
> === modified file 'lava_dispatche
> --- lava_dispatcher
> +++ lava_dispatcher
> @@ -204,20 +204,20 @@
>
> def _get_testdef_
> metadata = {'os': '', 'devices': '', 'environment': ''}
> - metadata['version'] = str(testdef[
> - metadata[
> - metadata['format'] = str(testdef[
> + metadata[
> + metadata['format'] = testdef[
> + metadata['version'] = testdef[
>
> # Convert list to comma separated string.
> if testdef[
> - metadata['os'] = ','.join(
> + metadata['os'] = ','.join(
>
> if testdef[
> - metadata['devices'] = ','.join(
> + metadata['devices'] = ','.join(
>
> if testdef[
> metadata[
> - testdef[
> + testdef[
So you changed from using `"None"` to using an empty string as the
default. Why are we doing this? Is this the expected behavior?
If you agree with me that None is indeed the appropriate default here, I
think you should just undo the diff lines above.
> === modified file 'lava_dispatche
> --- lava_dispatcher
> +++ lava_dispatcher
> @@ -284,6 +284,25 @@
> return attachments
>
>
> +def _get_run_
> + testdef_metadata = {
> + 'version': '',
> + 'description': '',
> + 'format': '',
> + 'location': '',
> + 'url': '',
> + 'os': '',
> + 'devices': '',
> + 'environment': ''
> + }
minor nitpick: shouldn't this closing brace align with testdef_metadata (i.e. one
indent level to the left)?
Main point here is: why are you using an empty string as default values,
instead of `None`? Isn't `None` the appropriate value in case no data
was provided? Shouldn't we s/''/None/ in the above hunk?
--
Antonio Terceiro
Software Engineer - Linaro
http://
- 561. By Senthil Kumaran S
-
Make the default values as None instead of empty strings.
Suggested by: terceiro
Senthil Kumaran S (stylesen) wrote : | # |
Hi Antonio,
On Thu, 2013-04-04 at 00:22 +0000, Antonio Terceiro wrote:
> > # Convert list to comma separated string.
> > if testdef[
> > - metadata['os'] = ','.join(
> > + metadata['os'] = ','.join(
> >
> > if testdef[
> > - metadata['devices'] = ','.join(
> > + metadata['devices'] = ','.join(
> >
> > if testdef[
> > metadata[
> > - testdef[
> > + testdef[
>
> So you changed from using `"None"` to using an empty string as the
> default. Why are we doing this? Is this the expected behavior?
>
> If you agree with me that None is indeed the appropriate default here, I
> think you should just undo the diff lines above.
I agree that None is the correct default, which I fixed in the code. But
for devices, os, environment having an empty string as default while
retrieving the values from the dict is fine, since we do a join of these
strings with a comma.
> > === modified file 'lava_dispatche
> > --- lava_dispatcher
> > +++ lava_dispatcher
> > @@ -284,6 +284,25 @@
> > return attachments
> >
> >
> > +def _get_run_
> > + testdef_metadata = {
> > + 'version': '',
> > + 'description': '',
> > + 'format': '',
> > + 'location': '',
> > + 'url': '',
> > + 'os': '',
> > + 'devices': '',
> > + 'environment': ''
> > + }
>
> minor nitpick: shouldn't this closing brace align with testdef_metadata (i.e. one
> indent level to the left)?
That is what emacs python mode gives me. I tried a tab on that line, but
emacs refused to align it! Hope this the correct indentation? (I go by
emacs ;) )
I fixed the comments which you mentioned above, please go through it and let me know
if it is good to be merged.
Thank You.
--
Senthil Kumaran
http://
http://
- 562. By Senthil Kumaran S
-
Bring up-to-date with trunk.
Antonio Terceiro (terceiro) wrote : | # |
On Fri, Apr 05, 2013 at 09:33:20AM -0000, Senthil Kumaran S wrote:
> Hi Antonio,
>
> On Thu, 2013-04-04 at 00:22 +0000, Antonio Terceiro wrote:
> > > # Convert list to comma separated string.
> > > if testdef[
> > > - metadata['os'] = ','.join(
> > > + metadata['os'] = ','.join(
> > >
> > > if testdef[
> > > - metadata['devices'] = ','.join(
> > > + metadata['devices'] = ','.join(
> > >
> > > if testdef[
> > > metadata[
> > > - testdef[
> > > + testdef[
> >
> > So you changed from using `"None"` to using an empty string as the
> > default. Why are we doing this? Is this the expected behavior?
> >
> > If you agree with me that None is indeed the appropriate default here, I
> > think you should just undo the diff lines above.
>
> I agree that None is the correct default, which I fixed in the code.
Cool.
I like get('foo') -- how it was before -- more then get('foo', None), though.
> But for devices, os, environment having an empty string as default
> while retrieving the values from the dict is fine, since we do a join
> of these strings with a comma.
The joins are already inside if's that test for the presence of those
properties. If present, are't those properties guaranteed to be arrays
according to the schema?
--
Antonio Terceiro
Software Engineer - Linaro
http://
- 563. By Senthil Kumaran S
-
Do not have empty strings while joining device, os and environment metadata.
Senthil Kumaran S (stylesen) wrote : | # |
Hi Antonio,
On Sun, 2013-04-07 at 13:37 +0000, Antonio Terceiro wrote:
> > But for devices, os, environment having an empty string as default
> > while retrieving the values from the dict is fine, since we do a join
> > of these strings with a comma.
>
> The joins are already inside if's that test for the presence of those
> properties. If present, are't those properties guaranteed to be arrays
> according to the schema?
I cross checked it (and tested it in my local instance) and understood
it is not required to due to the if condition. I fixed it in r563.
Waiting for your review/approval :)
Thank You.
--
Senthil Kumaran
http://
http://
Antonio Terceiro (terceiro) wrote : | # |
On Sun, Apr 07, 2013 at 05:26:20PM -0000, Senthil Kumaran S wrote:
> I cross checked it (and tested it in my local instance) and understood
> it is not required to due to the if condition. I fixed it in r563.
> Waiting for your review/approval :)
Go! :-)
review approve
--
Antonio Terceiro
Software Engineer - Linaro
http://
- 564. By Senthil Kumaran S
-
Bring up-to-date with trunk.
Preview Diff
1 | === modified file 'lava_dispatcher/actions/launch_control.py' |
2 | --- lava_dispatcher/actions/launch_control.py 2013-01-23 22:37:05 +0000 |
3 | +++ lava_dispatcher/actions/launch_control.py 2013-04-08 01:02:21 +0000 |
4 | @@ -209,7 +209,7 @@ |
5 | if not all_bundles: |
6 | main_bundle = { |
7 | "test_runs": [], |
8 | - "format": "Dashboard Bundle Format 1.5" |
9 | + "format": "Dashboard Bundle Format 1.6" |
10 | } |
11 | else: |
12 | main_bundle = all_bundles.pop(0) |
13 | |
14 | === modified file 'lava_dispatcher/actions/lava_test_shell.py' |
15 | --- lava_dispatcher/actions/lava_test_shell.py 2013-02-11 02:31:22 +0000 |
16 | +++ lava_dispatcher/actions/lava_test_shell.py 2013-04-08 01:02:21 +0000 |
17 | @@ -204,9 +204,9 @@ |
18 | |
19 | def _get_testdef_info(testdef): |
20 | metadata = {'os': '', 'devices': '', 'environment': ''} |
21 | - metadata['version'] = str(testdef['metadata'].get('version')) |
22 | - metadata['description'] = str(testdef['metadata'].get('description')) |
23 | - metadata['format'] = str(testdef['metadata'].get('format')) |
24 | + metadata['description'] = testdef['metadata'].get('description', None) |
25 | + metadata['format'] = testdef['metadata'].get('format', None) |
26 | + metadata['version'] = testdef['metadata'].get('version', None) |
27 | |
28 | # Convert list to comma separated string. |
29 | if testdef['metadata'].get('os'): |
30 | @@ -404,7 +404,7 @@ |
31 | f.write(self.uuid) |
32 | |
33 | with open('%s/testdef_metadata' % hostdir, 'w') as f: |
34 | - f.write(yaml.dump(self.testdef_metadata)) |
35 | + f.write(yaml.safe_dump(self.testdef_metadata)) |
36 | |
37 | if 'install' in self.testdef: |
38 | self._create_repos(hostdir) |
39 | @@ -439,8 +439,8 @@ |
40 | testdef_metadata = {} |
41 | testdef_metadata.update({'url': info['branch_url']}) |
42 | testdef_metadata.update({'location': info['branch_vcs'].upper()}) |
43 | - testdef_metadata.update({'repo_rev': info['branch_revision']}) |
44 | testdef_metadata.update(_get_testdef_info(testdef)) |
45 | + testdef_metadata.update({'version': info['branch_revision']}) |
46 | |
47 | URLTestDefinition.__init__(self, context, idx, testdef, |
48 | testdef_metadata) |
49 | |
50 | === modified file 'lava_dispatcher/lava_test_shell.py' |
51 | --- lava_dispatcher/lava_test_shell.py 2013-02-11 02:31:22 +0000 |
52 | +++ lava_dispatcher/lava_test_shell.py 2013-04-08 01:02:21 +0000 |
53 | @@ -284,6 +284,25 @@ |
54 | return attachments |
55 | |
56 | |
57 | +def _get_run_testdef_metadata(test_run_dir): |
58 | + testdef_metadata = { |
59 | + 'version': None, |
60 | + 'description': None, |
61 | + 'format': None, |
62 | + 'location': None, |
63 | + 'url': None, |
64 | + 'os': None, |
65 | + 'devices': None, |
66 | + 'environment': None |
67 | + } |
68 | + |
69 | + metadata = _read_content(os.path.join(test_run_dir, 'testdef_metadata')) |
70 | + if metadata is not '': |
71 | + testdef_metadata = yaml.safe_load(metadata) |
72 | + |
73 | + return testdef_metadata |
74 | + |
75 | + |
76 | def _get_test_run(test_run_dir, hwcontext, build, pkginfo, testdefs_by_uuid): |
77 | now = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ') |
78 | |
79 | @@ -292,11 +311,9 @@ |
80 | uuid = _read_content(os.path.join(test_run_dir, 'analyzer_assigned_uuid')) |
81 | attachments = _get_run_attachments(test_run_dir, testdef, stdout) |
82 | attributes = _attributes_from_dir(os.path.join(test_run_dir, 'attributes')) |
83 | - # XXX testdef_metadata = _read_content(os.path.join(test_run_dir, |
84 | - # XXX 'testdef_metadata')) |
85 | |
86 | testdef = yaml.safe_load(testdef) |
87 | - # XXX testdef_metadata = yaml.safe_load(testdef_metadata) |
88 | + |
89 | if uuid in testdefs_by_uuid: |
90 | sw_sources = testdefs_by_uuid[uuid]._sw_sources |
91 | else: |
92 | @@ -314,8 +331,8 @@ |
93 | 'hardware_context': hwcontext, |
94 | 'attachments': attachments, |
95 | 'attributes': attributes, |
96 | - # XXX 'testdef_metadata': testdef_metadata, |
97 | - } |
98 | + 'testdef_metadata': _get_run_testdef_metadata(test_run_dir) |
99 | + } |
100 | |
101 | |
102 | def _read_content(filepath, ignore_missing=False): |
103 | @@ -354,4 +371,4 @@ |
104 | except: |
105 | logging.exception('error processing results for: %s' % test_run_name) |
106 | |
107 | - return {'test_runs': testruns, 'format': 'Dashboard Bundle Format 1.5'} |
108 | + return {'test_runs': testruns, 'format': 'Dashboard Bundle Format 1.6'} |
109 | |
110 | === modified file 'lava_dispatcher/test_data.py' |
111 | --- lava_dispatcher/test_data.py 2013-01-30 05:33:55 +0000 |
112 | +++ lava_dispatcher/test_data.py 2013-04-08 01:02:21 +0000 |
113 | @@ -34,8 +34,7 @@ |
114 | def __init__(self, test_id='lava'): |
115 | self.job_status = 'pass' |
116 | self.metadata = {} |
117 | - self._test_run = { 'test_results':[], 'attachments':[], 'tags':[], } |
118 | - # XXX 'testdef_metadata':{} } |
119 | + self._test_run = { 'test_results':[], 'attachments':[], 'tags':[] } |
120 | self._test_run['test_id'] = test_id |
121 | self._assign_date() |
122 | self._assign_uuid() |
- # XXX testdef_metadata = yaml.safe_ load(testdef_ metadata) testdef_ metadata)
28 + testdef_metadata = yaml.load(
Given the recent fuckup with using yaml I would rather see safe_load here.
-1