Merge lp:~fginther/ubuntu-test-cases/upstream-merger into lp:ubuntu-test-cases/touch

Proposed by Francis Ginther
Status: Work in progress
Proposed branch: lp:~fginther/ubuntu-test-cases/upstream-merger
Merge into: lp:ubuntu-test-cases/touch
Diff against target: 350 lines (+276/-7)
5 files modified
scripts/click-info.py (+40/-0)
scripts/provision.sh (+90/-7)
scripts/run-generic-tests.sh (+142/-0)
support/00localrepo.list (+1/-0)
support/local-pin-1100 (+3/-0)
To merge this branch: bzr merge lp:~fginther/ubuntu-test-cases/upstream-merger
Reviewer Review Type Date Requested Status
Ubuntu Test Case Developers Pending
Review via email: mp+193334@code.launchpad.net

This proposal supersedes a proposal from 2013-10-30.

Description of the change

Add support for zip package archives created by jenkins.

This allows adding packages from a zip archive produced from a jenkins job. This is used for upstream merger testing where the packages under test have not landed in any PPA or ubuntu archive yet.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

+ echo "$NETWORK_FILE"
Maybe add a bit more text around this to make it clear what you are telling the user?

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

there also looks like there might be some tabs vs spaces troubles.

105. By Francis Ginther

Removed a debug statement and corrected reference.

106. By Francis Ginther

Add support for installing click packages and tests.

107. By Francis Ginther

Move usage of click to the android device.

108. By Francis Ginther

Fix placement of adb -s option."

109. By Francis Ginther

Add generic test runner.

Unmerged revisions

109. By Francis Ginther

Add generic test runner.

108. By Francis Ginther

Fix placement of adb -s option."

107. By Francis Ginther

Move usage of click to the android device.

106. By Francis Ginther

Add support for installing click packages and tests.

105. By Francis Ginther

Removed a debug statement and corrected reference.

104. By Francis Ginther

