Merge lp:~dpniel/ubuntu-autopilot-tests/test-runner into lp:ubuntu-autopilot-tests
- test-runner
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Dan Chapman |
Approved revision: | 70 |
Merged at revision: | 64 |
Proposed branch: | lp:~dpniel/ubuntu-autopilot-tests/test-runner |
Merge into: | lp:ubuntu-autopilot-tests |
Diff against target: |
1054 lines (+995/-0) 9 files modified
README.md (+113/-0) desktop-autopilot-runner/config/testrunner.cfg (+35/-0) desktop-autopilot-runner/custom-installation/hooks/casper-bottom.sh (+30/-0) desktop-autopilot-runner/custom-installation/iso-override/etc/rsyslog.d/50-default.conf (+69/-0) desktop-autopilot-runner/custom-installation/iso-override/etc/xdg/autostart/autopilot.desktop (+9/-0) desktop-autopilot-runner/custom-installation/iso-override/etc/xdg/lxsession/Lubuntu/autostart (+1/-0) desktop-autopilot-runner/custom-installation/iso-override/usr/local/bin/run-autopilot.sh (+332/-0) desktop-autopilot-runner/run-autopilot-test (+392/-0) desktop-autopilot-runner/splitlogs.awk (+14/-0) |
To merge this branch: | bzr merge lp:~dpniel/ubuntu-autopilot-tests/test-runner |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nicholas Skaggs (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
This MP adds a test runner to run the autopilot tests in a pristine environment. See the enclosed README for info on usage.
It work pretty much the same as the ubiquity runner and is just a modified copy of that runner

Nicholas Skaggs (nskaggs) wrote : | # |

Nicholas Skaggs (nskaggs) wrote : | # |
I'm curious about desktop-
deb http://
We're pushing trusty in there; is there a more generic way to specify what we want? Going forward trusty isn't going to be it, and I don't want to push updates for something so trivial.

Nicholas Skaggs (nskaggs) wrote : | # |
Looks good. I know jibel likes to push things into /tmp, so I suppose I'm ok with using /tmp to store the results. I personally don't like putting longterm things in there.
Overall, I approve, just have the one question above.

Dan Chapman (dpniel) wrote : | # |
It's easy enough to either re-write/update the sources.list file. I'll get that updated.
Where would you rather the artefacts ended up? as I want it to be more of a general purpose tool for running any autopilot test than the ubiquity runner currently is.

Nicholas Skaggs (nskaggs) wrote : | # |
I would rather the results ended up in /home.. /home/autopilot

Dan Chapman (dpniel) wrote : | # |
Sounds good to me. I'll change that

Adam Smith (adam-disc0tech) wrote : | # |
It would be great to be able run files from a local path instead of LP.
- 67. By Dan Chapman
-
Removed apt/sources.list and just add-apt-repo universe & multiverse instead
Artifacts are now stored in $HOME/ubuntu_
autopilot. tests instead of /tmp Updated README

Dan Chapman (dpniel) wrote : | # |
Ok so changes made.
1) Removed the hardcoded sources.list and now just enable repositories using add-apt-repository
2) Artefacts now stored in $HOME/ubuntu_
3) Updated README
@Adam From an MP review / Jenkins point of view pulling from bzr branches is ideal, so I don't want to make any changes in this branch. But i agree the ability to use local directories for developing tests would be a nice feature. Once this is merged if you could file a bug for a new feature that would be great :-)
- 68. By Dan Chapman
-
added retrieval of upstart logs for test artefacts
- 69. By Dan Chapman
-
added partner repository
- 70. By Dan Chapman
-
remove partner repo as it's archive.
canonical. com and not archive.ubuntu.com

