Merge lp:~stylesen/lava-dispatcher/add-on-to-testdef-yaml into lp:lava-dispatcher

Proposed by Senthil Kumaran S
Status: Merged
Merged at revision: 548
Proposed branch: lp:~stylesen/lava-dispatcher/add-on-to-testdef-yaml
Merge into: lp:lava-dispatcher
Diff against target: 173 lines (+48/-7)
5 files modified
lava_dispatcher/actions/lava_test_shell.py (+40/-5)
lava_dispatcher/lava_test_shell.py (+4/-0)
lava_dispatcher/test_data.py (+2/-2)
lava_test_shell/lava-test-runner-android (+1/-0)
lava_test_shell/lava-test-runner-ubuntu (+1/-0)
To merge this branch: bzr merge lp:~stylesen/lava-dispatcher/add-on-to-testdef-yaml
Reviewer Review Type Date Requested Status
Linaro Validation Team Pending
Linaro Validation Team Pending
Linaro Validation Team Pending
Review via email: mp+144214@code.launchpad.net

Description of the change

Add more metadata parameters to the YAML format which could now be understood by lava-test-shell. A test definition with the newly added parameters is available here - http://git.linaro.org/gitweb?p=qa/test-definitions.git;a=blob;f=ubuntu/device-tree.yaml

To post a comment you must log in.
539. By Senthil Kumaran S

Make certain test definition metadata parameters to be a list in YAML.

Revision history for this message
Andy Doan (doanac) wrote :

looks pretty good to me. one thing its probably worth adding now is either a docs entry detailing these YAML fields or an annotated example

Revision history for this message
Senthil Kumaran S (stylesen) wrote :

On Thursday 24 January 2013 12:14 AM, Andy Doan wrote:
> looks pretty good to me. one thing its probably worth adding now is either a docs entry detailing these YAML fields or an annotated example

Yep, I shall do that shortly (its in my TODO already).

Thank You.
--
Senthil Kumaran S
http://www.stylesen.org/
http://www.sasenthilkumaran.com/

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Senthil Kumaran S <email address hidden> writes:

> +def _get_testdef_info(testdef):
> + metadata = {}
> + metadata['version'] = testdef['metadata']['version']
> + metadata['description'] = testdef['metadata']['description']
> + metadata['format'] = testdef['metadata']['format']
> + metadata['os'] = ','.join(testdef['metadata']['os'])
> + metadata['devices'] = ','.join(testdef['metadata']['devices'])
> + metadata['environment'] = ','.join(testdef['metadata']['environment'])
> + return metadata

I don't think it's reasonable to assume that the new fields are present
in the testdef. The rest looks fine.

Cheers,
mwh

540. By Senthil Kumaran S

Ensure testdef metadata is attached to each test run and avoid adding it
to context.

541. By Senthil Kumaran S

Fix comment to add description about new testdef_metadata file.

542. By Senthil Kumaran S

Bring up-to-date with trunk.

Revision history for this message
Andy Doan (doanac) wrote :

I think this looks pretty good. I have a concern we'll need some sort of evolution logic as the schema changes. However, maybe we assume this comprises the 1.0 version and hold off doing evultion stuff until we change the schema next time?

Revision history for this message
Senthil Kumaran S (stylesen) wrote :

Hi Andy,

On Monday 28 January 2013 10:52 PM, Andy Doan wrote:
> I think this looks pretty good. I have a concern we'll need some sort of evolution logic as the schema changes. However, maybe we assume this comprises the 1.0 version and hold off doing evultion stuff until we change the schema next time?

I thought I can take evolution stuff in next months BP. As of now we
will have the format till date as version 1.0 and lets evolve.

Thank You.
--
Senthil Kumaran S
http://www.stylesen.org/
http://www.sasenthilkumaran.com/

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Senthil Kumaran S <email address hidden> writes:

> === modified file 'lava_dispatcher/test_data.py'
> --- lava_dispatcher/test_data.py 2012-07-31 20:20:02 +0000
> +++ lava_dispatcher/test_data.py 2013-01-28 08:54:19 +0000
> @@ -34,7 +34,8 @@
> def __init__(self, test_id='lava'):
> self.job_status = 'pass'
> self.metadata = {}
> - self._test_run = { 'test_results':[], 'attachments':[], 'tags':[] }
> + self._test_run = { 'test_results':[], 'attachments':[], 'tags':[],
> + 'testdef_metadata':{} }

Does this actually work? The 1.5 bundle format:

http://bazaar.launchpad.net/~linaro-validation/linaro-python-dashboard-bundle/trunk/view/head:/linaro_dashboard_bundle/schemas/dashboard_bundle_format_1.5.json

doesn't allow a testdef_metadata property on elements of the test_run
array.

