Merge lp:~jibel/ubuntu-server-iso-testing/wubi into lp:ubuntu-server-iso-testing

Proposed by Jean-Baptiste Lallement
Status: Merged
Merged at revision: 229
Proposed branch: lp:~jibel/ubuntu-server-iso-testing/wubi
Merge into: lp:ubuntu-server-iso-testing
Diff against target: 856 lines (+789/-0)
10 files modified
wubi/README (+118/-0)
wubi/bin/Wubi Test.bat (+6/-0)
wubi/bin/config (+8/-0)
wubi/bin/functions (+39/-0)
wubi/bin/poll-wubi-results.sh (+39/-0)
wubi/bin/run-test.sh (+168/-0)
wubi/bin/wubi-test.sh (+223/-0)
wubi/data/custom-installation/target-override/etc/rc.local (+24/-0)
wubi/data/custom-installation/target-override/usr/local/bin/run_test (+56/-0)
wubi/data/custom-installation/target-override/usr/local/tests/test_default.py (+108/-0)
To merge this branch: bzr merge lp:~jibel/ubuntu-server-iso-testing/wubi
Reviewer Review Type Date Requested Status
C de-Avillez (community) Approve
Review via email: mp+69132@code.launchpad.net

Description of the change

There is very little interaction with other pieces of USIT as most of the work is done on Windows side.
If anyone is interested in reviewing this I'll be happy to discuss with him, otherwise I'll go ahead and merge.

There are still a few bits of documentation missing like how to deploy the Jenkins script and add other flavors (support is there but untested)

A piece of code related to logging need to be moved from wubi-test.sh to the master script but that is not critical.

To post a comment you must log in.
Revision history for this message
C de-Avillez (hggdh2) wrote :

go for it. Just a question: how long should we wait at the end of the test for Jenkins to sync?

+
734 +# Send the results to Jenkins
735 +
736 +# Poweroff or reboot to windows
737 +reboot

review: Approve
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

This is an old comment that is not relevant anymore. Initially I planned to send the results to jenkins from Ubuntu, but finally the results are copied to Windows, and the job on Windows side sends it to Jenkins. So I only have to maintain the state of the job on on side.

The timeout is set to 3600s and defined in the job running on Jenkins. The test runs in ~20min including time to download the langpacks.

