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
=== added file 'scripts/click-info.py'
--- scripts/click-info.py 1970-01-01 00:00:00 +0000
+++ scripts/click-info.py 2013-11-12 14:46:32 +0000
@@ -0,0 +1,40 @@
1#!/usr/bin/env python
2
3import argparse
4import json
5import subprocess
6import sys
7
8def parse_arguments():
9 parser = argparse.ArgumentParser(
10 description='Provides information regarding a click package')
11 parser.add_argument('--key',
12 required=True,
13 help='Returns the requested manifest key value.')
14 parser.add_argument('--serial',
15 default=None,
16 help='Specify the android device serial number.')
17 parser.add_argument('package', nargs=1,
18 help='Click pacake to inspect')
19 return parser.parse_args()
20
21
22def get_value(key, serial, package):
23 cmd = 'adb %s shell click info %s' % (serial, package)
24 data = json.loads(subprocess.check_output(cmd, shell=True))
25 if key in data:
26 return data[key]
27 return None
28
29
30def main():
31 args = parse_arguments()
32 serial = ""
33 if args.serial:
34 serial = "-s %s" % (args.serial)
35 print(get_value(args.key, serial, args.package[0]))
36
37 return 0
38
39if __name__ == "__main__":
40 sys.exit(main())
041
=== modified file 'scripts/provision.sh'
--- scripts/provision.sh 2013-11-08 03:13:39 +0000
+++ scripts/provision.sh 2013-11-12 14:46:32 +0000
@@ -7,6 +7,7 @@
7BASEDIR=$(dirname $(readlink -f $0))7BASEDIR=$(dirname $(readlink -f $0))
88
9RESDIR=`pwd`/clientlogs9RESDIR=`pwd`/clientlogs
10ZIPDIR=`pwd`/archive
1011
11NETWORK_FILE="${NETWORK_FILE-/home/ubuntu/magners-wifi}"12NETWORK_FILE="${NETWORK_FILE-/home/ubuntu/magners-wifi}"
1213
@@ -25,7 +26,10 @@
25 -n Select network file26 -n Select network file
26 -P add the ppa to the target (can be repeated)27 -P add the ppa to the target (can be repeated)
27 -p add the package to the target (can be repeated)28 -p add the package to the target (can be repeated)
29 -a add a URL for a jenkins created zip archive of packages
28 -w make the system writeable (implied with -p and -P arguments)30 -w make the system writeable (implied with -p and -P arguments)
31 -c Specify the click package to install
32 -C Specify the source directory for click tests
2933
30EOF34EOF
31}35}
@@ -49,7 +53,7 @@
49 adb push $RESDIR/.ci-customizations /home/phablet/.ci-customizations53 adb push $RESDIR/.ci-customizations /home/phablet/.ci-customizations
50}54}
5155
52while getopts i:s:n:P:p:wh opt; do56while getopts i:s:n:P:p:a:c:C:wh opt; do
53 case $opt in57 case $opt in
54 h)58 h)
55 usage59 usage
@@ -74,6 +78,15 @@
74 p)78 p)
75 CUSTOMIZE="$CUSTOMIZE -p $OPTARG"79 CUSTOMIZE="$CUSTOMIZE -p $OPTARG"
76 ;;80 ;;
81 a)
82 ARCHIVE="$OPTARG"
83 ;;
84 c)
85 CLICK_PACKAGE="$OPTARG"
86 ;;
87 C)
88 CLICK_SOURCE="$OPTARG"
89 ;;
77 esac90 esac
78done91done
7992
@@ -91,12 +104,74 @@
91set -x104set -x
92[ -d $RESDIR ] && rm -rf $RESDIR105[ -d $RESDIR ] && rm -rf $RESDIR
93mkdir -p $RESDIR106mkdir -p $RESDIR
94107[ -d $ZIPDIR ] && rm -rf $ZIPDIR
95phablet-flash $IMAGE_OPT108
96adb wait-for-device109# Setup the local archive bits first, exit out before flashing if it fails
97sleep 20 #give the system a little time110if [ -n "$ARCHIVE" ]; then
98111 wget $ARCHIVE
99phablet-click-test-setup112 ZIPNAME=`basename $ARCHIVE`
113 unzip $ZIPNAME -d $ZIPDIR
114 rm $ZIPNAME
115 if [ -d $ZIPDIR/archive/work/output ]; then
116 ARCHIVEDIR=$ZIPDIR/archive/work/output
117 elif [ -e $ZIPDIR/output ]; then
118 ARCHIVEDIR=$ZIPDIR/output
119 chmod 755 $ARCHIVEDIR
120 else
121 echo "E: Cannot find local package archive" >&2
122 exit 1
123 fi
124 cd $ARCHIVEDIR
125 dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
126 cd -
127fi
128
129if [ -n "$SKIP_FLASH" ]; then
130 echo "SKIPPING phablet-flash AS REQUESTED"
131else
132 phablet-flash $IMAGE_OPT
133 adb wait-for-device
134 sleep 20 #give the system a little time
135fi
136
137CLICK_PACKAGE_NAME=""
138CLICK_PACKAGE_SETUP=""
139if [ -n "$CLICK_PACKAGE" ]; then
140 # Copy click package to device and install
141 CLICK_SERIAL=""
142 if [ -n "$ANDROID_SERIAL" ]; then
143 CLICK_SERIAL="--serial $ANDROID_SERIAL"
144 fi
145 CLICK_BASE_NAME=`basename ${CLICK_PACKAGE}`
146 adb push "${CLICK_PACKAGE}" /home/phablet/
147 adb shell "chown phablet:phablet /home/phablet/${CLICK_BASE_NAME}"
148
149 CLICK_PACKAGE_NAME=`$BASEDIR/click-info.py $CLICK_SERIAL --key name /home/phablet/${CLICK_BASE_NAME}`
150 CLICK_PACKAGE_VERSION=`$BASEDIR/click-info.py $CLICK_SERIAL --key version /home/phablet/${CLICK_BASE_NAME}`
151 CLICK_PACKAGE_SETUP="--click ${CLICK_BASE_NAME}"
152 adb shell "click install --user phablet /home/phablet/${CLICK_BASE_NAME}"
153 adb shell "click register --user phablet ${CLICK_PACKAGE_NAME} ${CLICK_PACKAGE_VERSION}"
154fi
155
156if [ -n "$SKIP_CLICK" ]; then
157 echo "SKIPPING phablet-click-test-setup AS REQUESTED"
158else
159 phablet-click-test-setup $CLICK_PACKAGE_SETUP
160fi
161
162if [ -n "$CLICK_SOURCE" ]; then
163 # Copy click tests to device
164 # phablet-click-test-setup install tests under /home/phablet/autopilot
165 AUTOPILOTFILES=`ls ${CLICK_SOURCE}/tests/autopilot/`
166 for DIR in $AUTOPILOTFILES; do
167 if [ -d "${CLICK_SOURCE}/tests/autopilot/$DIR" ]; then
168 adb shell "rm -rf /home/phablet/autopilot/${DIR}"
169 adb push ${CLICK_SOURCE}/tests/autopilot/${DIR} /home/phablet/autopilot/${DIR}
170 adb shell "chown -R phablet:phablet /home/phablet/autopilot"
171 fi
172 done
173fi
174
100phablet-network -n $NETWORK_FILE175phablet-network -n $NETWORK_FILE
101176
102if [ "$IMAGE_TYPE" = "touch_sf4p" ]; then177if [ "$IMAGE_TYPE" = "touch_sf4p" ]; then
@@ -113,6 +188,14 @@
113188
114image_info189image_info
115190
191# Setup the provided archive on the device
192if [ -n "$ARCHIVE" ]; then
193 phablet-config writable-image
194 adb push $ARCHIVEDIR /home/phablet/archive
195 adb push ${BASEDIR}/../support/00localrepo.list /etc/apt/sources.list.d
196 adb push ${BASEDIR}/../support/local-pin-1100 /etc/apt/preferences.d
197fi
198
116if [ -n "$CUSTOMIZE" ] ; then199if [ -n "$CUSTOMIZE" ] ; then
117 echo "= CUSTOMIZING IMAGE"200 echo "= CUSTOMIZING IMAGE"
118 phablet-config writable-image $CUSTOMIZE201 phablet-config writable-image $CUSTOMIZE
119202
=== added file 'scripts/run-generic-tests.sh'
--- scripts/run-generic-tests.sh 1970-01-01 00:00:00 +0000
+++ scripts/run-generic-tests.sh 2013-11-12 14:46:32 +0000
@@ -0,0 +1,142 @@
1#!/bin/sh
2
3set -e
4
5BASEDIR=$(dirname $(readlink -f $0))/..
6RESDIR=`pwd`/clientlogs
7
8export PATH=${BASEDIR}/utils/host:${PATH}
9export TARGET_PREFIX=adb-shell
10
11
12usage() {
13 cat <<EOF
14usage: $0 -t test-command [-s ANDROID_SERIAL] ] [-Q] [-o results_dir] [-S]
15
16Runs a set of autopilot tests on the target
17
18OPTIONS:
19 -h Show this message
20 -s Specify the serial of the device to test.
21 -t The test to execute.
22 -a A test artifact to collect (can be repeated).
23 -o Specify the directory to place results in.
24 Default: $RESDIR
25 -Q "Quick" don't do a reboot of teh device before/between tests.
26 -S Skip the system-settle tests that run before/after each test.
27
28EOF
29}
30
31system_settle() {
32 [ -z $NOSETTLE ] || return 0
33
34 label=$1
35 odir=$2
36 rc=0
37 settle=${BASEDIR}/tests/systemsettle/systemsettle.sh
38 {
39 export UTAH_PROBE_DIR=${odir} # needed for log file location
40 timeout 120s $settle -c5 -d2 -p 97.5 -l $label || rc=1
41 echo $rc > ${odir}/settle_${label}.rc
42 } 2>&1 | tee ${odir}/settle_${label}.log
43
44 if [ "$label" = "after" ] ; then
45 ${BASEDIR}/scripts/combine_results ${odir}
46 fi
47}
48
49run_test() {
50 test=$1
51
52 test_dir=`echo ${test} | cut -d" " -f1`
53 odir=${RESDIR}/${test_dir}
54 [ -d $odir ] && rm -rf $odir
55 mkdir -p $odir
56
57 system_settle before $odir
58
59 adb shell $test
60
61 system_settle after $odir
62}
63
64reboot_wait() {
65 if [ -z $QUICK ] ; then
66 ${BASEDIR}/scripts/reboot-and-wait
67 adb shell 'rm -rf /var/crash/* /home/phablet/.cache/upstart/*.log'
68 else
69 echo "SKIPPING phone reboot..."
70 fi
71}
72
73collect_logs() {
74 for artifact in $ARTIFACTS; do
75 adb pull $artifact ${RESDIR}
76 done
77}
78
79main() {
80 # print the build date so the jenkins job can use it as the
81 # build description
82 BUILDID=$(adb shell cat /home/phablet/.ci-version)
83 echo "= TOUCH IMAGE VERSION:$BUILDID"
84
85 [ -d $RESDIR ] || mkdir -p $RESDIR
86
87 set -x
88
89 set +x
90 echo "========================================================"
91 echo "= testing $TEST"
92 echo "========================================================"
93 set -x
94 reboot_wait
95 run_test "$TEST"
96 collect_logs
97}
98
99while getopts s:t:a:o:QSh opt; do
100 case $opt in
101 h)
102 usage
103 exit 0
104 ;;
105 s)
106 export ANDROID_SERIAL=$OPTARG
107 ;;
108 o)
109 RESDIR=$OPTARG
110 ;;
111 t)
112 TEST=$OPTARG
113 ;;
114 a)
115 ARTIFACTS="$ARTIFACTS $OPTARG"
116 ;;
117 Q)
118 QUICK=1
119 ;;
120 S)
121 NOSETTLE=1
122 ;;
123 esac
124done
125
126if [ -z $ANDROID_SERIAL ] ; then
127 # ensure we only have one device attached
128 lines=$(adb devices | wc -l)
129 if [ $lines -gt 3 ] ; then
130 echo "ERROR: More than one device attached, please use -s option"
131 echo
132 usage
133 exit 1
134 fi
135fi
136if [ -z "$TEST" ] ; then
137 echo "ERROR: No test specified"
138 usage
139 exit 1
140fi
141
142main
0143
=== added directory 'support'
=== added file 'support/00localrepo.list'
--- support/00localrepo.list 1970-01-01 00:00:00 +0000
+++ support/00localrepo.list 2013-11-12 14:46:32 +0000
@@ -0,0 +1,1 @@
1deb file:/home/phablet/archive/ ./
02
=== added file 'support/local-pin-1100'
--- support/local-pin-1100 1970-01-01 00:00:00 +0000
+++ support/local-pin-1100 2013-11-12 14:46:32 +0000
@@ -0,0 +1,3 @@
1Package: *
2Pin: origin ""
3Pin-Priority: 1100

Subscribers

People subscribed via source and target branches