Merge lp:~stylesen/lava-dispatcher/testdef-yaml-support into lp:lava-dispatcher

Proposed by Senthil Kumaran S
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: 429
Merged at revision: 435
Proposed branch: lp:~stylesen/lava-dispatcher/testdef-yaml-support
Merge into: lp:lava-dispatcher
Diff against target: 146 lines (+21/-16)
4 files modified
lava_dispatcher/actions/lava_test_shell.py (+14/-9)
lava_dispatcher/lava_test_shell.py (+5/-5)
lava_test_shell/lava-test-runner-android (+1/-1)
lava_test_shell/lava-test-runner-ubuntu (+1/-1)
To merge this branch: bzr merge lp:~stylesen/lava-dispatcher/testdef-yaml-support
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle (community) Approve
Review via email: mp+132663@code.launchpad.net

Commit message

Support yaml for test definitions.

Description of the change

Support yaml for test definitions.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

This looks fine. We should try to find some way of validating the
testdef a bit more for the sake of clearer error messages (let's talk
abou this when I've gotten home and got some sleep) but this looks fine
as it is.

 review approve
 status approved

Cheers,
mwh

review: Approve

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 2012-10-23 04:46:20 +0000
3+++ lava_dispatcher/actions/lava_test_shell.py 2012-11-02 08:53:21 +0000
4@@ -21,6 +21,7 @@
5 # with this program; if not, see <http://www.gnu.org/licenses>.
6
7 import json
8+import yaml
9 import logging
10 import os
11 import pexpect
12@@ -131,7 +132,7 @@
13 testdef_file = download_image(testdef_url, self.context, tmpdir)
14 with open(testdef_file, 'r') as f:
15 logging.info('loading test definition')
16- return json.load(f)
17+ return yaml.load(f)
18
19 def _copy_runner(self, mntdir, target):
20 runner = target.deployment_data['lava_test_runner']
21@@ -197,22 +198,24 @@
22 f.write('cd %s\n' % targetdir)
23
24 # TODO how should we handle this for Android?
25- if 'deps' in testdef['install']:
26+ if 'deps' in testdef['install'] and \
27+ testdef['install']['deps'] is not None:
28 f.write('sudo apt-get update\n')
29 f.write('sudo apt-get install -y ')
30 for dep in testdef['install']['deps']:
31 f.write('%s ' % dep)
32 f.write('\n')
33
34- if 'steps' in testdef['install']:
35+ if 'steps' in testdef['install'] and \
36+ testdef['install']['steps'] is not None:
37 for cmd in testdef['install']['steps']:
38 f.write('%s\n' % cmd)
39
40 def _copy_test(self, hostdir, targetdir, testdef):
41 self._sw_sources = []
42 utils.ensure_directory(hostdir)
43- with open('%s/testdef.json' % hostdir, 'w') as f:
44- f.write(json.dumps(testdef))
45+ with open('%s/testdef.yaml' % hostdir, 'w') as f:
46+ f.write(yaml.dump(testdef))
47
48 if 'install' in testdef:
49 self._create_repos(testdef, hostdir)
50@@ -221,8 +224,10 @@
51 with open('%s/run.sh' % hostdir, 'w') as f:
52 f.write('set -e\n')
53 f.write('cd %s\n' % targetdir)
54- for cmd in testdef['run']['steps']:
55- f.write('%s\n' % cmd)
56+ if 'steps' in testdef['run'] \
57+ and testdef['run']['steps'] is not None:
58+ for cmd in testdef['run']['steps']:
59+ f.write('%s\n' % cmd)
60
61 def _mk_runner_dirs(self, mntdir):
62 utils.ensure_directory('%s/bin' % mntdir)
63@@ -243,8 +248,8 @@
64 # android mount the partition under /system, while ubuntu
65 # mounts under /, so we have hdir for where it is on the host
66 # and tdir for how the target will see the path
67- hdir = '%s/tests/%d_%s' % (d, i, testdef['test_id'])
68- tdir = '%s/tests/%d_%s' % (ldir, i, testdef['test_id'])
69+ hdir = '%s/tests/%d_%s' % (d, i, testdef.get('metadata').get('name'))
70+ tdir = '%s/tests/%d_%s' % (ldir, i, testdef.get('metadata').get('name'))
71 self._copy_test(hdir, tdir, testdef)
72 testdirs.append(tdir)
73
74
75=== modified file 'lava_dispatcher/lava_test_shell.py'
76--- lava_dispatcher/lava_test_shell.py 2012-10-14 21:44:55 +0000
77+++ lava_dispatcher/lava_test_shell.py 2012-11-02 08:53:21 +0000
78@@ -21,6 +21,7 @@
79 import datetime
80 import errno
81 import json
82+import yaml
83 import logging
84 import os
85 import re
86@@ -119,7 +120,6 @@
87
88 pattern = re.compile(testdef['parse']['pattern'])
89
90- fixupdict = {}
91 if 'fixupdict' in testdef['parse']:
92 fixupdict = testdef['parse']['fixupdict']
93
94@@ -143,7 +143,7 @@
95 attachments = []
96
97 attachments.append(create_attachment('stdout.txt', stdout))
98- attachments.append(create_attachment('testdef.json', testdef))
99+ attachments.append(create_attachment('testdef.yaml', testdef))
100
101 for f in files:
102 fname = '%s/%s' % (dirname, f)
103@@ -157,14 +157,14 @@
104 def _get_test_run(results_dir, dirname, hwcontext, swcontext):
105 now = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
106
107- testdef = _get_content(results_dir, '%s/testdef.json' % dirname)
108+ testdef = _get_content(results_dir, '%s/testdef.yaml' % dirname)
109 stdout = _get_content(results_dir, '%s/stdout.log' % dirname)
110 attachments = _get_attachments(results_dir, dirname, testdef, stdout)
111
112- testdef = json.loads(testdef)
113+ testdef = yaml.load(testdef)
114
115 return {
116- 'test_id': testdef['test_id'],
117+ 'test_id': testdef.get('metadata').get('name'),
118 'analyzer_assigned_date': now,
119 'analyzer_assigned_uuid': str(uuid4()),
120 'time_check_performed': False,
121
122=== modified file 'lava_test_shell/lava-test-runner-android'
123--- lava_test_shell/lava-test-runner-android 2012-10-22 20:41:43 +0000
124+++ lava_test_shell/lava-test-runner-android 2012-11-02 08:53:21 +0000
125@@ -79,7 +79,7 @@
126 echo "${PREFIX} running ${test} under lava-test-shell..."
127 odir=${RESULTSDIR}/${test}-`date +%s`
128 mkdir ${odir}
129- cp ${line}/testdef.json ${odir}/
130+ cp ${line}/testdef.yaml ${odir}/
131 cp ${line}/run.sh ${odir}/
132 [ -f ${line}/install.sh ] && cp ${line}/install.sh ${odir}/
133 lava-test-shell --output_dir ${odir} /system/bin/sh -e "${line}/run.sh"
134
135=== modified file 'lava_test_shell/lava-test-runner-ubuntu'
136--- lava_test_shell/lava-test-runner-ubuntu 2012-10-22 20:41:43 +0000
137+++ lava_test_shell/lava-test-runner-ubuntu 2012-11-02 08:53:21 +0000
138@@ -63,7 +63,7 @@
139 echo "${PREFIX} running ${test} under lava-test-shell..."
140 odir=${RESULTSDIR}/${test}-`date +%s`
141 mkdir ${odir}
142- cp ${line}/testdef.json ${odir}/
143+ cp ${line}/testdef.yaml ${odir}/
144 cp ${line}/run.sh ${odir}/
145 [ -f ${line}/install.sh ] && cp ${line}/install.sh ${odir}/
146 lava-test-shell --output_dir ${odir} /bin/sh -e "${line}/run.sh"

Subscribers

People subscribed via source and target branches