Thanks for pointing this comment, I'll remove it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'wubi'
2=== added file 'wubi/README'
3--- wubi/README 1970-01-01 00:00:00 +0000
4+++ wubi/README 2011-07-25 16:56:01 +0000
5@@ -0,0 +1,118 @@
6+= Introduction =
7+This document describes automated wubi testing
8+
9+= Setup =
10+The test is installed on the Windows side.
11+The general process is:
12+1. Trigger the test if
13+ - A new version of wubi is available
14+ or
15+ - A new Ubuntu Desktop ISO (i386|mad64) is available
16+
17+2. Download Wubi if needed
18+3. Download the required ISO if needed.
19+4. Run Wubi
20+5. Reboot and install Ubuntu
21+6. Reboot to Ubuntu, run the tests and report the results
22+7. Restore the system and boot back to Windows for next run.
23+
24+Directory Structure
25+./bin
26+./bin/functions General purpose functions
27+./bin/run-test.sh Main test script
28+./data Data Directory
29+./data/custom-installation Contains the scripts to be run by casper
30+./data/custom-installation/packages Packages in this directory are installed on the target
31+./data/custom-installation/target-override Content is copied as-is to target
32+./data/custom-installation/target-override/etc
33+./data/custom-installation/target-override/etc/rc.local Setup the target and launch the tests
34+./data/custom-installation/target-override/usr
35+./data/custom-installation/target-override/usr/local
36+./data/custom-installation/target-override/usr/local/bin
37+./data/custom-installation/target-override/usr/local/bin/run_test The test runner
38+./data/custom-installation/target-override/usr/local/tests Contains the tests to run on target
39+./data/iso Download directory (ISOs and wubi.exe) Wubi and the ISO must be in the same directory to use --isopath
40+./data/wubi.list The expected content of DRIVE/ubuntu on the host after wubi installation. Used to check the integrity of the installation
41+./log Log directory
42+./results Results to push to jenkins
43+
44+
45+= Run Test Script =
46+== Preliminary steps ==
47+On the test system:
48+- Download ISO
49+- Download wubi.exe
50+Both tasks should be done by a separate jenkins task (as we do for the other iso tests)
51+
52+== Step 1: Windows side ==
53+Execute run-test.sh with the name of the ISO or the architecture to test.
54+Without argument it will install the latest ISO for the architecture the test runs on.
55+wubi.exe and the ISO must be in the same directory (TODO: File a bug)
56+
57+=== wubi-test.sh ===
58+1. Uninstall Wubi if a previous installation exists
59+2. Install Wubi non-interactively with the ISO passed on the command line or download a new iso if required.
60+3. Copy the testing material from ./data/custom-installation to C:/ubuntu/install/custom-installation
61+ This files will be copied to /root/custom-installatio on the target.
62+4. Restart system and proceed with step 2
63+== Step 2: Ubuntu site ==
64+1. Boots directly to linux
65+2. Installs Ubuntu
66+ At the end of the installation the content of /root/custom-installation is copied to /target/
67+ rc.local will start the tests on next reboot.
68+3. Reboot to Ubuntu
69+4. Run rc.local script:
70+ 4.1 Install the prerequisites and setup the system for the test
71+ 4.2 Execute /usr/local/bin/run_test which will run the tests in /usr/local/tests/ (python unittests)
72+ 4.3 Write the results to the run directory in xUnit format
73+
74+= Master Script - run-test.sh =
75+ * For each $RELEASE $FLAVOR $ARCH
76+ * If test has not started:
77+ * Trigger remote build on phad
78+ * sync logs
79+ * Sync the image
80+ * Extract wubi.exe
81+ * chmod +x wubi.exe
82+ * sync logs
83+ * run test phase 1 (sync logs before reboot)
84+ * else if phase 2 as not started
85+ * run test phase 2 (sync logs before reboot)
86+ * else
87+ * sync the log on more time excepted result.xml
88+ * sync result.xml
89+* List of tests to run in $RUNDIR/job.list
90+* Maintain job state in a file in $RUNDIR/job.state
91+
92+= Integration with Jenkins =
93+ * Trigger a remote build on run start.
94+ * Jenkins job
95+ * Wait until timeout is reached or job is completed
96+ * Job is completed if a specific file is on the Jenkins slave (wazn)
97+ * Wubi job
98+ * At start, trigger the remote job
99+ * At each step of the test, sync the current run directory to wazn
100+ * At the end of the run do a last sync + copy a flag to indicate the end of the run
101+
102+= General Notes =
103+== Resources ==
104+https://wiki.ubuntu.com/WubiGuide
105+https://launchpad.net/ubuntu/+spec/foundations-o-wubi
106+https://launchpad.net/wubi
107+=== Remote Access to the Wubi machine ===
108+ How to run the OpenSSH SSHD server on Windows using Cygwin
109+Install the following Cygwin packages (rerun setup if necessary -- you can add packages after you have already installed Cygwin).
110+
111+ Admin --> cygrunsrv
112+ Net --> openssh
113+Open a new bash shell window and run the SSH configure stuff.
114+
115+ssh-host-config -y
116+This step will create necessary configuration files, a priviledge separation user and necessary directories.
117+When prompted with "CYGWIN=" type for following:
118+
119+tty ntsec
120+Now you are ready to start the service.
121+
122+cygrunsrv -S sshd
123+
124
125=== added directory 'wubi/bin'
126=== added file 'wubi/bin/Wubi Test.bat'
127--- wubi/bin/Wubi Test.bat 1970-01-01 00:00:00 +0000
128+++ wubi/bin/Wubi Test.bat 2011-07-25 16:56:01 +0000
129@@ -0,0 +1,6 @@
130+@echo off
131+
132+C:
133+chdir C:\cygwin\home\ubuntu\wubitest
134+
135+\cygwin\bin\bash.exe --login -c "cd ~/wubitest/; ./bin/test-wubi.sh -r --isopath=data/iso/oneiric-desktop-amd64.iso "
136
137=== added file 'wubi/bin/bcdedit.exe'
138Binary files wubi/bin/bcdedit.exe 1970-01-01 00:00:00 +0000 and wubi/bin/bcdedit.exe 2011-07-25 16:56:01 +0000 differ
139=== added file 'wubi/bin/config'
140--- wubi/bin/config 1970-01-01 00:00:00 +0000
141+++ wubi/bin/config 2011-07-25 16:56:01 +0000
142@@ -0,0 +1,8 @@
143+# Wubi Testing configuration file
144+#
145+# Must be valid shell script
146+JENKINS_MASTER="phad"
147+JENKINS_SLAVE="wazn"
148+JENKINS_TOKEN="aHidyaw7gratFen9"
149+JENKINS_URL="localhost:8080"
150+
151
152=== added file 'wubi/bin/functions'
153--- wubi/bin/functions 1970-01-01 00:00:00 +0000
154+++ wubi/bin/functions 2011-07-25 16:56:01 +0000
155@@ -0,0 +1,39 @@
156+# #!/bin/sh
157+#
158+# Utility functions
159+
160+log_msg() {
161+ printf "$(date '+%F %X'): $@"
162+}
163+
164+log_info_msg() {
165+ log_msg "Info: $@\n"
166+}
167+
168+log_success_msg() {
169+ log_msg "Success: $@\n"
170+}
171+
172+log_failure_msg() {
173+ log_msg "Failure: $@\n"
174+}
175+
176+log_warning_msg() {
177+ log_msg "Warning: $@\n"
178+}
179+
180+log_begin_msg() {
181+ log_msg "Begin: $@ ... "
182+}
183+
184+log_end_msg() {
185+ printf "done.\n"
186+}
187+
188+log_start_job() {
189+ log_msg "Starting Job: $@\n"
190+}
191+
192+log_end_job() {
193+ log_msg "Job Finished: $@\n"
194+}
195
196=== added file 'wubi/bin/poll-wubi-results.sh'
197--- wubi/bin/poll-wubi-results.sh 1970-01-01 00:00:00 +0000
198+++ wubi/bin/poll-wubi-results.sh 2011-07-25 16:56:01 +0000
199@@ -0,0 +1,39 @@
200+#!/bin/sh
201+#
202+# This job wait for wubi test to finish
203+# It is triggered remotely by a remote build call from the wubi host
204+#
205+# An xml file in RESULTPATH is the condition to end the job
206+# Otherwise it ends at when TIMEOUT is reached.
207+#
208+echo "Test Start"
209+env
210+
211+START=$(date +%s)
212+TIMEOUT=30
213+SLEEPTIME=5
214+
215+BASERESULTDIR=/tmp/${FLAVOR}_${RELEASE}_${ARCH}_${PRESEED}
216+TESTRESULTDIR=test-results
217+RESULTPATH=$WORKSPACE/$BUILD_NUMBER
218+
219+mkdir -p $RESULTPATH
220+mkdir -p $BASERESULTDIR
221+
222+while true; do
223+ NOW=$(date +%s)
224+
225+ rsync -r $BASERESULTDIR/$TESTRESULTDIR $RESULTPATH
226+
227+ if ls $RESULTPATH/$TESTRESULTDIR/ | grep -q 'xml$'; then
228+ echo "Results found"
229+ break
230+ fi
231+ if [ $(( $NOW - $START )) -gt $TIMEOUT ]; then
232+ echo "Time out!"
233+ break
234+ fi
235+ sleep $SLEEPTIME
236+done
237+
238+echo "Test End"
239
240=== added file 'wubi/bin/run-test.sh'
241--- wubi/bin/run-test.sh 1970-01-01 00:00:00 +0000
242+++ wubi/bin/run-test.sh 2011-07-25 16:56:01 +0000
243@@ -0,0 +1,168 @@
244+#/bin/sh
245+# Copyright (C) 2011, Canonical Ltd (http://www.canonical.com/)
246+#
247+# Automated Wubi installation testing
248+#
249+# This software is free software: you can redistribute it
250+# and/or modify it under the terms of the GNU General Public License
251+# as published by the Free Software Foundation, either version 3 of
252+# the License, or (at your option) any later version.
253+#
254+# This software is distributed in the hope that it will
255+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
256+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
257+# GNU General Public License for more details.
258+#
259+# You should have received a copy of the GNU General Public License
260+# along with this software. If not, see <http://www.gnu.org/licenses/>.
261+#
262+
263+JOBNAME="Wubi Test"
264+
265+BASEDIR="$(dirname $0)/.."
266+BINDIR="$BASEDIR/bin"
267+DATADIR="$BASEDIR/data"
268+CUSTOMDIR="$DATADIR/custom-installation"
269+RUNDIR=$BASEDIR/run
270+LOGFILE=$RUNDIR/latest/$(basename $0 .sh).log
271+STATEFILE=$RUNDIR/job.state
272+STATE=""
273+
274+. $BINDIR/functions
275+. $BINDIR/config
276+
277+WUBIEXE="wubi.exe"
278+
279+# Default Values
280+FLAVOR="ubuntu"
281+RELEASE="oneiric"
282+ARCH="i386"
283+TEST="default"
284+VARIANT="desktop" # Always desktop for Wubi
285+
286+# Default values are overridden by those in statefile
287+# if a job is already running
288+# Then args passed on commandline
289+[ -f "$STATEFILE" ] && . $STATEFILE
290+
291+usage() {
292+ cat<<EOF
293+Usage: $(basename $0) [OPTIONS...]
294+
295+ -f, --flavor FLAVOR Select specific flavor to test ($FLAVOR)
296+ -r, --release RELEASE Select release to test ($RELEASE)
297+ -a, --arch ARCH Select architecture to test ($ARCH)
298+ -t, --test TEST Select test to run ($TEST)
299+ -h, --help This help
300+EOF
301+ exit 1
302+}
303+
304+run_test () {
305+ # Run the test
306+ log_info_msg "Running test for $1"
307+ #$BINDIR/wubi-test.sh -r --isopath=$1
308+}
309+
310+write_state() {
311+ STATE=$1
312+ cat<<EOF>${STATEFILE}
313+RELEASE=$RELEASE
314+FLAVOR=$FLAVOR
315+ARCH=$ARCH
316+TEST=$TEST
317+LOGFILE=$LOGFILE
318+STATE=$1
319+EOF
320+
321+}
322+
323+TEMP=$(getopt -o f:r:a:t:h --long help,flavor:,release:,arch:,test: -- "$@")
324+eval set -- "$TEMP"
325+
326+while true ; do
327+ case "$1" in
328+ -h|--help)
329+ usage;;
330+ -f|--flavor)
331+ FLAVOR=$2
332+ shift 2;;
333+ -r|--release)
334+ RELEASE=$2
335+ shift 2 ;;
336+ -a|--arch)
337+ ARCH=$2
338+ shift 2 ;;
339+ -t|--test)
340+ TEST=$2
341+ shift 2 ;;
342+ --) shift ; break ;;
343+ *) usage;;
344+ esac
345+done
346+
347+
348+exec 2>&1
349+
350+log_info_msg "Log saved to $LOGFILE"
351+
352+exec 1>>$LOGFILE
353+
354+log_start_job "$JOBNAME"
355+trap "log_end_job \"$JOBNAME\"" EXIT QUIT
356+
357+JENKINS_JOB=${FLAVOR}_${VARIANT}-${ARCH}_wubi-${TEST}
358+ISODIR=$DATADIR/iso/${FLAVOR}
359+
360+FLAVORPART="${FLAVOR}/"
361+[ $FLAVOR == "ubuntu" ] && FLAVORPART=""
362+
363+ISONAME="${RELEASE}-${VARIANT}-${ARCH}.iso"
364+ISOPATH=$ISODIR/$ISONAME
365+ZSYNCURL=http://cdimage.ubuntu.com/${FLAVORPART}daily-live/current/${ISONAME}.zsync
366+
367+if [ ! -f "$STATEFILE" ]; then
368+ log_info_msg "State file $STATEFILE not found. Starting new job"
369+ # No state file, create a new job
370+ # Start remote jenkins task
371+ write_state "start-build"
372+ JOBURL="http://${JENKINS_URL}/job/$JENKINS_JOB/buildWithParameters?token=$JENKINS_TOKEN"
373+ log_info_msg "Starting remote build $JOBURL"
374+ ssh $JENKINS_MASTER wget '$JOBURL' -o /dev/null
375+
376+ # Write state change
377+ # Sync result to notify start
378+ # Download image from cdimage.u.c
379+ write_state "sync"
380+ mkdir -p $ISODIR
381+ cd $ISODIR
382+ log_info_msg "Syncing $ZSYNCURL to $ISODIR"
383+ zsync $ZSYNCURL
384+
385+ # Extract wubi.exe
386+ log_info_msg "Extracting $WUBIEXE from $ISONAME"
387+ bsdtar.exe xf $ISONAME $WUBIEXE
388+ cd -
389+
390+ write_state "running"
391+
392+ log_info_msg "Starting Stage 1"
393+ # This command will restart the system, so nothing can be done after this.
394+ run_test $ISOPATH
395+elif [ "$STATE" == "running" ]; then
396+ log_info_msg "Starting Stage 2"
397+ write_state "report"
398+ run_test $ISOPATH
399+elif [ "$STATE" == "report" ]; then
400+ log_info_msg "Syncing results"
401+ # Last step report slave and remove state file for next run
402+ # Sync the files
403+ rsync -avz --del run/latest/ $JENKINS_SLAVE:~/test-results
404+ rm $STATEFILE
405+else
406+ log_warning_msg "Unknown state: $STATE"
407+ log_warning_msg "Aborting!"
408+ exit 1
409+fi
410+
411+log_end_msg
412
413=== added file 'wubi/bin/ubuntu.ico'
414Binary files wubi/bin/ubuntu.ico 1970-01-01 00:00:00 +0000 and wubi/bin/ubuntu.ico 2011-07-25 16:56:01 +0000 differ
415=== added file 'wubi/bin/wubi-test.sh'
416--- wubi/bin/wubi-test.sh 1970-01-01 00:00:00 +0000
417+++ wubi/bin/wubi-test.sh 2011-07-25 16:56:01 +0000
418@@ -0,0 +1,223 @@
419+#/bin/sh
420+# Copyright (C) 2011, Canonical Ltd (http://www.canonical.com/)
421+#
422+# Automated Wubi installation testing
423+#
424+# This software is free software: you can redistribute it
425+# and/or modify it under the terms of the GNU General Public License
426+# as published by the Free Software Foundation, either version 3 of
427+# the License, or (at your option) any later version.
428+#
429+# This software is distributed in the hope that it will
430+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
431+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
432+# GNU General Public License for more details.
433+#
434+# You should have received a copy of the GNU General Public License
435+# along with this software. If not, see <http://www.gnu.org/licenses/>.
436+#
437+
438+# TODO:
439+# - Verify that Windows stage is complete and write results somewhere (Use unittest ?)
440+# - The following files are on C:/ : wubildr and wubildr.mbr
441+# - TARGET_DRIVE/ubuntu is a directory
442+# - Verify the content of $TARGET_DRIVE/ubuntu
443+# - Add other releases
444+
445+
446+JOBNAME="Wubi Test"
447+
448+BASEDIR="$(dirname $0)/.."
449+BINDIR="$BASEDIR/bin"
450+DATADIR="$BASEDIR/data"
451+CUSTOMDIR="$DATADIR/custom-installation"
452+RUNDIR=$BASEDIR/run
453+LOGFILE=$RUNDIR/latest/$(basename $0 .sh).log
454+
455+. $BINDIR/functions
456+
457+DRIVE="c"
458+I386=""
459+ISOPATH=""
460+REBOOT=""
461+USERNAME="ubuntu"
462+PASSWORD="ubuntu"
463+WUBIEXE="$DATADIR/iso/wubi.exe"
464+
465+TIMEOUT=3600 # Wubi run asynchronously. Need to wait to it to finish and download takes time
466+
467+usage() {
468+ cat<<EOF
469+Usage: $(basename $0) [OPTIONS...]
470+
471+ -d, --drive=TARGET_DRIVE Target drive (Default ${DRIVE}:)
472+ -i, --isopath=FILE Use specified ISO (Downloaded if unspecified)
473+ -r, --reboot Reboot after installation
474+ -x, --32bit Force installation of 32bit version
475+ -h, --help This help
476+EOF
477+ exit 1
478+}
479+
480+get_bootid() {
481+ # Return Window's bootid for the boot entry with 'name'
482+
483+ name=$1
484+ if [ -z "$name" ]; then
485+ return
486+ fi
487+ bootid=$( $BINDIR/bcdedit.exe |grep -B3 "$name" |grep identifier|awk '{print $2}' )
488+ echo $bootid
489+}
490+
491+TEMP=$(getopt -o hd:i:rx --long help,drive:,reboot,isopath:,32bit -- "$@")
492+eval set -- "$TEMP"
493+
494+while true ; do
495+ case "$1" in
496+ -h|--help)
497+ usage;;
498+ -d|--drive)
499+ DRIVE=$2
500+ shift 2 ;;
501+ -i|--isopath)
502+ ISOPATH=$2
503+ shift 2 ;;
504+ -r|--reboot)
505+ REBOOT="Y"
506+ shift;;
507+ -x|--32bit)
508+ I386="--32bit"
509+ shift;;
510+ --) shift ; break ;;
511+ *) usage;;
512+ esac
513+done
514+
515+
516+exec 2>&1
517+
518+if [ -f "$RUNDIR/latest/stage2" ]; then
519+ exec 1>>$LOGFILE
520+ log_start_job "$JOBNAME : Stage 2"
521+
522+ # Just grep 'buntu' to catch derivatives as well
523+ # It will be used to set default boot entry for stage 2 of the test
524+ bootid=$(get_bootid "buntu")
525+
526+ if [ -z "$bootid" ]; then
527+ log_failure_msg "Boot entry for Ubuntu not found. Aborting."
528+ exit 3
529+ fi
530+
531+ log_info_msg "Setting $bootid entry as default for next reboot"
532+ $BINDIR/bcdedit.exe /bootsequence $bootid
533+
534+ if [ "$REBOOT" == "Y" ]; then
535+ # Reboot
536+ log_info_msg "Rebooting"
537+ shutdown.exe /r /f /t 5
538+ fi
539+ log_end_msg
540+ exit 0
541+fi
542+
543+if [ -d $RUNDIR/latest ]; then
544+ log_begin_msg "Backup previous log dir to $RUNDIR/$(date '+%Y%m%d-%H%M%S')"
545+ mv $RUNDIR/latest $RUNDIR/$(date '+%Y%m%d-%H%M%S')
546+ log_end_msg
547+fi
548+mkdir -p $RUNDIR/latest
549+
550+log_info_msg "Log saved to $LOGFILE"
551+
552+exec 1>>$LOGFILE
553+
554+log_start_job "$JOBNAME"
555+trap "log_end_job \"$JOBNAME\"" EXIT QUIT
556+
557+if [ ! -x "$WUBIEXE" ]; then
558+ log_failure_msg "'$WUBIEXE' not found"
559+ exit 1
560+fi
561+
562+#WUBIARGS="--password=$PASSWORD --username=$USERNAME --noninteractive --skipmd5check --log-file=$WUBILOG"
563+WUBIARGS="--password=$PASSWORD --username=$USERNAME --noninteractive --skipmd5check"
564+if [ ! -z "$ISOPATH" ]; then
565+ if [ ! -f "$ISOPATH" ]; then
566+ log_failure_msg "File doesn't exist '$ISOPATH'"
567+ exit 1
568+ fi
569+
570+ MIMETYPE=$( file -bi "$ISOPATH" )
571+ if ! echo "$MIMETYPE" | grep -q iso9660; then
572+ log_failure_msg "'$ISOPATH' is not a valid ISO (mimetype: $MIMETYPE)"
573+ exit 1
574+ fi
575+
576+ # If an image and 32bit are specified on the command line then check that the image is not 64bit
577+ if basename "$ISOPATH" | grep -q "amd64"; then
578+ if [ ! -z "$I386" ]; then
579+ log_failure_msg "You forced installation of 32bit version but the image is 64bit"
580+ exit 1
581+ fi
582+ else
583+ I386="--32bit"
584+ fi
585+fi
586+
587+if [ ! -z "$ISOPATH" ]; then
588+ ISOPATH="--isopath=$ISOPATH"
589+fi
590+
591+WUBIARGS="$WUBIARGS $I386 $ISOPATH"
592+
593+log_begin_msg "Uninstalling previous install"
594+$WUBIEXE --uninstall --noninteractive
595+
596+# Take some breath
597+sleep 5
598+log_end_msg
599+
600+log_info_msg "Running $(basename $WUBIEXE) $WUBIARGS"
601+$WUBIEXE $WUBIARGS
602+
603+STARTTIME=$(date +%s)
604+while true; do
605+ currtime=$(date +%s)
606+ timediff=$(( $currtime - $STARTTIME ))
607+
608+ if [ $timediff -gt $TIMEOUT ]; then
609+ log_failure_msg "Wubi still running after $TIMEOUT seconds. Aborting!"
610+ exit 2
611+ fi
612+ if ! ps -W | grep -q "pyrun.exe"; then
613+ log_info_msg "Wubi installation done (took ${timediff}s)"
614+ break
615+ fi
616+ log_info_msg "Waiting for wubi to finish. running for ${timediff}s"
617+ sleep 1
618+done
619+
620+TARGET_CUSTOMDIR=/cygdrive/${DRIVE}/ubuntu/install/custom-installation
621+
622+# Load casper custome-installation directory with tests
623+log_begin_msg "Copying $(basename $CUSTOMDIR) to $TARGET_CUSTOMDIR"
624+cp -af $CUSTOMDIR/* $TARGET_CUSTOMDIR || true
625+log_end_msg
626+
627+log_begin_msg "Saving Wubi log file"
628+mv /tmp/wubi*.log $RUNDIR/latest/
629+log_end_msg
630+
631+log_begin_msg "Preparing for stage 2"
632+touch $RUNDIR/latest/stage2
633+log_end_msg
634+
635+if [ "$REBOOT" == "Y" ]; then
636+ # Reboot
637+ log_info_msg "Rebooting"
638+ shutdown.exe /r /f /t 5
639+fi
640+
641+log_end_msg
642
643=== added directory 'wubi/data'
644=== added directory 'wubi/data/custom-installation'
645=== added directory 'wubi/data/custom-installation/packages'
646=== added directory 'wubi/data/custom-installation/target-override'
647=== added directory 'wubi/data/custom-installation/target-override/etc'
648=== added file 'wubi/data/custom-installation/target-override/etc/rc.local'
649--- wubi/data/custom-installation/target-override/etc/rc.local 1970-01-01 00:00:00 +0000
650+++ wubi/data/custom-installation/target-override/etc/rc.local 2011-07-25 16:56:01 +0000
651@@ -0,0 +1,24 @@
652+#!/bin/sh -e
653+#
654+# rc.local
655+#
656+# This script is executed at the end of each multiuser runlevel.
657+# Make sure that the script will "exit 0" on success or any other
658+# value on error.
659+#
660+# In order to enable or disable this script just change the execution
661+# bits.
662+#
663+# By default this script does nothing.
664+
665+JOBNAME="wubitest"
666+logger -t $JOBNAME "Installing prerequisites"
667+apt-get install -y openssh-server python-couchdb subunit python-subunit python-junitxml|logger -t $JOBNAME
668+
669+RUNTEST=/usr/local/bin/run_test
670+if [ -x "$RUNTEST" ]; then
671+ logger -t $JOBNAME "Starting $RUNTEST"
672+ sudo $RUNTEST|logger -t $JOBNAME
673+else
674+ logger -t $JOBNAME "Error: File not found '$RUNTEST'"
675+fi
676
677=== added directory 'wubi/data/custom-installation/target-override/usr'
678=== added directory 'wubi/data/custom-installation/target-override/usr/local'
679=== added directory 'wubi/data/custom-installation/target-override/usr/local/bin'
680=== added file 'wubi/data/custom-installation/target-override/usr/local/bin/run_test'
681--- wubi/data/custom-installation/target-override/usr/local/bin/run_test 1970-01-01 00:00:00 +0000
682+++ wubi/data/custom-installation/target-override/usr/local/bin/run_test 2011-07-25 16:56:01 +0000
683@@ -0,0 +1,56 @@
684+#!/bin/sh
685+#
686+# Copyright (C) 2010, Canonical Ltd (http://www.canonical.com/)
687+#
688+# This file is part of ubuntu-server-iso-testing.
689+#
690+# ubuntu-server-iso-testing is free software: you can redistribute it
691+# and/or modify it under the terms of the GNU General Public License
692+# as published by the Free Software Foundation, either version 3 of
693+# the License, or (at your option) any later version.
694+#
695+# ubuntu-server-iso-testing is distributed in the hope that it will
696+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
697+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
698+# GNU General Public License for more details.
699+#
700+# You should have received a copy of the GNU General Public License
701+# along with ubuntu-server-iso-testing. If not, see
702+# <http://www.gnu.org/licenses/>.
703+#
704+
705+# This script must be executed with admin privileges
706+
707+BASEDIR=$(dirname $0)/..
708+TESTDIR=$BASEDIR/tests
709+
710+# Don't hardcode this, it will break if wubi is not installed on C:
711+LOGDIR=/host/cygwin/home/ubuntu/wubitest/run/latest
712+if [ ! -d "$LOGDIR" ]; then
713+ echo "Logdir not found. Aborting!"
714+ exit 1
715+fi
716+
717+cd $TESTDIR
718+for t in test_*.py; do
719+ tbasename=$(basename $t .py)
720+ echo "Running test: $tbasename"
721+ python -m subunit.run $tbasename | subunit2junitxml > $LOGDIR/results.${tbasename}.log
722+done
723+cd -
724+
725+# Save the installer file
726+echo "Saving log files"
727+cp -r /var/log/installer $LOGDIR/
728+dmesg > $LOGDIR/dmesg
729+cp /var/log/syslog $LOGDIR
730+
731+# Stage 2 is done
732+rm $LOGDIR/stage2
733+
734+# Send the results to Jenkins
735+
736+# Poweroff or reboot to windows
737+reboot
738+
739+
740
741=== added directory 'wubi/data/custom-installation/target-override/usr/local/tests'
742=== added file 'wubi/data/custom-installation/target-override/usr/local/tests/test_default.py'
743--- wubi/data/custom-installation/target-override/usr/local/tests/test_default.py 1970-01-01 00:00:00 +0000
744+++ wubi/data/custom-installation/target-override/usr/local/tests/test_default.py 2011-07-25 16:56:01 +0000
745@@ -0,0 +1,108 @@
746+#!/usr/bin/python
747+#
748+# Copyright (C) 2010, Canonical Ltd (http://www.canonical.com/)
749+#
750+# This file is part of ubuntu-server-iso-testing.
751+#
752+# ubuntu-server-iso-testing is free software: you can redistribute it
753+# and/or modify it under the terms of the GNU General Public License
754+# as published by the Free Software Foundation, either version 3 of
755+# the License, or (at your option) any later version.
756+#
757+# ubuntu-server-iso-testing is distributed in the hope that it will
758+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
759+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
760+# GNU General Public License for more details.
761+#
762+# You should have received a copy of the GNU General Public License
763+# along with ubuntu-server-iso-testing. If not, see
764+# <http://www.gnu.org/licenses/>.
765+#
766+
767+import logging
768+import os.path
769+import unittest
770+import lsb_release
771+import subprocess
772+
773+logging.basicConfig(level=logging.INFO)
774+
775+def cmd(command, input = None, stderr = subprocess.STDOUT, stdout = subprocess.PIPE, stdin = None):
776+ '''Try to execute given command (array) and return its stdout, or return
777+ a textual error if it failed.'''
778+
779+ try:
780+ sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True)
781+ except OSError, e:
782+ return [127, str(e)]
783+
784+ out, outerr = sp.communicate(input)
785+ # Handle redirection of stdout
786+ if out == None:
787+ out = ''
788+ # Handle redirection of stderr
789+ if outerr == None:
790+ outerr = ''
791+ return [sp.returncode,out+outerr]
792+
793+class DefaultTest(unittest.TestCase):
794+
795+ mount_point = "/host"
796+ wubidir = os.path.join(mount_point, 'ubuntu')
797+ distinfo = lsb_release.get_distro_information()
798+ pkg_test = 'hello' # Example package used by the apt test
799+
800+ def test_01_host_is_mounted(self):
801+ self.assertTrue(os.path.ismount(self.mount_point))
802+
803+ def test_02_read_write(self):
804+ t_fh = open(os.path.join(self.mount_point, 'Temp', 'a'), 'w')
805+ self.assertNotEqual(t_fh, None)
806+ self.assertEqual(t_fh.write('a'), None)
807+ self.assertEqual(t_fh.close(), None)
808+
809+ def test_03_wubi_dir_structure(self):
810+ wubi_filelist = (
811+ '/host/ubuntu/',
812+ '/host/ubuntu/disks',
813+ '/host/ubuntu/disks/boot',
814+ '/host/ubuntu/disks/boot/grub',
815+ '/host/ubuntu/disks/root.disk',
816+ '/host/ubuntu/disks/swap.disk',
817+ '/host/ubuntu/install',
818+ '/host/ubuntu/Ubuntu.ico',
819+ '/host/ubuntu/uninstall-wubi.exe',
820+ '/host/ubuntu/winboot',
821+ '/host/ubuntu/winboot/wubildr',
822+ '/host/ubuntu/winboot/wubildr-bootstrap.cfg',
823+ '/host/ubuntu/winboot/wubildr.cfg',
824+ '/host/ubuntu/winboot/wubildr.mbr',
825+ '/host/ubuntu/winboot/wubildr.tar'
826+ )
827+
828+ for f in wubi_filelist:
829+ self.assertTrue(os.path.exists(f), "File not found: '%s'" % f)
830+
831+ def test_04_apt_update(self):
832+ '''apt-get update'''
833+ rc, report = cmd(['apt-get', 'update'])
834+ expected = 0
835+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
836+ self.assertEquals(expected, rc, result + report)
837+
838+ def test_05_apt_install_remove(self):
839+ '''apt-get install'''
840+ rc, report = cmd(['apt-get', 'install', '-y', self.pkg_test])
841+ expected = 0
842+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
843+ self.assertEquals(expected, rc, result + report)
844+
845+ rc, report = cmd(['apt-get', 'remove', '-y', '--purge', self.pkg_test])
846+ expected = 0
847+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
848+ self.assertEquals(expected, rc, result + report)
849+
850+
851+if __name__ == '__main__':
852+ unittest.main()
853+
854
855=== added directory 'wubi/data/iso'
856=== added directory 'wubi/run'

Subscribers

People subscribed via source and target branches