> self._test_run['test_id'] = test_id
> self._assign_date()
> self._assign_uuid()
> @@ -75,4 +76,3 @@
> def get_test_run(self):
> self.add_result('job_complete', self.job_status)
> return self._test_run
> -
>

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Senthil Kumaran S <email address hidden> writes:

> Hi Andy,
>
> On Monday 28 January 2013 10:52 PM, Andy Doan wrote:
>> I think this looks pretty good. I have a concern we'll need some sort of evolution logic as the schema changes. However, maybe we assume this comprises the 1.0 version and hold off doing evultion stuff until we change the schema next time?
>
> I thought I can take evolution stuff in next months BP. As of now we
> will have the format till date as version 1.0 and lets evolve.

This makes sense to me.

Revision history for this message
Senthil Kumaran S (stylesen) wrote :

On Tuesday 29 January 2013 06:46 AM, Michael Hudson-Doyle wrote:
> http://bazaar.launchpad.net/~linaro-validation/linaro-python-dashboard-bundle/trunk/view/head:/linaro_dashboard_bundle/schemas/dashboard_bundle_format_1.5.json
>
> doesn't allow a testdef_metadata property on elements of the test_run
> array.

I did patched linaro-python-dashboard-bundle along with this BP -
https://blueprints.launchpad.net/lava-dispatcher/+spec/add-on-to-testdef-yaml-format

The branch is here -
https://code.launchpad.net/~stylesen/linaro-python-dashboard-bundle/add-on-to-testdef-yaml

Thank You.
--
Senthil Kumaran S
http://www.stylesen.org/
http://www.sasenthilkumaran.com/

543. By Senthil Kumaran S