Add support for zip package archives.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'scripts/click-info.py'
2--- scripts/click-info.py 1970-01-01 00:00:00 +0000
3+++ scripts/click-info.py 2013-11-12 14:46:32 +0000
4@@ -0,0 +1,40 @@
5+#!/usr/bin/env python
6+
7+import argparse
8+import json
9+import subprocess
10+import sys
11+
12+def parse_arguments():
13+ parser = argparse.ArgumentParser(
14+ description='Provides information regarding a click package')
15+ parser.add_argument('--key',
16+ required=True,
17+ help='Returns the requested manifest key value.')
18+ parser.add_argument('--serial',
19+ default=None,
20+ help='Specify the android device serial number.')
21+ parser.add_argument('package', nargs=1,
22+ help='Click pacake to inspect')
23+ return parser.parse_args()
24+
25+
26+def get_value(key, serial, package):
27+ cmd = 'adb %s shell click info %s' % (serial, package)
28+ data = json.loads(subprocess.check_output(cmd, shell=True))
29+ if key in data:
30+ return data[key]
31+ return None
32+
33+
34+def main():
35+ args = parse_arguments()
36+ serial = ""
37+ if args.serial:
38+ serial = "-s %s" % (args.serial)
39+ print(get_value(args.key, serial, args.package[0]))
40+
41+ return 0
42+
43+if __name__ == "__main__":
44+ sys.exit(main())
45
46=== modified file 'scripts/provision.sh'
47--- scripts/provision.sh 2013-11-08 03:13:39 +0000
48+++ scripts/provision.sh 2013-11-12 14:46:32 +0000
49@@ -7,6 +7,7 @@
50 BASEDIR=$(dirname $(readlink -f $0))
51
52 RESDIR=`pwd`/clientlogs
53+ZIPDIR=`pwd`/archive
54
55 NETWORK_FILE="${NETWORK_FILE-/home/ubuntu/magners-wifi}"
56
57@@ -25,7 +26,10 @@
58 -n Select network file
59 -P add the ppa to the target (can be repeated)
60 -p add the package to the target (can be repeated)
61+ -a add a URL for a jenkins created zip archive of packages
62 -w make the system writeable (implied with -p and -P arguments)
63+ -c Specify the click package to install
64+ -C Specify the source directory for click tests
65
66 EOF
67 }
68@@ -49,7 +53,7 @@
69 adb push $RESDIR/.ci-customizations /home/phablet/.ci-customizations
70 }
71
72-while getopts i:s:n:P:p:wh opt; do
73+while getopts i:s:n:P:p:a:c:C:wh opt; do
74 case $opt in
75 h)
76 usage
77@@ -74,6 +78,15 @@
78 p)
79 CUSTOMIZE="$CUSTOMIZE -p $OPTARG"
80 ;;
81+ a)
82+ ARCHIVE="$OPTARG"
83+ ;;
84+ c)
85+ CLICK_PACKAGE="$OPTARG"
86+ ;;
87+ C)
88+ CLICK_SOURCE="$OPTARG"
89+ ;;
90 esac
91 done
92
93@@ -91,12 +104,74 @@
94 set -x
95 [ -d $RESDIR ] && rm -rf $RESDIR
96 mkdir -p $RESDIR
97-
98-phablet-flash $IMAGE_OPT
99-adb wait-for-device
100-sleep 20 #give the system a little time
101-
102-phablet-click-test-setup
103+[ -d $ZIPDIR ] && rm -rf $ZIPDIR
104+
105+# Setup the local archive bits first, exit out before flashing if it fails
106+if [ -n "$ARCHIVE" ]; then
107+ wget $ARCHIVE
108+ ZIPNAME=`basename $ARCHIVE`
109+ unzip $ZIPNAME -d $ZIPDIR
110+ rm $ZIPNAME
111+ if [ -d $ZIPDIR/archive/work/output ]; then
112+ ARCHIVEDIR=$ZIPDIR/archive/work/output
113+ elif [ -e $ZIPDIR/output ]; then
114+ ARCHIVEDIR=$ZIPDIR/output
115+ chmod 755 $ARCHIVEDIR
116+ else
117+ echo "E: Cannot find local package archive" >&2
118+ exit 1
119+ fi
120+ cd $ARCHIVEDIR
121+ dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
122+ cd -
123+fi
124+
125+if [ -n "$SKIP_FLASH" ]; then
126+ echo "SKIPPING phablet-flash AS REQUESTED"
127+else
128+ phablet-flash $IMAGE_OPT
129+ adb wait-for-device
130+ sleep 20 #give the system a little time
131+fi
132+
133+CLICK_PACKAGE_NAME=""
134+CLICK_PACKAGE_SETUP=""
135+if [ -n "$CLICK_PACKAGE" ]; then
136+ # Copy click package to device and install
137+ CLICK_SERIAL=""
138+ if [ -n "$ANDROID_SERIAL" ]; then
139+ CLICK_SERIAL="--serial $ANDROID_SERIAL"
140+ fi
141+ CLICK_BASE_NAME=`basename ${CLICK_PACKAGE}`
142+ adb push "${CLICK_PACKAGE}" /home/phablet/
143+ adb shell "chown phablet:phablet /home/phablet/${CLICK_BASE_NAME}"
144+
145+ CLICK_PACKAGE_NAME=`$BASEDIR/click-info.py $CLICK_SERIAL --key name /home/phablet/${CLICK_BASE_NAME}`
146+ CLICK_PACKAGE_VERSION=`$BASEDIR/click-info.py $CLICK_SERIAL --key version /home/phablet/${CLICK_BASE_NAME}`
147+ CLICK_PACKAGE_SETUP="--click ${CLICK_BASE_NAME}"
148+ adb shell "click install --user phablet /home/phablet/${CLICK_BASE_NAME}"
149+ adb shell "click register --user phablet ${CLICK_PACKAGE_NAME} ${CLICK_PACKAGE_VERSION}"
150+fi
151+
152+if [ -n "$SKIP_CLICK" ]; then
153+ echo "SKIPPING phablet-click-test-setup AS REQUESTED"
154+else
155+ phablet-click-test-setup $CLICK_PACKAGE_SETUP
156+fi
157+
158+if [ -n "$CLICK_SOURCE" ]; then
159+ # Copy click tests to device
160+ # phablet-click-test-setup install tests under /home/phablet/autopilot
161+ AUTOPILOTFILES=`ls ${CLICK_SOURCE}/tests/autopilot/`
162+ for DIR in $AUTOPILOTFILES; do
163+ if [ -d "${CLICK_SOURCE}/tests/autopilot/$DIR" ]; then
164+ adb shell "rm -rf /home/phablet/autopilot/${DIR}"
165+ adb push ${CLICK_SOURCE}/tests/autopilot/${DIR} /home/phablet/autopilot/${DIR}
166+ adb shell "chown -R phablet:phablet /home/phablet/autopilot"
167+ fi
168+ done
169+fi
170+
171 phablet-network -n $NETWORK_FILE
172
173 if [ "$IMAGE_TYPE" = "touch_sf4p" ]; then
174@@ -113,6 +188,14 @@
175
176 image_info
177
178+# Setup the provided archive on the device
179+if [ -n "$ARCHIVE" ]; then
180+ phablet-config writable-image
181+ adb push $ARCHIVEDIR /home/phablet/archive
182+ adb push ${BASEDIR}/../support/00localrepo.list /etc/apt/sources.list.d
183+ adb push ${BASEDIR}/../support/local-pin-1100 /etc/apt/preferences.d
184+fi
185+
186 if [ -n "$CUSTOMIZE" ] ; then
187 echo "= CUSTOMIZING IMAGE"
188 phablet-config writable-image $CUSTOMIZE
189
190=== added file 'scripts/run-generic-tests.sh'
191--- scripts/run-generic-tests.sh 1970-01-01 00:00:00 +0000
192+++ scripts/run-generic-tests.sh 2013-11-12 14:46:32 +0000
193@@ -0,0 +1,142 @@
194+#!/bin/sh
195+
196+set -e
197+
198+BASEDIR=$(dirname $(readlink -f $0))/..
199+RESDIR=`pwd`/clientlogs
200+
201+export PATH=${BASEDIR}/utils/host:${PATH}
202+export TARGET_PREFIX=adb-shell
203+
204+
205+usage() {
206+ cat <<EOF
207+usage: $0 -t test-command [-s ANDROID_SERIAL] ] [-Q] [-o results_dir] [-S]
208+
209+Runs a set of autopilot tests on the target
210+
211+OPTIONS:
212+ -h Show this message
213+ -s Specify the serial of the device to test.
214+ -t The test to execute.
215+ -a A test artifact to collect (can be repeated).
216+ -o Specify the directory to place results in.
217+ Default: $RESDIR
218+ -Q "Quick" don't do a reboot of teh device before/between tests.
219+ -S Skip the system-settle tests that run before/after each test.
220+
221+EOF
222+}
223+
224+system_settle() {
225+ [ -z $NOSETTLE ] || return 0
226+
227+ label=$1
228+ odir=$2
229+ rc=0
230+ settle=${BASEDIR}/tests/systemsettle/systemsettle.sh
231+ {
232+ export UTAH_PROBE_DIR=${odir} # needed for log file location
233+ timeout 120s $settle -c5 -d2 -p 97.5 -l $label || rc=1
234+ echo $rc > ${odir}/settle_${label}.rc
235+ } 2>&1 | tee ${odir}/settle_${label}.log
236+
237+ if [ "$label" = "after" ] ; then
238+ ${BASEDIR}/scripts/combine_results ${odir}
239+ fi
240+}
241+
242+run_test() {
243+ test=$1
244+
245+ test_dir=`echo ${test} | cut -d" " -f1`
246+ odir=${RESDIR}/${test_dir}
247+ [ -d $odir ] && rm -rf $odir
248+ mkdir -p $odir
249+
250+ system_settle before $odir
251+
252+ adb shell $test
253+
254+ system_settle after $odir
255+}
256+
257+reboot_wait() {
258+ if [ -z $QUICK ] ; then
259+ ${BASEDIR}/scripts/reboot-and-wait
260+ adb shell 'rm -rf /var/crash/* /home/phablet/.cache/upstart/*.log'
261+ else
262+ echo "SKIPPING phone reboot..."
263+ fi
264+}
265+
266+collect_logs() {
267+ for artifact in $ARTIFACTS; do
268+ adb pull $artifact ${RESDIR}
269+ done
270+}
271+
272+main() {
273+ # print the build date so the jenkins job can use it as the
274+ # build description
275+ BUILDID=$(adb shell cat /home/phablet/.ci-version)
276+ echo "= TOUCH IMAGE VERSION:$BUILDID"
277+
278+ [ -d $RESDIR ] || mkdir -p $RESDIR
279+
280+ set -x
281+
282+ set +x
283+ echo "========================================================"
284+ echo "= testing $TEST"
285+ echo "========================================================"
286+ set -x
287+ reboot_wait
288+ run_test "$TEST"
289+ collect_logs
290+}
291+
292+while getopts s:t:a:o:QSh opt; do
293+ case $opt in
294+ h)
295+ usage
296+ exit 0
297+ ;;
298+ s)
299+ export ANDROID_SERIAL=$OPTARG
300+ ;;
301+ o)
302+ RESDIR=$OPTARG
303+ ;;
304+ t)
305+ TEST=$OPTARG
306+ ;;
307+ a)
308+ ARTIFACTS="$ARTIFACTS $OPTARG"
309+ ;;
310+ Q)
311+ QUICK=1
312+ ;;
313+ S)
314+ NOSETTLE=1
315+ ;;
316+ esac
317+done
318+
319+if [ -z $ANDROID_SERIAL ] ; then
320+ # ensure we only have one device attached
321+ lines=$(adb devices | wc -l)
322+ if [ $lines -gt 3 ] ; then
323+ echo "ERROR: More than one device attached, please use -s option"
324+ echo
325+ usage
326+ exit 1
327+ fi
328+fi
329+if [ -z "$TEST" ] ; then
330+ echo "ERROR: No test specified"
331+ usage
332+ exit 1
333+fi
334+
335+main
336
337=== added directory 'support'
338=== added file 'support/00localrepo.list'
339--- support/00localrepo.list 1970-01-01 00:00:00 +0000
340+++ support/00localrepo.list 2013-11-12 14:46:32 +0000
341@@ -0,0 +1,1 @@
342+deb file:/home/phablet/archive/ ./
343
344=== added file 'support/local-pin-1100'
345--- support/local-pin-1100 1970-01-01 00:00:00 +0000
346+++ support/local-pin-1100 2013-11-12 14:46:32 +0000
347@@ -0,0 +1,3 @@
348+Package: *
349+Pin: origin ""
350+Pin-Priority: 1100

Subscribers

People subscribed via source and target branches