Nicholas Skaggs (nskaggs) wrote : | # |
Here and I thought this was waiting on you. Approved on my end ;-)
Preview Diff
1 | === added file 'README.md' |
2 | --- README.md 1970-01-01 00:00:00 +0000 |
3 | +++ README.md 2014-03-04 19:06:35 +0000 |
4 | @@ -0,0 +1,113 @@ |
5 | +Introduction |
6 | +============ |
7 | + |
8 | +This document describes how to setup and run automated autopilot tests for desktop applications. |
9 | +The test runner works for Ubuntu, Xubuntu, Lubuntu, Ubuntu-GNOME and Edubuntu. and should work |
10 | +for all other flavours of Ubuntu. |
11 | + |
12 | +Source code: `lp:ubuntu-autopilot-tests` |
13 | + |
14 | +Tests use python3 version of autopilot. So any current tests that use python 2.7 should be ported |
15 | +to be supported by python3 |
16 | + |
17 | + |
18 | +Project Structure |
19 | +================= |
20 | + |
21 | +The project is structured as follow: |
22 | + |
23 | + * *ubuntu-autopilot-tests/* Contains the tests and the test runner |
24 | + |
25 | + * *desktop-autopilot-runner/* Runner to setup a VM from an ISO |
26 | + and execute autopilot tests |
27 | + |
28 | + * *config/* Contains configuration examples to override default values of |
29 | + the runner |
30 | + |
31 | + * *custom-installation/iso-override/* Content of this directory will |
32 | + override the content on the ISO |
33 | + |
34 | + * *ubuntu_autopilot_tests/* Autopilot tests for the default applications in Ubuntu |
35 | + |
36 | + * *xubuntu_autopilot_tests/* Autopilot tests for the default applications in Xubuntu |
37 | + |
38 | + |
39 | +Running the tests |
40 | +================= |
41 | + |
42 | +Directly on local machine |
43 | +---------------------------- |
44 | + |
45 | +Install the following dependencies : |
46 | + |
47 | + $ sudo apt-get install python3-autopilot libautopilot-gtk python3-xlib |
48 | + |
49 | +To run the tests, go to the root folder of the flavor's tests you want to run. |
50 | + |
51 | +Example: |
52 | + |
53 | +Run in Terminal (for ubuntu): |
54 | + |
55 | + $ cd ubiquity-autopilot-tests/ubuntu_autopilot_tests |
56 | + $ autopilot-py3 run TESTNAME (where TESTNAME is the directory name of the application you want to test) |
57 | + |
58 | +To execute the *gedit* test suite, Run in Terminal: |
59 | + |
60 | + $ cd ubiquity-autopilot-tests/ubuntu_autopilot_tests |
61 | + $ autopilot-py3 run gedit |
62 | + |
63 | +Other tests are available from *ubuntu_autopilot_tests/*. To get a list |
64 | +of available tests run: |
65 | + |
66 | + $ autopilot-py3 list ubuntu_autopilot_tests or xubuntu_autopilot_tests |
67 | + |
68 | +On a local machine using the test runner (recommended before proposing a merge for new tests) |
69 | +--------------------------------------------------------------------------------------------- |
70 | + |
71 | + * Install the following dependencies: |
72 | + |
73 | + $ sudo apt-get install bsdtar qemu-system-x86 bzr xz-utils cpio |
74 | + |
75 | + * Download a desktop image from *http//cdimage.ubuntu.com/* |
76 | + |
77 | + * Execute the command: |
78 | + |
79 | + $ ./desktop-autopilot-runner/run-autopilot-test <ISO> |
80 | + e.g |
81 | + $ ./desktop-autopilot-runner/run-autopilot-test ~/iso/ubuntu/trusty-desktop-amd64.iso |
82 | + |
83 | + * All tests are run from the root of the flavors test suite (eg ubuntu_autopilot_tests/*) |
84 | + So all tests need to be abe to run when be started from this point. When specifying a |
85 | + test/testsuite to run, a dot path to a specific test can be used as long as it starts from the |
86 | + suites root directory |
87 | + |
88 | + Example: |
89 | + |
90 | + gedit.test_gedit.GeditWindowTests.test_window_visible |
91 | + |
92 | + |
93 | + * If you want to watch what is running use option `--sdl` |
94 | + |
95 | + * If you want to select a test suite to run use option `--test` (e.g --test fileroller) |
96 | + |
97 | + * If you want need to use any extra packages or select flavor test suite this can be done |
98 | + using a config file, like the one found in ./desktop-autopilot-runner/config/testrunner.cfg. |
99 | + And can be used with the `-T` and `--testconfig` options. Also see config for other available options |
100 | + |
101 | + * If your system has enough memory you can run tests in memory (in /dev/shm |
102 | + actually) with option `-s|--shm` |
103 | + |
104 | + * If you require test environment to continue running after the test, |
105 | + you can set no shutdown in the config file. |
106 | + |
107 | + Note: this is still restricted by the global timeout of the test runner which can be overridden |
108 | + by setting the TIMOUT variable when executing the runner |
109 | + |
110 | + Example: |
111 | + |
112 | + $ TIMEOUT=123412341234 ./desktop-autopilot-runner/run-autopilot-test --sdl ~/iso/ubuntu/trusty-desktop-amd64.iso |
113 | + |
114 | + * And of course `-h|--help` for a list of available options |
115 | + |
116 | + * At the end of the run, results are collected in your home directory`$HOME/ubuntu_autopilot.tests` |
117 | + |
118 | |
119 | === added directory 'desktop-autopilot-runner' |
120 | === added directory 'desktop-autopilot-runner/config' |
121 | === added file 'desktop-autopilot-runner/config/testrunner.cfg' |
122 | --- desktop-autopilot-runner/config/testrunner.cfg 1970-01-01 00:00:00 +0000 |
123 | +++ desktop-autopilot-runner/config/testrunner.cfg 2014-03-04 19:06:35 +0000 |
124 | @@ -0,0 +1,35 @@ |
125 | +# |
126 | +# Example configuration file for the test runner |
127 | +# This file allows user to override some of the variables defined in the |
128 | +# testrunner |
129 | +# |
130 | +# Branch to fetch containing autopilot tests |
131 | +TSBRANCH=lp:ubuntu-autopilot-tests |
132 | + |
133 | +# Testsuite directory for flavor under test |
134 | +FLAVOR_TESTSUITE="ubuntu_autopilot_tests" |
135 | + |
136 | +# Additional artifacts to collect at the end of the test |
137 | +ARTIFACTS="/var/log/upstart/" |
138 | + |
139 | +# Additional options for autopilot |
140 | +# -f xml <FILE> is always appended to this option |
141 | +AP_OPTS="-v" |
142 | + |
143 | +# By default the test environment powers off at the end of the test. Set this to |
144 | +# 0 to keep it running |
145 | +SHUTDOWN=0 |
146 | + |
147 | +# Extra packages to install. EXTRAPACKAGE is appended to PACKAGES defined in the |
148 | +# runner |
149 | +EXTRAPACKAGES="eatmydata" |
150 | + |
151 | +# Test timeout. |
152 | +# Note that this apply to autopilot running inside the test environment and |
153 | +# doesn't affect the global timeout of the runner set in the main script |
154 | +TIMEOUT=600 |
155 | + |
156 | +# Debug Mode |
157 | +# Set to 1 to enable debug mode. This will start an xterm in the live session |
158 | +# for example. |
159 | +DEBUG=1 |
160 | |
161 | === added directory 'desktop-autopilot-runner/custom-installation' |
162 | === added directory 'desktop-autopilot-runner/custom-installation/hooks' |
163 | === added file 'desktop-autopilot-runner/custom-installation/hooks/casper-bottom.sh' |
164 | --- desktop-autopilot-runner/custom-installation/hooks/casper-bottom.sh 1970-01-01 00:00:00 +0000 |
165 | +++ desktop-autopilot-runner/custom-installation/hooks/casper-bottom.sh 2014-03-04 19:06:35 +0000 |
166 | @@ -0,0 +1,30 @@ |
167 | +#!/bin/sh |
168 | + |
169 | +# |
170 | +# Put here every steps that must be executed on the target system and can not |
171 | +# be done with the iso-override facility |
172 | +# |
173 | + |
174 | +PREREQ="" |
175 | +DESCRIPTION="Running custom script..." |
176 | + |
177 | +prereqs() |
178 | +{ |
179 | + echo "$PREREQ" |
180 | +} |
181 | + |
182 | +case $1 in |
183 | +# get pre-requisites |
184 | + prereqs) |
185 | + prereqs |
186 | + exit 0 |
187 | + ;; |
188 | +esac |
189 | + |
190 | +. /scripts/casper-functions |
191 | + |
192 | +log_begin_msg "$DESCRIPTION" |
193 | + |
194 | +sed -i 's/^%admin.*/%admin ALL=(ALL) NOPASSWD: ALL/' /root/etc/sudoers |
195 | + |
196 | +log_end_msg |
197 | |
198 | === added directory 'desktop-autopilot-runner/custom-installation/iso-override' |
199 | === added directory 'desktop-autopilot-runner/custom-installation/iso-override/etc' |
200 | === added directory 'desktop-autopilot-runner/custom-installation/iso-override/etc/rsyslog.d' |
201 | === added file 'desktop-autopilot-runner/custom-installation/iso-override/etc/rsyslog.d/50-default.conf' |
202 | --- desktop-autopilot-runner/custom-installation/iso-override/etc/rsyslog.d/50-default.conf 1970-01-01 00:00:00 +0000 |
203 | +++ desktop-autopilot-runner/custom-installation/iso-override/etc/rsyslog.d/50-default.conf 2014-03-04 19:06:35 +0000 |
204 | @@ -0,0 +1,69 @@ |
205 | +# Default rules for rsyslog. |
206 | +# |
207 | +# For more information see rsyslog.conf(5) and /etc/rsyslog.conf |
208 | + |
209 | +# |
210 | +# First some standard log files. Log by facility. |
211 | +# |
212 | +auth,authpriv.* /var/log/auth.log |
213 | +*.*;auth,authpriv.none -/dev/ttyS0 |
214 | +*.*;auth,authpriv.none -/var/log/syslog |
215 | +#cron.* /var/log/cron.log |
216 | +#daemon.* -/var/log/daemon.log |
217 | +kern.* -/var/log/kern.log |
218 | +#lpr.* -/var/log/lpr.log |
219 | +mail.* -/var/log/mail.log |
220 | +#user.* -/var/log/user.log |
221 | + |
222 | +# |
223 | +# Logging for the mail system. Split it up so that |
224 | +# it is easy to write scripts to parse these files. |
225 | +# |
226 | +#mail.info -/var/log/mail.info |
227 | +#mail.warn -/var/log/mail.warn |
228 | +mail.err /var/log/mail.err |
229 | + |
230 | +# |
231 | +# Logging for INN news system. |
232 | +# |
233 | +news.crit /var/log/news/news.crit |
234 | +news.err /var/log/news/news.err |
235 | +news.notice -/var/log/news/news.notice |
236 | + |
237 | +# |
238 | +# Some "catch-all" log files. |
239 | +# |
240 | +#*.=debug;\ |
241 | +# auth,authpriv.none;\ |
242 | +# news.none;mail.none -/var/log/debug |
243 | +#*.=info;*.=notice;*.=warn;\ |
244 | +# auth,authpriv.none;\ |
245 | +# cron,daemon.none;\ |
246 | +# mail,news.none -/var/log/messages |
247 | + |
248 | +# |
249 | +# Emergencies are sent to everybody logged in. |
250 | +# |
251 | +*.emerg * |
252 | + |
253 | +# |
254 | +# I like to have messages displayed on the console, but only on a virtual |
255 | +# console I usually leave idle. |
256 | +# |
257 | +#daemon,mail.*;\ |
258 | +# news.=crit;news.=err;news.=notice;\ |
259 | +# *.=debug;*.=info;\ |
260 | +# *.=notice;*.=warn /dev/ttyS0 |
261 | + |
262 | +# The named pipe /dev/xconsole is for the `xconsole' utility. To use it, |
263 | +# you must invoke `xconsole' with the `-file' option: |
264 | +# |
265 | +# $ xconsole -file /dev/xconsole [...] |
266 | +# |
267 | +# NOTE: adjust the list below, or you'll go crazy if you have a reasonably |
268 | +# busy site.. |
269 | +# |
270 | +daemon.*;mail.*;\ |
271 | + news.err;\ |
272 | + *.=debug;*.=info;\ |
273 | + *.=notice;*.=warn |/dev/xconsole |
274 | |
275 | === added directory 'desktop-autopilot-runner/custom-installation/iso-override/etc/xdg' |
276 | === added directory 'desktop-autopilot-runner/custom-installation/iso-override/etc/xdg/autostart' |
277 | === added file 'desktop-autopilot-runner/custom-installation/iso-override/etc/xdg/autostart/autopilot.desktop' |
278 | --- desktop-autopilot-runner/custom-installation/iso-override/etc/xdg/autostart/autopilot.desktop 1970-01-01 00:00:00 +0000 |
279 | +++ desktop-autopilot-runner/custom-installation/iso-override/etc/xdg/autostart/autopilot.desktop 2014-03-04 19:06:35 +0000 |
280 | @@ -0,0 +1,9 @@ |
281 | +[Desktop Entry] |
282 | +Encoding=UTF-8 |
283 | +Name=Fire-up Autopilot tests for Ubiquity |
284 | +Comment=Starts the Autopilot tests |
285 | +Exec=/usr/local/bin/run-autopilot.sh -R |
286 | +Terminal=false |
287 | +Type=Application |
288 | +Categories= |
289 | +X-GNOME-Autostart-Delay=10 |
290 | |
291 | === added directory 'desktop-autopilot-runner/custom-installation/iso-override/etc/xdg/lxsession' |
292 | === added directory 'desktop-autopilot-runner/custom-installation/iso-override/etc/xdg/lxsession/Lubuntu' |
293 | === added file 'desktop-autopilot-runner/custom-installation/iso-override/etc/xdg/lxsession/Lubuntu/autostart' |
294 | --- desktop-autopilot-runner/custom-installation/iso-override/etc/xdg/lxsession/Lubuntu/autostart 1970-01-01 00:00:00 +0000 |
295 | +++ desktop-autopilot-runner/custom-installation/iso-override/etc/xdg/lxsession/Lubuntu/autostart 2014-03-04 19:06:35 +0000 |
296 | @@ -0,0 +1,1 @@ |
297 | +@/usr/local/bin/run-autopilot.sh -R |
298 | |
299 | === added directory 'desktop-autopilot-runner/custom-installation/iso-override/usr' |
300 | === added directory 'desktop-autopilot-runner/custom-installation/iso-override/usr/local' |
301 | === added directory 'desktop-autopilot-runner/custom-installation/iso-override/usr/local/bin' |
302 | === added file 'desktop-autopilot-runner/custom-installation/iso-override/usr/local/bin/run-autopilot.sh' |
303 | --- desktop-autopilot-runner/custom-installation/iso-override/usr/local/bin/run-autopilot.sh 1970-01-01 00:00:00 +0000 |
304 | +++ desktop-autopilot-runner/custom-installation/iso-override/usr/local/bin/run-autopilot.sh 2014-03-04 19:06:35 +0000 |
305 | @@ -0,0 +1,332 @@ |
306 | +#!/bin/sh |
307 | + |
308 | +# |
309 | +# This script runs autopilot |
310 | + |
311 | +# Copyright (C) 2013, Canonical Ltd (http://www.canonical.com/) |
312 | +# |
313 | +# Author: Jean-Baptiste Lallement <jean-baptiste.lallement@canonical.com> |
314 | +# Dan Chapman <dpniel@ubuntu.com> (Modified from original ubiquity |
315 | +# autopilot test runner) |
316 | +# |
317 | +# This software is free software: you can redistribute it |
318 | +# and/or modify it under the terms of the GNU General Public License |
319 | +# as published by the Free Software Foundation, either version 3 of |
320 | +# the License, or (at your option) any later version. |
321 | +# |
322 | +# This software is distributed in the hope that it will |
323 | +# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
324 | +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
325 | +# GNU General Public License for more details. |
326 | +# |
327 | +# You should have received a copy of the GNU General Public License |
328 | +# along with this software. If not, see <http://www.gnu.org/licenses/>. |
329 | +# |
330 | +set -eu |
331 | + |
332 | +# Lock management to prevent this script of running twice |
333 | +LOCKFILE=/tmp/$(basename $0).lock |
334 | +if [ -e ${LOCKFILE} ] && kill -0 $(cat ${LOCKFILE}); then |
335 | + echo "W: $(basename $0) already running. Exiting!" |
336 | + exit |
337 | +fi |
338 | +echo $$>${LOCKFILE} |
339 | + |
340 | +# The following variables can be overridden with a configuration file |
341 | +TSBRANCH=lp:ubuntu-autopilot-tests/production |
342 | +FLAVOR_TESTSUITE="ubuntu_autopilot_tests" |
343 | +EXTRAPACKAGES="" |
344 | +ARTIFACTS="" |
345 | +AP_OPTS="-vv" |
346 | +SHUTDOWN=1 |
347 | +TIMEOUT=1200 # 20min timeout |
348 | +DEBUG=0 |
349 | + |
350 | +# Custom configuration |
351 | +# Do not use the variable TESTBASE because we don't want it to be overridden |
352 | +[ -f /var/local/autopilot/config ] && . /var/local/autopilot/config |
353 | + |
354 | +TESTBASE=/var/local/autopilot/ |
355 | +AP_ARTIFACTS=$TESTBASE/videos/ |
356 | +AP_RESULTS=$TESTBASE/junit/ |
357 | +AP_LOGS=$TESTBASE/logs/ |
358 | +AP_TESTSUITES=$TESTBASE/testsuites |
359 | +AP_LOGFILE=$AP_LOGS/autopilot.log |
360 | +AP_SUMMARY=$AP_LOGS/summary.log |
361 | +AP_INFO=$AP_LOGS/build_info.txt |
362 | +RMD_OPTS="-r -rd $AP_ARTIFACTS --record-options=--fps=6,--no-wm-check" |
363 | +SPOOLDIR=$TESTBASE/spool |
364 | +TSEXPORT=$HOME/ubuntu_autopilot-autopilot |
365 | +SESSION_LOG="" |
366 | +# Append mandatory artifacts |
367 | +ARTIFACTS="$TESTBASE /var/log/syslog /var/crash $HOME/.cache/upstart $ARTIFACTS" |
368 | + |
369 | + |
370 | +# Specific configurations for various DE |
371 | +case $SESSION in |
372 | + ubuntu) # Covers Ubuntu and Edubuntu |
373 | + SESSION_LOG=$HOME/.cache/upstart/gnome-session.log |
374 | + ;; |
375 | + xubuntu) |
376 | + SESSION_LOG=$HOME/.cache/upstart/startxfce4.log |
377 | + ;; |
378 | + Lubuntu) |
379 | + SESSION_LOG=$HOME/.cache/lxsession/Lubuntu/run.log |
380 | + ARTIFACTS="$ARTIFACTS $HOME/.cache/lxsession" |
381 | + ;; |
382 | + gnome) # ubuntu-gnome |
383 | + SESSION_LOG=$HOME/.cache/upstart/gnome-session.log |
384 | +esac |
385 | + |
386 | +PACKAGES="bzr ssh python3-autopilot libautopilot-gtk python3-xlib \ |
387 | + recordmydesktop" |
388 | + |
389 | +export DEBIAN_FRONTEND=noninteractive |
390 | + |
391 | +on_exit() { |
392 | + # Exit handler |
393 | + echo "I: Archiving artifacts" |
394 | + archive=/tmp/artifacts |
395 | + |
396 | + |
397 | + |
398 | + for artifact in $ARTIFACTS; do |
399 | + [ -e "$artifact" ] && sudo tar rf ${archive}.tar $artifact || true |
400 | + done |
401 | + |
402 | + # Find a better way. ttys are a bit limited and sometimes output is |
403 | + # truncated or messages are skipped by the kernel if it goes too fast. |
404 | + if [ -f ${archive}.tar ]; then |
405 | + sudo stty -F /dev/ttyS1 raw speed 115200 |
406 | + gzip -9 -c ${archive}.tar > ${archive}.tgz |
407 | + sudo sh -c "cat ${archive}.tgz>/dev/ttyS1" |
408 | + fi |
409 | + |
410 | + rm -f ${LOCKFILE} |
411 | + shutdown_host |
412 | +} |
413 | +trap on_exit EXIT INT QUIT ABRT PIPE TERM |
414 | + |
415 | +usage() { |
416 | + # Display usage and exit |
417 | + cat<<EOF |
418 | +Usage: $(basename $0) [OPTIONS...] |
419 | +Run autopilot tests in $SPOOLDIR |
420 | + |
421 | +Options: |
422 | + -h, --help This help |
423 | + -d, --debug Enable debug mode |
424 | + -N, --new Restart all the tests in $AP_TESTSUITES otherwise |
425 | + only the remaining tests in $SPOOLDIR are run |
426 | + -R, --norecord Do not use recordmydesktop. |
427 | + -S, --noshutdown |
428 | + Do not shutdown the system after the tests |
429 | + |
430 | +EOF |
431 | + exit 1 |
432 | +} |
433 | + |
434 | +# retry command a certain number of time |
435 | +# $1 is the number of retry |
436 | +# $2 is the delay in second between retries |
437 | +# the command is then passed |
438 | +retry_cmd() { |
439 | + # Tries to execute $@ $loop times with a delay of $delay between retries |
440 | + # before aborting |
441 | + loop=$1 |
442 | + loopcnt=$1 # Just used to print the status on failure |
443 | + delay=$2 |
444 | + shift |
445 | + shift |
446 | + while [ $loop -gt 0 ]; do |
447 | + rc=0 |
448 | + $@ || rc=$? |
449 | + [ $rc -eq 0 ] && return |
450 | + loop=$((loop - 1)) |
451 | + sleep $delay |
452 | + done |
453 | + |
454 | + echo "E: Command failed after $loopcnt tries: $@" |
455 | + echo "E: Aborting!" |
456 | + exit 1 |
457 | +} |
458 | + |
459 | +setup_tests() { |
460 | + # Prepares the environment for the tests |
461 | + flag=$HOME/.ap_setup_done |
462 | + |
463 | + [ -e "$flag" ] && return 0 |
464 | + |
465 | + |
466 | + if [ $DEBUG -ne 0 ]; then |
467 | + # Put here everything you want to run in debug mode |
468 | + xterm & # Easier to debug from a live session, and rarely broken |
469 | + fi |
470 | + |
471 | + sudo stty -F /dev/ttyS0 raw speed 115200 |
472 | + |
473 | + tail_logs $SESSION_LOG /var/log/syslog |
474 | + # Disable notifications and screensaver |
475 | + if which gsettings >/dev/null 2>&1; then |
476 | + echo "I: Disabling crash notifications" |
477 | + gsettings set com.ubuntu.update-notifier show-apport-crashes false |
478 | + echo "I: Disabling screensaver" |
479 | + gsettings set org.gnome.desktop.screensaver idle-activation-enabled false |
480 | + fi |
481 | + |
482 | + # Loads the list of test and queue them in test spool |
483 | + sudo mkdir -p $SPOOLDIR $AP_ARTIFACTS $AP_RESULTS $AP_LOGS |
484 | + sudo chown -R $USER:$USER $TESTBASE $SPOOLDIR $AP_ARTIFACTS $AP_RESULTS $AP_LOGS |
485 | + |
486 | + echo "I: enabling universe and multiverse repositories" |
487 | + retry_cmd 3 30 sudo add-apt-repository universe -y |
488 | + retry_cmd 3 30 sudo add-apt-repository multiverse -y |
489 | + # add partner repository aswell |
490 | + #retry_cmd 3 30 sudo add-apt-repository "deb http://archive.canonical.com/ubuntu $(lsb_release -sc) partner" -y |
491 | + |
492 | + echo "I: Installating additional packages" |
493 | + retry_cmd 3 30 sudo apt-get update |
494 | + retry_cmd 3 30 sudo apt-get install -yq $PACKAGES $EXTRAPACKAGES |
495 | + |
496 | + |
497 | + echo "I: Branch $TSBRANCH" |
498 | + bzr export $TSEXPORT $TSBRANCH |
499 | + |
500 | + if [ -e "$AP_TESTSUITES" ]; then |
501 | + (cd $SPOOLDIR; touch $(cat $AP_TESTSUITES)) |
502 | + fi |
503 | + |
504 | + cat>$AP_INFO<<EOF |
505 | +Image Id: $(cat /cdrom/.disk/info) |
506 | +Test branch: ${TSBRANCH} |
507 | +Test revno: $(bzr revno $TSBRANCH) |
508 | +EOF |
509 | + |
510 | + cat<<EOF |
511 | + |
512 | +============================== Test Info ============================== |
513 | +$(cat $AP_INFO) |
514 | +======================================================================= |
515 | + |
516 | +EOF |
517 | + touch $flag |
518 | + |
519 | + dpkg -l > $AP_LOGS/packages.list |
520 | +} |
521 | + |
522 | +shutdown_host() { |
523 | + # Shutdown host |
524 | + sleep 10 |
525 | + if [ $SHUTDOWN -eq 1 ]; then |
526 | + echo "I: Shutting down test environment" |
527 | + sudo shutdown -h now |
528 | + else |
529 | + echo "I: Shutdown disabled, host will keep running" |
530 | + fi |
531 | +} |
532 | + |
533 | +tail_logs() { |
534 | + # Tail log files in -F mode in background |
535 | + # |
536 | + # $@ List of log files |
537 | + for log in $@; do |
538 | + if [ -f "$log" ]; then |
539 | + sudo sh -c "/bin/busybox tail -n0 -f $log | mawk -Winteractive -v logfile=\"$log\" '{print logfile\":\",\$0}' > /dev/ttyS0" & |
540 | + fi |
541 | + done |
542 | + } |
543 | + |
544 | + |
545 | +run_tests() { |
546 | + # Runs all the tests in spooldir |
547 | + # |
548 | + # $1: Spool directory |
549 | + spooldir=$1 |
550 | + if [ ! -d $spooldir ]; then |
551 | + echo "E: '$spooldir is not a directory. Exiting!" |
552 | + exit 1 |
553 | + fi |
554 | + |
555 | + if ! which autopilot-py3 >/dev/null 2>&1; then |
556 | + echo "E: autopilot is required to run autopilot tests" |
557 | + echo "autopilot_installed (see autopilot.log for details): ERROR" >> $AP_SUMMARY |
558 | + shutdown_host |
559 | + exit 1 |
560 | + fi |
561 | + echo "autopilot_installed: PASS" >> $AP_SUMMARY |
562 | + |
563 | + exec >>$AP_LOGFILE |
564 | + exec 2>&1 |
565 | + touch $AP_LOGFILE |
566 | + tail_logs $AP_LOGFILE |
567 | + |
568 | + echo "Running autopilot tests" |
569 | + cd $TSEXPORT/$FLAVOR_TESTSUITE/ |
570 | + |
571 | + tail_logs /var/log/installer/debug |
572 | + for testfile in $(ls -d $spooldir/* 2>/dev/null); do |
573 | + testname=$(basename $testfile) |
574 | + echo "I: Running autopilot run $testname $AP_OPTS -o $AP_RESULTS/$testname.xml" |
575 | + aprc=0 |
576 | + timeout -s 9 -k 30 $TIMEOUT autopilot-py3 run $testname $AP_OPTS -f xml -o $AP_RESULTS/${testname}.xml||aprc=$? |
577 | + if [ $aprc -gt 0 ]; then |
578 | + echo "${testname}: FAIL" >> $AP_SUMMARY |
579 | + else |
580 | + echo "${testname}: DONE" >> $AP_SUMMARY |
581 | + fi |
582 | + sudo rm -f $testfile |
583 | + done |
584 | +} |
585 | + |
586 | +reset_test() { |
587 | + # Reset the tests for a new run |
588 | + rm -f $HOME/.ap_setup_done $AP_SUMMARY $AP_LOGFILE $SPOOLDIR/* $AP_ARTIFACTS/* $AP_RESULTS/* |
589 | +} |
590 | +SHORTOPTS="hdNRS" |
591 | +LONGOPTS="help,debug,new,norecord,noshutdown" |
592 | + |
593 | +TEMP=$(getopt -o $SHORTOPTS --long $LONGOPTS -- "$@") |
594 | +eval set -- "$TEMP" |
595 | + |
596 | +while true ; do |
597 | + case "$1" in |
598 | + -h|--help) |
599 | + usage;; |
600 | + -d|--debug) |
601 | + set -x |
602 | + shift;; |
603 | + -N|--new) |
604 | + reset_test |
605 | + shift;; |
606 | + -R|--norecord) |
607 | + RMD_OPTS="" |
608 | + shift;; |
609 | + -S|--noshutdown) |
610 | + SHUTDOWN=0 |
611 | + shift;; |
612 | + --) shift; |
613 | + break;; |
614 | + *) usage;; |
615 | + esac |
616 | +done |
617 | + |
618 | +setup_tests |
619 | +if [ -f "/usr/lib/libeatmydata/libeatmydata.so" ]; then |
620 | + echo "I: Enabling eatmydata" |
621 | + export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}/usr/lib/libeatmydata/libeatmydata.so" |
622 | +fi |
623 | +# Specific option for recordmydesktop for unity tests |
624 | +# It is suspected to caused memory fragmentation and make the test crash |
625 | +if [ -e "$AP_TESTSUITES" ]; then |
626 | + if grep -qw "unity" "$AP_TESTSUITES" 2>/dev/null; then |
627 | + RMD_OPTS="$RMD_OPTS --record-options=--fps=6,--no-wm-check" |
628 | + fi |
629 | +fi |
630 | + |
631 | +if which recordmydesktop >/dev/null 2>&1; then |
632 | + AP_OPTS="$AP_OPTS $RMD_OPTS" |
633 | +fi |
634 | + |
635 | +run_tests $SPOOLDIR |
636 | + |
637 | +exit 0 |
638 | |
639 | === added directory 'desktop-autopilot-runner/custom-installation/packages' |
640 | === added file 'desktop-autopilot-runner/run-autopilot-test' |
641 | --- desktop-autopilot-runner/run-autopilot-test 1970-01-01 00:00:00 +0000 |
642 | +++ desktop-autopilot-runner/run-autopilot-test 2014-03-04 19:06:35 +0000 |
643 | @@ -0,0 +1,392 @@ |
644 | +#!/bin/bash |
645 | + |
646 | +# |
647 | +# Run Ubuntu Desktop Autopilot Tests in KVM |
648 | +# |
649 | +# This script prepares a test environment to run ubuntu autopilot test, run |
650 | +# the tests and collect test artifacts |
651 | +# |
652 | + |
653 | +# Copyright (C) 2013, Canonical Ltd (http://www.canonical.com/) |
654 | +# |
655 | +# Author: Jean-Baptiste Lallement <jean-baptiste.lallement@canonical.com> |
656 | +# Dan Chapman <dpniel@ubuntu.com> (Modified from original ubiquity |
657 | +# autopilot test runner) |
658 | +# |
659 | +# This software is free software: you can redistribute it |
660 | +# and/or modify it under the terms of the GNU General Public License |
661 | +# as published by the Free Software Foundation, either version 3 of |
662 | +# the License, or (at your option) any later version. |
663 | +# |
664 | +# This software is distributed in the hope that it will |
665 | +# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
666 | +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
667 | +# GNU General Public License for more details. |
668 | +# |
669 | +# You should have received a copy of the GNU General Public License |
670 | +# along with this software. If not, see <http://www.gnu.org/licenses/>. |
671 | +# |
672 | +set -u |
673 | + |
674 | +RC=0 |
675 | +BINDIR=$(dirname $(readlink -f $0)) |
676 | + |
677 | +DISKSIZE=12G |
678 | +RAMSIZE=2048 |
679 | +VCPU=2 |
680 | +REQUIREDPKGS="bsdtar qemu-system-x86 bzr xz-utils cpio" |
681 | +OVERRIDEDIR="" |
682 | +WORKSPACE="${WORKSPACE:-$HOME/ubuntu_autopilot.tests}" |
683 | +TESTNAME="${TESTNAME:-gedit}" |
684 | +TESTCONFIG="" |
685 | +TIMEOUT=${TIMEOUT:-3600} |
686 | +DELAY=5 |
687 | +SSHPORT=$(shuf -i 2000-65000 -n 1 -z) |
688 | +VNCPORT=$(shuf -i 1-2000 -n 1 -z) |
689 | +VNCOPTS="-vnc localhost:$VNCPORT" |
690 | + |
691 | +QEMUOPTS="-m $RAMSIZE -smp $VCPU \ |
692 | + -localtime -no-reboot \ |
693 | + -net nic,model=virtio -net user -redir tcp:$SSHPORT::22 \ |
694 | + -daemonize |
695 | + " |
696 | + |
697 | +STARTAT=$(date) |
698 | +ENDAT="" |
699 | + |
700 | +on_exit() { |
701 | + # Exit Handler |
702 | + # |
703 | + # Exit program with status in $RC |
704 | + [ -n "$ENDAT" ] && exit $RC |
705 | + ENDAT=$(date) |
706 | + if [ -f "$WORKDIR/qemu.pid" ]; then |
707 | + echo "I: Terminating qemu" |
708 | + kill -9 $(cat $WORKDIR/qemu.pid) 2>/dev/null |
709 | + fi |
710 | + echo "I: Cleaning working directory" |
711 | + [ -f "$DISKIMG" ] && rm -f "$DISKIMG" |
712 | + [ -d "$WORKDIR" ] && rm -Rf "$WORKDIR" |
713 | + |
714 | + hrule |
715 | + echo -en "Run ended on $ENDAT\n" |
716 | + hrule |
717 | + exit $RC |
718 | +} |
719 | + |
720 | +trap on_exit EXIT INT QUIT ABRT PIPE TERM |
721 | +WORKDIR=$(mktemp -d /tmp/$(basename $0).XXXXXX) |
722 | +DISKDIR=$WORKDIR |
723 | +DISKIMG="" |
724 | + |
725 | +usage() { |
726 | + # Display script usage |
727 | + cat<<EOF |
728 | +Usage: $(basename $0) [OPTIONS...] <iso file> |
729 | + Prepares a system from an ISO and run autopilot tests for ubuntu_autopilot |
730 | + |
731 | +Arguments: |
732 | + <iso file> Path to a valid Ubuntu Desktop ISO |
733 | +Options: |
734 | + -h, --help This help |
735 | + -d, --debug Enable debug mode |
736 | + -o, --override PATH |
737 | + Directory to copy into the target filesystem |
738 | + -S, --disksize DISKSIZE |
739 | + Set disk size (default: $DISKSIZE) |
740 | + -s, --shm Write disk image into /dev/shm |
741 | + --sdl Uses SDL instead of VNC by default |
742 | + -t, --test TESTNAME |
743 | + Name of the test to run (default: $TESTNAME) |
744 | + -T, --testconfig FILE |
745 | + Load test configuration from FILE |
746 | + |
747 | +EOF |
748 | + RC=1 && exit |
749 | +} |
750 | + |
751 | +hrule() { seq -s_ 78|tr -d [[:digit:]]; echo; } |
752 | + |
753 | +check_prerequisites() { |
754 | + # Check and set requirements to run this test |
755 | + # |
756 | + # Check and set the requirements to run this test. If any of the |
757 | + # requirement is missing the programs exit with error |
758 | + # |
759 | + # Args: |
760 | + # $@: List of required packages |
761 | + # |
762 | + # Returns |
763 | + # Exit program is a requirement is not met |
764 | + echo "I: Checking system requirements" |
765 | + for pkg in $@; do |
766 | + if ! dpkg-query -W -f'${Status}' $pkg|grep -q "install ok installed" 2>/dev/null; then |
767 | + echo "E: $pkg is required and not installed on this system. Exiting!" |
768 | + RC=1 |
769 | + exit |
770 | + fi |
771 | + done |
772 | + |
773 | + QEMUCMD=$(which qemu-system-x86_64||true) |
774 | + if [ -z "$QEMUCMD" ]; then |
775 | + echo "E: qemu is required and not installed on this system (run sudo apt-get install qemu). Exiting!" |
776 | + RC=1 |
777 | + exit |
778 | + fi |
779 | + QEMUCMD="$(which eatmydata 2>/dev/null||true) $QEMUCMD" |
780 | + QEMUOPTS="$QEMUOPTS -enable-kvm $VNCOPTS" |
781 | + |
782 | +} |
783 | + |
784 | +extract_kernel() { |
785 | + # Extract kernel and initrd |
786 | + # |
787 | + # Extract kernel and initrd from an ISO image |
788 | + # |
789 | + # Args: |
790 | + # $1: Path to a valid ISO |
791 | + # $2: Destination directory |
792 | + src=$1 |
793 | + dst=$2 |
794 | + echo "I: Extracting kernel and initrd from iso" |
795 | + |
796 | + if [ ! -f "$src" ]; then |
797 | + echo "E: The file '$src' does not exists. Exiting!" |
798 | + RC=2 |
799 | + exit |
800 | + fi |
801 | + |
802 | + if [ ! -d "$dst" ]; then |
803 | + echo "E: The directory '$dst' does not exists or is not a directory. Exiting!" |
804 | + RC=2 |
805 | + exit |
806 | + fi |
807 | + |
808 | + files="casper/initrd.lz casper/$(basename $KERNEL)" |
809 | + echo "I: extracting files from $src: $files" |
810 | + bsdtar xf $src -C $dst $files |
811 | + ret=$? |
812 | + if [ $ret -gt 0 ]; then |
813 | + echo "E: bsdtar failed. Aborting!" |
814 | + RC=$ret |
815 | + exit |
816 | + fi |
817 | +} |
818 | + |
819 | +create_disk_image() { |
820 | + # Create a disk image |
821 | + # |
822 | + # Args: |
823 | + # $1: Path of the disk image to create |
824 | + # $2: Size of the disk |
825 | + diskpath=$1 |
826 | + disksize=$2 |
827 | + echo "I: Creating disk image" |
828 | + qemu-img create -f qcow2 $diskpath $disksize |
829 | + ret=$? |
830 | + if [ $ret -gt 0 ]; then |
831 | + echo "E: qemu-img create failed. Aborting!" |
832 | + RC=$ret |
833 | + exit |
834 | + fi |
835 | +} |
836 | +prepare_initrd() { |
837 | + # Put test payload into initrd |
838 | + # |
839 | + # Prepares the initrd and loads a payload that'll botstrap the test |
840 | + # |
841 | + # Args: |
842 | + # $1: working directory |
843 | + # $2: Path to initrd |
844 | + # $3: Path to test directory that contains the override of the target |
845 | + # file system |
846 | + # Returns: |
847 | + # Nothing |
848 | + workdir=$1/initrd |
849 | + initrd=$2 |
850 | + initrdlz=${initrd}.lz |
851 | + usercustomdir=$3 |
852 | + customdir=${BINDIR}/custom-installation |
853 | + |
854 | + echo "I: Preparing initrd" |
855 | + if [ ! -f "$initrdlz" ]; then |
856 | + echo "E: file '$(basename $initrdlz)' not found. Aborting!" |
857 | + RC=1 |
858 | + exit |
859 | + fi |
860 | + mkdir -p $workdir |
861 | + |
862 | + ( |
863 | + cd $workdir |
864 | + xzcat $initrdlz|cpio --quiet -ivd 2>/dev/null |
865 | + echo "I: Copying overrides" |
866 | + cp -af $customdir $workdir/ |
867 | + [ -d "$usercustomdir" ] && cp -af "$usercustomdir" $workdir/ |
868 | + mkdir -p $workdir/custom-installation/iso-override/var/local/autopilot |
869 | + echo "$TESTNAME" > $workdir/custom-installation/iso-override/var/local/autopilot/testsuites |
870 | + [ -f "$TESTCONFIG" ] && cp $TESTCONFIG $workdir/custom-installation/iso-override/var/local/autopilot/config |
871 | + |
872 | + echo "I: Repacking initrd" |
873 | + [ -f "$initrd" ] && rm -f $initrd |
874 | + find .|cpio --quiet -o -H newc > $initrd |
875 | + ) |
876 | +} |
877 | + |
878 | +boot_image() { |
879 | + # Boot an image with a iso, a kernel, an initrd and a kernel cmdline |
880 | + # |
881 | + # Args: |
882 | + # $1: Working directory |
883 | + # $1: Path to ISO file |
884 | + # $2: Path to disk image |
885 | + # $3: Path to initrd file |
886 | + # $4: Path to kernel file |
887 | + # $5: Kernel command line |
888 | + workdir=$1 |
889 | + isofile=$2 |
890 | + diskimg=$3 |
891 | + initrd=$4 |
892 | + kernel=$5 |
893 | + cmdline="$6" |
894 | + |
895 | + for f in $2 $3 $4 $5; do |
896 | + if [ ! -f "$f" ]; then |
897 | + echo "E: Required file not found. Aborting!" |
898 | + RC=1 |
899 | + exit |
900 | + fi |
901 | + done |
902 | + echo "I: Booting image" |
903 | + |
904 | + $QEMUCMD $QEMUOPTS -drive file=$diskimg,if=virtio -cdrom $isofile -boot d \ |
905 | + -initrd $initrd -kernel $kernel -append "$cmdline" \ |
906 | + -serial file:$workdir/ubuntu_autopilot.ttyS0 \ |
907 | + -serial file:$workdir/ubuntu_autopilot.ttyS1 \ |
908 | + -pidfile $workdir/qemu.pid |
909 | +} |
910 | + |
911 | +collect_artifacts() { |
912 | + echo "I: Collecting test artifacts" |
913 | + [ $# -eq 0 ] && return |
914 | + [ -z "$WORKSPACE" ] && return |
915 | + |
916 | + resultdir=$WORKSPACE/results/ |
917 | + mkdir -p $resultdir |
918 | + |
919 | + rsync -avH $@ $resultdir |
920 | + |
921 | + if [ -f "$resultdir/artifacts.tgz" ]; then |
922 | + echo "I: Extracting artifacts to result directory" |
923 | + tar xzf $resultdir/artifacts.tgz -C $resultdir/ |
924 | + rm -f "$resultdir/artifacts.tgz" |
925 | + fi |
926 | + find $resultdir | xargs touch |
927 | + echo "I: Artifacts stored in $resultdir" |
928 | +} |
929 | + |
930 | +tail_logs() { |
931 | + # Tail log files in -F mode in background |
932 | + # |
933 | + # $@ List of log files |
934 | + for log in $@; do |
935 | + #tail -n0 -F --pid=$$ $log | mawk -Winteractive -v logfile="$log" '{print logfile":",$0}' & |
936 | + tail -n0 -F --pid=$$ $log & |
937 | + done |
938 | +} |
939 | + |
940 | +SHORTOPTS="hdo:S:st:T:" |
941 | +LONGOPTS="help,debug,override:,disksize:,sdl,shm,test:,testconfig:" |
942 | + |
943 | +TEMP=$(getopt -o $SHORTOPTS --long $LONGOPTS -- "$@") |
944 | +eval set -- "$TEMP" |
945 | + |
946 | +exec 2>&1 |
947 | + |
948 | +while true ; do |
949 | + case "$1" in |
950 | + -h|--help) |
951 | + usage;; |
952 | + -d|--debug) |
953 | + set -x |
954 | + shift;; |
955 | + -o|--override) |
956 | + OVERRIDEDIR=$2 |
957 | + shift 2;; |
958 | + -S|--disksize) |
959 | + DISKSIZE=$2 |
960 | + shift 2;; |
961 | + -s|--shm) |
962 | + DISKDIR=/dev/shm |
963 | + shift;; |
964 | + --sdl) |
965 | + VNCOPTS="" |
966 | + shift;; |
967 | + -t|--test) |
968 | + TESTNAME=$2 |
969 | + shift 2;; |
970 | + -T|--testconfig) |
971 | + TESTCONFIG=$(readlink -f $2) |
972 | + if [ ! -f "$TESTCONFIG" ]; then |
973 | + echo "E: Configuration file not found :'$TESTCONFIG'. Aborting!" |
974 | + exit 1 |
975 | + fi |
976 | + shift 2;; |
977 | + --) |
978 | + shift; |
979 | + break;; |
980 | + *) |
981 | + usage;; |
982 | + esac |
983 | +done |
984 | + |
985 | +[ $# -ne 1 ] && usage |
986 | +ISO="$1" |
987 | +hrule |
988 | +cat<<EOF |
989 | + |
990 | +╦ ╦┌┐ ┬ ┬┌┐┌┌┬┐┬ ┬ ╔═╗┬ ┬┌┬┐┌─┐┌─┐┬┬ ┌─┐┌┬┐ ╔╦╗┌─┐┌─┐┌┬┐┌─┐ |
991 | +║ ║├┴┐│ ││││ │ │ │───╠═╣│ │ │ │ │├─┘││ │ │ │───║ ├┤ └─┐ │ └─┐ |
992 | +╚═╝└─┘└─┘┘└┘ ┴ └─┘ ╩ ╩└─┘ ┴ └─┘┴ ┴┴─┘└─┘ ┴ ╩ └─┘└─┘ ┴ └─┘ |
993 | +EOF |
994 | +hrule |
995 | +echo -en "Starting run on $STARTAT\n" |
996 | +hrule |
997 | + |
998 | +DISKIMG=$DISKDIR/disk.img |
999 | +INITRD=$WORKDIR/casper/initrd |
1000 | +KERNEL=$WORKDIR/casper/vmlinuz |
1001 | +if bsdtar tf $ISO casper/vmlinuz.efi >/dev/null 2>&1; then |
1002 | + KERNEL=${KERNEL}.efi |
1003 | +fi |
1004 | +KERNELOPTS="boot=casper DEBCONF_DEBUG=developer -- debconf/priority=critical locale=en_US console-setup/ask_detect=false console-setup/layoutcode=us automatic-ubuntu_autopilot" |
1005 | +KERNELOPTS="boot=casper DEBCONF_DEBUG=developer -- debconf/priority=critical locale=en_US console-setup/ask_detect=false console-setup/layoutcode=us noprompt console=ttyS0,115200" |
1006 | +check_prerequisites $REQUIREDPKGS |
1007 | +extract_kernel $ISO $WORKDIR |
1008 | +create_disk_image $DISKIMG $DISKSIZE |
1009 | +prepare_initrd $WORKDIR ${INITRD} "$OVERRIDEDIR" |
1010 | +boot_image $WORKDIR $ISO $DISKIMG ${INITRD} $KERNEL "$KERNELOPTS" |
1011 | + |
1012 | +tail_logs $WORKDIR/ubuntu_autopilot.ttyS0 |
1013 | + |
1014 | +PIDFILE=$WORKDIR/qemu.pid |
1015 | +while sleep $DELAY; do |
1016 | + if [ ! -f "$PIDFILE" ]; then |
1017 | + echo "I: PID file not found: $PIDFILE" |
1018 | + break |
1019 | + fi |
1020 | + if ! kill -0 $(cat $WORKDIR/qemu.pid) 2>/dev/null; then |
1021 | + echo "I: Qemu process terminated." |
1022 | + break |
1023 | + fi |
1024 | + TIMEOUT=$((TIMEOUT - DELAY)) |
1025 | + if [ $TIMEOUT -le 0 ]; then |
1026 | + echo "E: Test Timed out!" |
1027 | + break |
1028 | + fi |
1029 | +done |
1030 | + |
1031 | +mkdir -p $WORKDIR/logs |
1032 | +cp $WORKDIR/ubuntu_autopilot.ttyS0 $WORKDIR/logs/console |
1033 | +cp $WORKDIR/ubuntu_autopilot.ttyS1 $WORKDIR/logs/artifacts.tgz |
1034 | + |
1035 | +collect_artifacts $WORKDIR/logs/ |
1036 | |
1037 | === added file 'desktop-autopilot-runner/splitlogs.awk' |
1038 | --- desktop-autopilot-runner/splitlogs.awk 1970-01-01 00:00:00 +0000 |
1039 | +++ desktop-autopilot-runner/splitlogs.awk 2014-03-04 19:06:35 +0000 |
1040 | @@ -0,0 +1,14 @@ |
1041 | +{ |
1042 | + split($0, line, ":") |
1043 | + filename=line[1] |
1044 | + # Get basename and trim line |
1045 | + sub(/^.*\//, "", filename) |
1046 | + sub(/[ \t\r\n]+/, "", filename) |
1047 | + # Remove filename from line |
1048 | + logline=$0 |
1049 | + sub(/^[^:]*: /, "", logline) |
1050 | + |
1051 | + if (filename) { |
1052 | + print logline>filename; |
1053 | + } |
1054 | +} |
With this runner, we should be able to provide an easier workflow for running these tests in a similar environment as jenkins. This should help in reproducing issues. I suppose this could also be helpful in verifying tests work when run in a pristine environment; probably useful to verify before final merge.