Bring up-to-date with trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_dispatcher/actions/lava_test_shell.py'
2--- lava_dispatcher/actions/lava_test_shell.py 2013-01-15 17:23:13 +0000
3+++ lava_dispatcher/actions/lava_test_shell.py 2013-01-29 10:28:22 +0000
4@@ -53,6 +53,7 @@
5 # uuid The "analyzer_assigned_uuid" of the
6 # test_run that is being generated.
7 # testdef.yml The test definition.
8+# testdef_metadata Metadata extracted from test definition.
9 # install.sh The install steps.
10 # run.sh The run steps.
11 # [repos] The test definition can specify bzr or git
12@@ -74,6 +75,7 @@
13 # pkgs.txt Ditto
14 # ${IDX}_${TEST_ID}-${TIMESTAMP}/
15 # testdef.yml
16+# testdef_metadata
17 # stdout.log
18 # return_code The exit code of run.sh.
19 # analyzer_assigned_uuid
20@@ -173,8 +175,7 @@
21 cwd = os.getcwd()
22 gitdir = os.path.join(tmpdir, 'gittestrepo')
23 try:
24- subprocess.check_call(['git', 'clone', testdef_repo,
25- gitdir])
26+ subprocess.check_call(['git', 'clone', testdef_repo, gitdir])
27 if revision:
28 os.chdir(gitdir)
29 subprocess.check_call(['git', 'checkout', revision])
30@@ -201,6 +202,26 @@
31 logging.error('Unable to get test definition from bzr\n' + str(e))
32
33
34+def _get_testdef_info(testdef):
35+ metadata = {'os': '', 'devices': '', 'environment': ''}
36+ metadata['version'] = str(testdef['metadata'].get('version'))
37+ metadata['description'] = str(testdef['metadata'].get('description'))
38+ metadata['format'] = str(testdef['metadata'].get('format'))
39+
40+ # Convert list to comma separated string.
41+ if testdef['metadata'].get('os'):
42+ metadata['os'] = ','.join(testdef['metadata'].get('os'))
43+
44+ if testdef['metadata'].get('devices'):
45+ metadata['devices'] = ','.join(testdef['metadata'].get('devices'))
46+
47+ if testdef['metadata'].get('environment'):
48+ metadata['environment'] = ','.join(
49+ testdef['metadata'].get('environment'))
50+
51+ return metadata
52+
53+
54 class TestDefinitionLoader(object):
55 """
56 A TestDefinitionLoader knows how to load test definitions from the data
57@@ -227,7 +248,10 @@
58
59 idx = len(self.testdefs)
60
61- self._append_testdef(URLTestDefinition(self.context, idx, testdef))
62+ testdef_metadata = {'url': url, 'location': 'URL'}
63+ testdef_metadata.update(_get_testdef_info(testdef))
64+ self._append_testdef(URLTestDefinition(self.context, idx, testdef,
65+ testdef_metadata))
66
67 def load_from_repo(self, testdef_repo):
68 tmpdir = utils.mkdtemp(self.tmpbase)
69@@ -289,9 +313,10 @@
70 A test definition that was loaded from a URL.
71 """
72
73- def __init__(self, context, idx, testdef):
74+ def __init__(self, context, idx, testdef, testdef_metadata):
75 self.context = context
76 self.testdef = testdef
77+ self.testdef_metadata = testdef_metadata
78 self.idx = idx
79 self.test_run_id = '%s_%s' % (idx, self.testdef['metadata']['name'])
80 self.uuid = str(uuid4())
81@@ -378,6 +403,9 @@
82 with open('%s/uuid' % hostdir, 'w') as f:
83 f.write(self.uuid)
84
85+ with open('%s/testdef_metadata' % hostdir, 'w') as f:
86+ f.write(yaml.dump(self.testdef_metadata))
87+
88 if 'install' in self.testdef:
89 self._create_repos(hostdir)
90 self._create_target_install(hostdir, targetdir)
91@@ -408,7 +436,14 @@
92 """
93
94 def __init__(self, context, idx, testdef, repo, info):
95- URLTestDefinition.__init__(self, context, idx, testdef)
96+ testdef_metadata = {}
97+ testdef_metadata.update({'url': info['branch_url']})
98+ testdef_metadata.update({'location': info['branch_vcs'].upper()})
99+ testdef_metadata.update({'repo_rev': info['branch_revision']})
100+ testdef_metadata.update(_get_testdef_info(testdef))
101+
102+ URLTestDefinition.__init__(self, context, idx, testdef,
103+ testdef_metadata)
104 self.repo = repo
105 self._sw_sources.append(info)
106
107
108=== modified file 'lava_dispatcher/lava_test_shell.py'
109--- lava_dispatcher/lava_test_shell.py 2013-01-14 03:08:36 +0000
110+++ lava_dispatcher/lava_test_shell.py 2013-01-29 10:28:22 +0000
111@@ -292,8 +292,11 @@
112 uuid = _read_content(os.path.join(test_run_dir, 'analyzer_assigned_uuid'))
113 attachments = _get_run_attachments(test_run_dir, testdef, stdout)
114 attributes = _attributes_from_dir(os.path.join(test_run_dir, 'attributes'))
115+ testdef_metadata = _read_content(os.path.join(test_run_dir,
116+ 'testdef_metadata'))
117
118 testdef = yaml.load(testdef)
119+ testdef_metadata = yaml.load(testdef_metadata)
120 if uuid in testdefs_by_uuid:
121 sw_sources = testdefs_by_uuid[uuid]._sw_sources
122 else:
123@@ -311,6 +314,7 @@
124 'hardware_context': hwcontext,
125 'attachments': attachments,
126 'attributes': attributes,
127+ 'testdef_metadata': testdef_metadata,
128 }
129
130
131
132=== modified file 'lava_dispatcher/test_data.py'
133--- lava_dispatcher/test_data.py 2012-07-31 20:20:02 +0000
134+++ lava_dispatcher/test_data.py 2013-01-29 10:28:22 +0000
135@@ -34,7 +34,8 @@
136 def __init__(self, test_id='lava'):
137 self.job_status = 'pass'
138 self.metadata = {}
139- self._test_run = { 'test_results':[], 'attachments':[], 'tags':[] }
140+ self._test_run = { 'test_results':[], 'attachments':[], 'tags':[],
141+ 'testdef_metadata':{} }
142 self._test_run['test_id'] = test_id
143 self._assign_date()
144 self._assign_uuid()
145@@ -75,4 +76,3 @@
146 def get_test_run(self):
147 self.add_result('job_complete', self.job_status)
148 return self._test_run
149-
150
151=== modified file 'lava_test_shell/lava-test-runner-android'
152--- lava_test_shell/lava-test-runner-android 2013-01-04 13:23:08 +0000
153+++ lava_test_shell/lava-test-runner-android 2013-01-29 10:28:22 +0000
154@@ -92,6 +92,7 @@
155 mkdir ${odir}
156 mkdir ${odir}/attachments/
157 cp ${line}/testdef.yaml ${odir}/
158+ cp ${line}/testdef_metadata ${odir}/
159 cp ${line}/uuid ${odir}/analyzer_assigned_uuid
160 cp ${line}/run.sh ${odir}/attachments/
161 echo 'text/plain' > ${odir}/attachments/run.sh.mimetype
162
163=== modified file 'lava_test_shell/lava-test-runner-ubuntu'
164--- lava_test_shell/lava-test-runner-ubuntu 2013-01-14 16:30:05 +0000
165+++ lava_test_shell/lava-test-runner-ubuntu 2013-01-29 10:28:22 +0000
166@@ -76,6 +76,7 @@
167 mkdir ${odir}/attachments/
168 cp ${line}/uuid ${odir}/analyzer_assigned_uuid
169 cp ${line}/testdef.yaml ${odir}/
170+ cp ${line}/testdef_metadata ${odir}/
171 cp ${line}/run.sh ${odir}/attachments/
172 echo 'text/plain' > ${odir}/attachments/run.sh.mimetype
173 if [ -f ${line}/install.sh ]; then

Subscribers

People subscribed via source and target branches