Merge lp:~doanac/ubuntu-test-cases/config-rework into lp:ubuntu-test-cases/touch
- config-rework
- Merge into touch
Proposed by
Andy Doan
Status: | Merged |
---|---|
Merged at revision: | 94 |
Proposed branch: | lp:~doanac/ubuntu-test-cases/config-rework |
Merge into: | lp:ubuntu-test-cases/touch |
Diff against target: |
461 lines (+184/-174) 5 files modified
jenkins/apconfig.py (+0/-104) jenkins/production.py (+0/-28) jenkins/setup_jenkins.py (+6/-39) jenkins/templates/touch-smoke.xml.jinja2 (+3/-3) jenkins/testconfig.py (+175/-0) |
To merge this branch: | bzr merge lp:~doanac/ubuntu-test-cases/config-rework |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Paul Larson | Approve | ||
Review via email: mp+192566@code.launchpad.net |
Commit message
Description of the change
dealing with testsuite configuration information in setup_jenkins.py is becoming cumbersome. Additionally, as MEGA jobs currently stand, you need to regenerate jobs to add/remove testsuites. This moves the configuration information around a little bit so that MEGA jobs seldom need reconfiguring.
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 | === removed file 'jenkins/apconfig.py' |
2 | --- jenkins/apconfig.py 2013-10-21 18:16:50 +0000 |
3 | +++ jenkins/apconfig.py 1970-01-01 00:00:00 +0000 |
4 | @@ -1,104 +0,0 @@ |
5 | -#!/usr/bin/env python |
6 | - |
7 | -# Ubuntu Testing Automation Harness |
8 | -# Copyright 2013 Canonical Ltd. |
9 | - |
10 | -# This program is free software: you can redistribute it and/or modify it |
11 | -# under the terms of the GNU General Public License version 3, as published |
12 | -# by the Free Software Foundation. |
13 | - |
14 | -# This program is distributed in the hope that it will be useful, but |
15 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
16 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
17 | -# PURPOSE. See the GNU General Public License for more details. |
18 | - |
19 | -# You should have received a copy of the GNU General Public License along |
20 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
21 | - |
22 | -import argparse |
23 | -import collections |
24 | - |
25 | -TestSuite = collections.namedtuple('TestSuite', ['name', 'app', 'pkgs']) |
26 | - |
27 | - |
28 | -def _ap_test(name, app=None, pkgs=None): |
29 | - if not app: |
30 | - # convert share-app-autopilot to share_app |
31 | - app = name.replace('-', '_').replace('_autopilot', '') |
32 | - return TestSuite(name, app, pkgs) |
33 | - |
34 | - |
35 | -TESTSUITES = [ |
36 | - _ap_test('friends-app-autopilot', pkgs=['friends-app-autopilot']), |
37 | - _ap_test('mediaplayer-app-autopilot', pkgs=['mediaplayer-app-autopilot']), |
38 | - _ap_test('gallery-app-autopilot', pkgs=['gallery-app-autopilot']), |
39 | - _ap_test('webbrowser-app-autopilot', pkgs=['webbrowser-app-autopilot']), |
40 | - _ap_test('unity8-autopilot', 'unity8', pkgs=['python-gi']), |
41 | - _ap_test('notes-app-autopilot'), |
42 | - _ap_test('camera-app-autopilot', pkgs=['camera-app-autopilot']), |
43 | - _ap_test('dialer-app-autopilot', pkgs=['dialer-app-autopilot']), |
44 | - _ap_test('messaging-app-autopilot', pkgs=['messaging-app-autopilot']), |
45 | - _ap_test('address-book-app-autopilot', |
46 | - pkgs=['address-book-app-autopilot']), |
47 | - _ap_test('calendar-app-autopilot'), |
48 | - _ap_test('music-app-autopilot'), |
49 | - _ap_test('dropping-letters-app-autopilot'), |
50 | - _ap_test('ubuntu-calculator-app-autopilot'), |
51 | - _ap_test('ubuntu-clock-app-autopilot'), |
52 | - _ap_test('ubuntu-filemanager-app-autopilot'), |
53 | - _ap_test('ubuntu-rssreader-app-autopilot'), |
54 | - _ap_test('ubuntu-terminal-app-autopilot'), |
55 | - _ap_test('ubuntu-weather-app-autopilot'), |
56 | - _ap_test('ubuntu-ui-toolkit-autopilot', 'ubuntuuitoolkit', |
57 | - ['ubuntu-ui-toolkit-autopilot']), |
58 | - _ap_test('ubuntu-system-settings-online-accounts-autopilot', |
59 | - 'online_accounts_ui', |
60 | - ['ubuntu-system-settings-online-accounts-autopilot']), |
61 | -] |
62 | - |
63 | - |
64 | -def _handle_packages(args): |
65 | - pkgs = [] |
66 | - for suite in TESTSUITES: |
67 | - if not args.app or suite.app in args.app: |
68 | - if suite.pkgs: |
69 | - pkgs.extend(suite.pkgs) |
70 | - print(' '.join(pkgs)) |
71 | - return 0 |
72 | - |
73 | - |
74 | -def _handle_apps(args): |
75 | - apps = [t.app for t in TESTSUITES] |
76 | - print(' '.join(apps)) |
77 | - |
78 | - |
79 | -def _handle_tests(args): |
80 | - tests = [t.name for t in TESTSUITES] |
81 | - print(' '.join(tests)) |
82 | - |
83 | - |
84 | -def _get_parser(): |
85 | - parser = argparse.ArgumentParser( |
86 | - description='List information on configured autopilot tests for touch') |
87 | - sub = parser.add_subparsers(title='Commands', metavar='') |
88 | - |
89 | - p = sub.add_parser('packages', help='List packages required for apps') |
90 | - p.set_defaults(func=_handle_packages) |
91 | - p.add_argument('-a', '--app', action='append', |
92 | - help='Autopilot test application. eg share_app') |
93 | - |
94 | - p = sub.add_parser('apps', help='List tests by autopilot application name') |
95 | - p.set_defaults(func=_handle_apps) |
96 | - |
97 | - p = sub.add_parser('tests', help='List tests by CI test name') |
98 | - p.set_defaults(func=_handle_tests) |
99 | - |
100 | - return parser |
101 | - |
102 | - |
103 | -def main(): |
104 | - args = _get_parser().parse_args() |
105 | - return args.func(args) |
106 | - |
107 | -if __name__ == '__main__': |
108 | - exit(main()) |
109 | |
110 | === modified file 'jenkins/production.py' |
111 | --- jenkins/production.py 2013-10-22 14:41:50 +0000 |
112 | +++ jenkins/production.py 2013-10-24 18:45:43 +0000 |
113 | @@ -3,32 +3,6 @@ |
114 | JENKINS = 'http://10.97.0.1:8080' |
115 | |
116 | |
117 | -def _custom_test_filter(common_tests, mktest_func): |
118 | - tests = [] |
119 | - test_set = [ |
120 | - 'install-and-boot', |
121 | - 'default', |
122 | - 'unity8-autopilot', |
123 | - 'webbrowser-app-autopilot', |
124 | - ] |
125 | - |
126 | - tests = [t for t in common_tests if t.name in test_set] |
127 | - tests.insert(1, mktest_func('customizations')) |
128 | - return tests |
129 | - |
130 | - |
131 | -def _sf4p_test_filter(common_tests, mktest_func): |
132 | - tests = [] |
133 | - test_set = [ |
134 | - 'install-and-boot', |
135 | - 'default', |
136 | - 'unity8-autopilot', |
137 | - ] |
138 | - |
139 | - tests = [t for t in common_tests if t.name in test_set] |
140 | - return tests |
141 | - |
142 | - |
143 | def _url(channel, device): |
144 | return 'http://system-image.ubuntu.com/%s/%s/index.json' \ |
145 | % (channel, device) |
146 | @@ -48,7 +22,6 @@ |
147 | 'trigger_url': _url('trusty-proposed', 'maguro'), |
148 | }, |
149 | ], |
150 | - 'filter': _sf4p_test_filter, |
151 | }, |
152 | { |
153 | 'image-type': 'touch', |
154 | @@ -73,7 +46,6 @@ |
155 | 'trigger_url': _url('trusty-proposed-customized', 'mako'), |
156 | }, |
157 | ], |
158 | - 'filter': _custom_test_filter, |
159 | 'IMAGE_OPT': 'export IMAGE_OPT="ubuntu-system ' |
160 | '--channel trusty-proposed-customized"' |
161 | }, |
162 | |
163 | === modified file 'jenkins/setup_jenkins.py' |
164 | --- jenkins/setup_jenkins.py 2013-10-22 15:59:20 +0000 |
165 | +++ jenkins/setup_jenkins.py 2013-10-24 18:45:43 +0000 |
166 | @@ -16,7 +16,6 @@ |
167 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
168 | |
169 | import argparse |
170 | -import collections |
171 | import imp |
172 | import jenkins |
173 | import jinja2 |
174 | @@ -26,41 +25,10 @@ |
175 | from distro_info import UbuntuDistroInfo |
176 | DEV_SERIES = UbuntuDistroInfo().devel() |
177 | |
178 | -import apconfig |
179 | +import testconfig |
180 | |
181 | DEFINE_MEGA = os.environ.get('MEGA', False) |
182 | |
183 | -DEF_FMT = '{prefix}{series}-{imagetype}-{type}-smoke-{testname}' |
184 | -IDLE_FMT = '{prefix}{testname}-{series}-{imagetype}-armhf-install-idle-{type}' |
185 | - |
186 | -Test = collections.namedtuple('Test', ['name', 'fmt', 'ap']) |
187 | - |
188 | - |
189 | -def _test(name, fmt=DEF_FMT): |
190 | - return Test(name, fmt, False) |
191 | - |
192 | - |
193 | -def _ap_test(name): |
194 | - return Test(name, DEF_FMT, True) |
195 | - |
196 | - |
197 | -TESTS = [ |
198 | - _test('install-and-boot'), |
199 | - _test('default'), |
200 | -] |
201 | - |
202 | -TESTS += [_ap_test(t.name) for t in apconfig.TESTSUITES] |
203 | - |
204 | -TESTS += [ |
205 | - _test('click_image_tests'), |
206 | - _test('sdk'), |
207 | - _test('security'), |
208 | - _test('eventstat', IDLE_FMT), |
209 | - _test('smem', IDLE_FMT), |
210 | - _test('memevent', |
211 | - '{prefix}{testname}-{series}-{imagetype}-armhf-default-{type}'), |
212 | -] |
213 | - |
214 | |
215 | def _get_parser(): |
216 | """Create and return command line parser. |
217 | @@ -150,13 +118,12 @@ |
218 | 'serial': device.get('serial', defserial), |
219 | 'publish': args.publish, |
220 | 'branch': args.branch, |
221 | - 'tests': ' '.join([t.name for t in tests if not t.ap]), |
222 | 'trigger_url': device['trigger_url'], |
223 | 'imagetype': config_item['image-type'], |
224 | 'image_opt': config_item.get('IMAGE_OPT', ''), |
225 | } |
226 | # a hack so we can use _get_job_name |
227 | - test = _test('', fmt='{prefix}{series}-{imagetype}-{type}') |
228 | + test = testconfig.Test('', fmt='{prefix}{series}-{imagetype}-{type}') |
229 | job = _get_job_name(args, name, test, config_item['image-type']) |
230 | _publish(instance, env, args, 'touch-smoke.xml.jinja2', job, **params) |
231 | else: |
232 | @@ -187,7 +154,8 @@ |
233 | 'trigger_url': device['trigger_url'], |
234 | } |
235 | image_type = config_item['image-type'] |
236 | - job = _get_job_name(args, device['name'], _test('master'), image_type) |
237 | + test = testconfig.Test('master') |
238 | + job = _get_job_name(args, device['name'], test, image_type) |
239 | _publish(instance, env, args, 'touch-master.xml.jinja2', job, **params) |
240 | |
241 | job = 'smoke-master-free' |
242 | @@ -227,9 +195,8 @@ |
243 | |
244 | for item in config.MATRIX[args.series]: |
245 | for device in item['devices']: |
246 | - tests = TESTS |
247 | - if 'filter' in item: |
248 | - tests = item['filter'](tests, _test) |
249 | + tests = testconfig.TESTSUITES |
250 | + tests = testconfig.filter_tests(tests, item['image-type']) |
251 | _configure_jobs(jenkins_inst, env, args, item, device, tests) |
252 | |
253 | if __name__ == '__main__': |
254 | |
255 | === modified file 'jenkins/templates/touch-smoke.xml.jinja2' |
256 | --- jenkins/templates/touch-smoke.xml.jinja2 2013-10-22 15:59:20 +0000 |
257 | +++ jenkins/templates/touch-smoke.xml.jinja2 2013-10-24 18:45:43 +0000 |
258 | @@ -87,7 +87,7 @@ |
259 | |
260 | if [ -z $INSTALL_URL ] ; then |
261 | if [ "$PACKAGES" = "ALL" ] ; then |
262 | - PACKAGES="$(${BZRDIR}/jenkins/apconfig.py packages)" |
263 | + PACKAGES="$(${BZRDIR}/jenkins/testconfig.py packages -i {{imagetype}})" |
264 | fi |
265 | |
266 | custom_args="" |
267 | @@ -105,12 +105,12 @@ |
268 | fi |
269 | |
270 | if [ "$APPS" = "ALL" ] ; then |
271 | - APPS="$(${BZRDIR}/jenkins/apconfig.py apps)" |
272 | + APPS="$(${BZRDIR}/jenkins/testconfig.py apps -i {{imagetype}})" |
273 | fi |
274 | [ -z "$APPS" ] || APPS=${APPS} ${BZRDIR}/scripts/run-autopilot-tests.sh |
275 | |
276 | if [ "$TESTS" = "ALL" ] ; then |
277 | - TESTS="{{tests}}" |
278 | + TESTS="$(${BZRDIR}/jenkins/testconfig.py tests -i {{imagetype}})" |
279 | fi |
280 | |
281 | rc=0 |
282 | |
283 | === added file 'jenkins/testconfig.py' |
284 | --- jenkins/testconfig.py 1970-01-01 00:00:00 +0000 |
285 | +++ jenkins/testconfig.py 2013-10-24 18:45:43 +0000 |
286 | @@ -0,0 +1,175 @@ |
287 | +#!/usr/bin/env python |
288 | + |
289 | +# Ubuntu Testing Automation Harness |
290 | +# Copyright 2013 Canonical Ltd. |
291 | + |
292 | +# This program is free software: you can redistribute it and/or modify it |
293 | +# under the terms of the GNU General Public License version 3, as published |
294 | +# by the Free Software Foundation. |
295 | + |
296 | +# This program is distributed in the hope that it will be useful, but |
297 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
298 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
299 | +# PURPOSE. See the GNU General Public License for more details. |
300 | + |
301 | +# You should have received a copy of the GNU General Public License along |
302 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
303 | + |
304 | +import argparse |
305 | + |
306 | +DEF_FMT = '{prefix}{series}-{imagetype}-{type}-smoke-{testname}' |
307 | +IDLE_FMT = '{prefix}{testname}-{series}-{imagetype}-armhf-install-idle-{type}' |
308 | + |
309 | + |
310 | +class Test(object): |
311 | + def __init__(self, name, fmt=DEF_FMT): |
312 | + self.name = name |
313 | + self.fmt = fmt |
314 | + |
315 | + |
316 | +class APTest(Test): |
317 | + def __init__(self, name, app=None, pkgs=None): |
318 | + Test.__init__(self, name) |
319 | + self.pkgs = pkgs |
320 | + if not app: |
321 | + # convert share-app-autopilot to share_app |
322 | + app = name.replace('-', '_').replace('_autopilot', '') |
323 | + self.app = app |
324 | + |
325 | + |
326 | +TESTSUITES = [ |
327 | + Test('install-and-boot'), |
328 | + Test('default'), |
329 | +] |
330 | +TESTSUITES += [ |
331 | + APTest('friends-app-autopilot', pkgs=['friends-app-autopilot']), |
332 | + APTest('mediaplayer-app-autopilot', pkgs=['mediaplayer-app-autopilot']), |
333 | + APTest('gallery-app-autopilot', pkgs=['gallery-app-autopilot']), |
334 | + APTest('webbrowser-app-autopilot', pkgs=['webbrowser-app-autopilot']), |
335 | + APTest('unity8-autopilot', 'unity8', pkgs=['python-gi']), |
336 | + APTest('notes-app-autopilot'), |
337 | + APTest('camera-app-autopilot', pkgs=['camera-app-autopilot']), |
338 | + APTest('dialer-app-autopilot', pkgs=['dialer-app-autopilot']), |
339 | + APTest('messaging-app-autopilot', pkgs=['messaging-app-autopilot']), |
340 | + APTest('address-book-app-autopilot', pkgs=['address-book-app-autopilot']), |
341 | + APTest('calendar-app-autopilot'), |
342 | + APTest('music-app-autopilot'), |
343 | + APTest('dropping-letters-app-autopilot'), |
344 | + APTest('ubuntu-calculator-app-autopilot'), |
345 | + APTest('ubuntu-clock-app-autopilot'), |
346 | + APTest('ubuntu-filemanager-app-autopilot'), |
347 | + APTest('ubuntu-rssreader-app-autopilot'), |
348 | + APTest('ubuntu-terminal-app-autopilot'), |
349 | + APTest('ubuntu-weather-app-autopilot'), |
350 | + APTest('ubuntu-ui-toolkit-autopilot', 'ubuntuuitoolkit', |
351 | + ['ubuntu-ui-toolkit-autopilot']), |
352 | + APTest('ubuntu-system-settings-online-accounts-autopilot', |
353 | + 'online_accounts_ui', |
354 | + ['ubuntu-system-settings-online-accounts-autopilot']), |
355 | +] |
356 | +TESTSUITES += [ |
357 | + Test('click_image_tests'), |
358 | + Test('sdk'), |
359 | + Test('security'), |
360 | + Test('eventstat', IDLE_FMT), |
361 | + Test('smem', IDLE_FMT), |
362 | + Test('memevent', |
363 | + '{prefix}{testname}-{series}-{imagetype}-armhf-default-{type}'), |
364 | +] |
365 | + |
366 | + |
367 | +def filter_tests(tests, image_type): |
368 | + if image_type: |
369 | + func = globals().get('get_tests_%s' % image_type) |
370 | + if func: |
371 | + tests = func(tests) |
372 | + elif image_type not in ['touch', 'touch_mir']: |
373 | + print('Unsupported image type: %s' % image_type) |
374 | + exit(1) |
375 | + return tests |
376 | + |
377 | + |
378 | +def _get_tests(test_type, image_type): |
379 | + tests = [t for t in TESTSUITES if type(t) == test_type] |
380 | + return filter_tests(tests, image_type) |
381 | + |
382 | + |
383 | +def _handle_utah(args): |
384 | + tests = _get_tests(Test, args.image_type) |
385 | + # NOTE: this is only called by MEGA jobs, so we can skip install-and-boot |
386 | + print(' '.join([t.name for t in tests if t.name != 'install-and-boot'])) |
387 | + |
388 | + |
389 | +def _handle_ap_apps(args): |
390 | + tests = _get_tests(APTest, args.image_type) |
391 | + print(' '.join([t.app for t in tests])) |
392 | + |
393 | + |
394 | +def _handle_ap_packages(args): |
395 | + pkgs = [] |
396 | + tests = _get_tests(APTest, args.image_type) |
397 | + for test in tests: |
398 | + if not args.app or test.app in args.app: |
399 | + if test.pkgs: |
400 | + pkgs.extend(test.pkgs) |
401 | + print(' '.join(pkgs)) |
402 | + |
403 | + |
404 | +def get_tests_touch_sf4p(common_tests): |
405 | + tests = [] |
406 | + test_set = [ |
407 | + 'install-and-boot', |
408 | + 'default', |
409 | + 'unity8-autopilot', |
410 | + ] |
411 | + |
412 | + tests = [t for t in common_tests if t.name in test_set] |
413 | + return tests |
414 | + |
415 | + |
416 | +def get_tests_touch_custom(common_tests): |
417 | + tests = [] |
418 | + test_set = [ |
419 | + 'install-and-boot', |
420 | + 'default', |
421 | + 'unity8-autopilot', |
422 | + 'webbrowser-app-autopilot', |
423 | + ] |
424 | + |
425 | + tests = [t for t in common_tests if t.name in test_set] |
426 | + tests.insert(1, Test('customizations')) |
427 | + return tests |
428 | + |
429 | + |
430 | +def _get_parser(): |
431 | + parser = argparse.ArgumentParser( |
432 | + description='List information on configured tests for touch') |
433 | + sub = parser.add_subparsers(title='Commands', metavar='') |
434 | + |
435 | + p = sub.add_parser('utah', help='List UTAH tests') |
436 | + p.set_defaults(func=_handle_utah) |
437 | + p.add_argument('-i', '--image-type', |
438 | + help='Return list of test configured for an image type.') |
439 | + |
440 | + p = sub.add_parser('apps', help='List autopilot application names') |
441 | + p.set_defaults(func=_handle_ap_apps) |
442 | + p.add_argument('-i', '--image-type', |
443 | + help='Return list of test configured for an image type.') |
444 | + |
445 | + p = sub.add_parser('packages', help='List packages required for autopilot') |
446 | + p.set_defaults(func=_handle_ap_packages) |
447 | + g = p.add_mutually_exclusive_group() |
448 | + g.add_argument('-i', '--image-type', |
449 | + help='''If no apps are listed, limit to tests for an |
450 | + image type.''') |
451 | + g.add_argument('-a', '--app', action='append', |
452 | + help='Autopilot test application. eg share_app') |
453 | + return parser |
454 | + |
455 | + |
456 | +def main(): |
457 | + args = _get_parser().parse_args() |
458 | + return args.func(args) |
459 | + |
460 | +if __name__ == '__main__': |
461 | + exit(main()) |
Cool, that's useful