Merge lp:~nuclearbob/ubuntu-test-cases/touch-trace-export into lp:ubuntu-test-cases/touch

Proposed by Max Brustkern
Status: Needs review
Proposed branch: lp:~nuclearbob/ubuntu-test-cases/touch-trace-export
Merge into: lp:ubuntu-test-cases/touch
Prerequisite: lp:~pwlars/ubuntu-test-cases/touch-add-krillins
Diff against target: 375 lines (+300/-1)
11 files modified
README-cli.rst (+1/-1)
jenkins/templates/touch-base.xml.jinja2 (+16/-0)
jenkins/testconfig.py (+4/-0)
scripts/app-trace-export.py (+101/-0)
tests/app-startup-benchmark/app-startup.sh (+107/-0)
tests/app-startup-benchmark/blacklist (+3/-0)
tests/app-startup-benchmark/master.run (+5/-0)
tests/app-startup-benchmark/setup.sh (+23/-0)
tests/app-startup-benchmark/ts_control (+1/-0)
tests/app-startup-benchmark/tslist.auto (+4/-0)
utils/target/app-startup-benchmark.sh (+35/-0)
To merge this branch: bzr merge lp:~nuclearbob/ubuntu-test-cases/touch-trace-export
Reviewer Review Type Date Requested Status
Leo Arias (community) Disapprove
Max Brustkern (community) Needs Resubmitting
Paul Larson Needs Fixing
Francis Ginther Pending
Review via email: mp+229278@code.launchpad.net

This proposal supersedes a proposal from 2014-07-21.

Description of the change

This branch adds app startup benchmarking tests. It now relies on Paul's branch that adds the device type to the available variables.

To post a comment you must log in.
Revision history for this message
Max Brustkern (nuclearbob) wrote : Posted in a previous version of this proposal

I'd like to get a review of this so we can get app startup benchmarking running on each image. I'm not at all sure I'm doing the right thing for the job templates, so guidance on that would be appreciated.

Revision history for this message
Francis Ginther (fginther) wrote : Posted in a previous version of this proposal

A few comments inline, mostly questions.

review: Needs Information
Revision history for this message
Max Brustkern (nuclearbob) wrote : Posted in a previous version of this proposal

I'm pushing a couple of changes to address two of these.

Revision history for this message
Paul Larson (pwlars) wrote :

A couple of comments/questions below. What happens if that app-trace-export.py or insertion script fails? We need to be cautious about adding something that if it goes wrong, will cause the subsequent jobs to fail. I'd like to run this through some testing, but don't think I can at the moment due to the missing insertion script.

review: Needs Fixing
Revision history for this message
Max Brustkern (nuclearbob) wrote :

The data generation and insertion scripts run on the host and don't affect the device, so I don't think they have a high probability of failing unless we're making changes to the adb host. If they do fail, they won't create or write data on the adb host, but that should have no effect on future runs.

I've replied to diff comments individually. It seems like between the package installations and the aa containment changes, this may not run well in sequence with other smoke jobs. Is there a better way to have something run once per image after the other jobs have completed?

208. By Max Brustkern

Added nfss insertion script

209. By Max Brustkern

Merged changes

210. By Ted Gould

Make it so that we can have an Upstart config file for our env vars

211. By Ted Gould

Dropping setting env per test

212. By Ted Gould

Make sure to install UTAH too

213. By Ted Gould

Ensure the LTTng tools are installed

214. By Ted Gould

Switch to using UAL completely

215. By Ted Gould

Since the tests reboot anyway, settling is pretty useless

216. By Ted Gould

Use the reboot-and-unlock from autopilot to ensure we're in a good Unity

217. By Ted Gould

Fix command name

218. By Ted Gould

Ensure we're engaged

219. By Ted Gould

Don't think we need the update

220. By Ted Gould

Quiet

221. By Ted Gould

Give two secs for the display to come up, to ensure we're stable

222. By Ted Gould

Different tracepoitns

223. By Ted Gould

Cleanup the PIDs to turn on the screen

224. By Ted Gould

Give the dash more time to settle

225. By Ted Gould

Stop the dash so it can't screw things up

226. By Ted Gould

Make sure to trap on error

227. By Ted Gould

Change the tracking of tracepoints

228. By Ted Gould

Merge trunk

229. By Max Brustkern

Skipping actual launch

230. By Max Brustkern

Merged latest changes

231. By Max Brustkern

Adding local krillin

232. By Max Brustkern

Launch back in

233. By Max Brustkern

Cleaning up leftovers from iteration

234. By Max Brustkern

Updating nfss variable reading

235. By Max Brustkern

Job configuration updates

236. By Max Brustkern

Restored old name

237. By Max Brustkern

Re-applying Ted's updates

238. By Max Brustkern

Using sudo for apt-get

239. By Max Brustkern

Being -ex(plicit) about setup

240. By Max Brustkern

Updated nfss insert path

241. By Max Brustkern

Reverted some bootspeed changes that should go in a different branch

242. By Max Brustkern

Multiple runs of all click packages

243. By Max Brustkern

Removed testing configuration

244. By Max Brustkern

Updated installation instructions to use phase 0 PPA

245. By Max Brustkern

Adding application whitelist and blacklist and blacklisting file manager

246. By Max Brustkern

Removed file manager from blacklist

247. By Max Brustkern

Raised timeout

248. By Max Brustkern

Fixed blacklist

249. By Max Brustkern

Added blacklist apps

250. By Max Brustkern

Merged upstream changes

251. By Max Brustkern

Fixed environment variables

252. By Max Brustkern

Removed uneeded environment variables

253. By Max Brustkern

Integrated more tracepoints

254. By Max Brustkern

Giving a little extra time before timeout

Revision history for this message
Max Brustkern (nuclearbob) wrote :

This should be ready to review again. The comment change to setup_jenkins.py was for pep8 compliance. The change to provision.sh was to support package installation. That's no longer used in this branch, so I can take it out, but it seems like it is still the right way to do things now that a password is required? Let me know what questions you have.

review: Needs Resubmitting
255. By Max Brustkern

Merged changes

Revision history for this message
Leo Arias (elopio) wrote :

I copied Max's code and turned it into dep8 tests in https://code.launchpad.net/~canonical-platform-qa/ubuntu-test-cases/dep8-app-startup/+merge/241613

Max, it would be nice if you could take a look at it to confirm I didn't misunderstood anything.

review: Disapprove

Unmerged revisions

255. By Max Brustkern

Merged changes

254. By Max Brustkern

Giving a little extra time before timeout

253. By Max Brustkern

Integrated more tracepoints

252. By Max Brustkern

Removed uneeded environment variables

251. By Max Brustkern

Fixed environment variables

250. By Max Brustkern

Merged upstream changes

249. By Max Brustkern

Added blacklist apps

248. By Max Brustkern

Fixed blacklist

247. By Max Brustkern

Raised timeout

246. By Max Brustkern

Removed file manager from blacklist

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README-cli.rst'
2--- README-cli.rst 2014-11-10 19:28:56 +0000
3+++ README-cli.rst 2014-11-14 15:22:02 +0000
4@@ -64,7 +64,7 @@
5
6 sudo add-apt-repository ppa:utah/stable
7 sudo apt-get update
8- sudo apt-get install utah-client
9+ sudo apt-get install utah utah-client
10
11 With that package installed UTAH tests can be run with::
12
13
14=== modified file 'jenkins/templates/touch-base.xml.jinja2'
15--- jenkins/templates/touch-base.xml.jinja2 2014-10-31 03:02:46 +0000
16+++ jenkins/templates/touch-base.xml.jinja2 2014-11-14 15:22:02 +0000
17@@ -73,6 +73,22 @@
18 python3 ${BZRDIR}/tests/memevent/nfss_upload_results.py ./clientlogs/ nfss_insert.py ${NFSS_CONFIG_FILE}
19 {% endif %}
20 {% endif %}
21+{% if test == 'app-startup-benchmark' %}
22+NFSS_CONFIG_FILE=${WORKSPACE}/nfss_config
23+cat - > ${NFSS_CONFIG_FILE} <<EOD
24+{{nfss_config}}
25+EOD
26+adb pull /home/phablet/lttng-traces ./clientlogs/lttng-traces
27+cd ./clientlogs/lttng-traces
28+for DIR in $(find -mindepth 1 -maxdepth 1 -type d)
29+do
30+ export PACKAGE_NAME=$(echo "$DIR" | sed 's/\.\/\(.*\)-startup.*/\1/')
31+ export APP_ID=$(cat $DIR/app_id)
32+ export JSON_FILE=$DIR/results.json
33+ ${BZRDIR}/scripts/app-trace-export.py ${PACKAGE_NAME} ${APP_ID} ${DIR}/ust/uid/32011/32-bit/
34+ cat $JSON_FILE | nfss_insert.py ${NFSS_CONFIG_FILE} app-startup $PACKAGE_NAME
35+done
36+{% endif %}
37 ]]></command>
38 </hudson.tasks.Shell>
39 </builders>
40
41=== modified file 'jenkins/testconfig.py'
42--- jenkins/testconfig.py 2014-11-12 03:15:23 +0000
43+++ jenkins/testconfig.py 2014-11-14 15:22:02 +0000
44@@ -94,6 +94,10 @@
45 Test('bootspeed',
46 fmt='{prefix}{testname}-{series}-{imagetype}-{type}-{type}',
47 smoke=False),
48+ Test('app-startup-benchmark',
49+ fmt='{prefix}{testname}-{series}-{imagetype}-{type}-{type}',
50+ smoke=False,
51+ timeout=24300),
52 ]
53
54
55
56=== added file 'scripts/app-trace-export.py'
57--- scripts/app-trace-export.py 1970-01-01 00:00:00 +0000
58+++ scripts/app-trace-export.py 2014-11-14 15:22:02 +0000
59@@ -0,0 +1,101 @@
60+#!/usr/bin/env python3
61+
62+"""
63+Export application trace events for app startup.
64+"""
65+
66+import argparse
67+import json
68+import os
69+
70+from datetime import datetime
71+from pprint import pprint
72+
73+from babeltrace import TraceCollection
74+# Install Python bindings for libbabeltrace:
75+# $ sudo add-apt-repository -y \
76+# $ ppa:canonical-ci-engineering/ci-airline-phase-0
77+# $ sudo apt-get update
78+# $ sudo apt-get -qy install babeltrace python3-babeltrace
79+
80+
81+def parse_traces(trace_path):
82+ """
83+ Read binary traces and convert to dict of
84+ tracepoint names and timestamps. Timestamp format is:
85+ epoch secs + nanosecs.
86+ """
87+
88+ # Tracepoints to include for app startup
89+ tracepoints = {
90+ 'libual_start': {},
91+ 'libual_start_message_sent': {},
92+ 'libual_start_message_callback': {},
93+ 'handshake_wait': {},
94+ 'handshake_complete': {},
95+ 'exec_pre_exec': {},
96+ }
97+
98+ # Build up the traces collection
99+ traces = TraceCollection()
100+ ret = traces.add_trace(trace_path, 'ctf')
101+ if ret is None:
102+ raise IOError('Error adding trace')
103+
104+ # Record the timestamps
105+ timestamps = {}
106+ for event in traces.events:
107+ name = event.name.split(':')[1]
108+ # We only want the event if it's the first occurance to
109+ # handle possibly messy traces.
110+ if name not in timestamps:
111+ # Keep only the timestamps we care about by event name
112+ if name in tracepoints:
113+ if len(tracepoints[name]) == 0:
114+ timestamps[name] = event.timestamp
115+ else:
116+ fieldname = name
117+ for field in tracepoints[name]:
118+ if not event[field] == tracepoints[name][field]:
119+ fieldname = None
120+ break
121+ else:
122+ fieldname += ":{}={}".format(
123+ field, tracepoints[name][field])
124+
125+ if fieldname is not None and fieldname not in timestamps:
126+ timestamps[fieldname] = event.timestamp
127+
128+ return timestamps
129+
130+
131+def generate_doc(tracepoints, app_id):
132+ return dict(
133+ package_name=args.package_name,
134+ app_id=app_id,
135+ android_serial=os.environ.get('ANDROID_SERIAL'),
136+ image_type=os.environ.get('IMAGE_TYPE'),
137+ build_num=os.environ.get('BUILD_NUMBER'),
138+ build_id=os.environ.get('BUILD_ID'),
139+ job_name=os.environ.get('JOB_NAME'),
140+ node_name=os.environ.get('NODE_NAME'),
141+ datetime=datetime.utcnow().isoformat(),
142+ tracepoints=tracepoints,
143+ )
144+
145+
146+if __name__ == '__main__':
147+ parser = argparse.ArgumentParser()
148+ parser.add_argument('package_name', help='click package name')
149+ parser.add_argument('app_id', help='application identifier')
150+ parser.add_argument('path', help='path to trace')
151+ args = parser.parse_args()
152+
153+ tracepoints = parse_traces(args.path),
154+ doc = generate_doc(tracepoints, args.app_id)
155+
156+ pprint(doc)
157+
158+ if os.environ.get('JSON_FILE'):
159+ with open(os.environ.get('JSON_FILE'), 'w') as jsonfile:
160+ json.dump(doc, jsonfile)
161
162=== added directory 'tests/app-startup-benchmark'
163=== added file 'tests/app-startup-benchmark/app-startup.sh'
164--- tests/app-startup-benchmark/app-startup.sh 1970-01-01 00:00:00 +0000
165+++ tests/app-startup-benchmark/app-startup.sh 2014-11-14 15:22:02 +0000
166@@ -0,0 +1,107 @@
167+#!/bin/bash
168+
169+## This is the script jenkins should run for app startup benchmarks
170+
171+set -e
172+
173+CMD_PREFIX=""
174+BENCHMARK_CMD="app-startup-benchmark.sh"
175+
176+
177+usage() {
178+ cat <<EOF
179+usage: $0 -a APP [-s ANDROID_SERIAL] [-Q] [-t TIMEOUT]
180+
181+Benchmark the startup of APP
182+
183+OPTIONS:
184+ -h Show this message
185+ -s Specify the serial of the device to install
186+ -a The name of the application to start
187+ -Q "Quick" don't do a reboot of the device before running the test
188+ -t Time to wait for application startup (Default is 60)
189+ -r Number of times to repeat (Default is 1)
190+
191+EOF
192+}
193+
194+PIDS=""
195+
196+cleanup() {
197+ set +e
198+ echo "killing child pids: $PIDS"
199+ for p in $PIDS ; do
200+ kill $p
201+ done
202+}
203+
204+main() {
205+ PIDS=""
206+
207+ set -x
208+ if [ -z $QUICK ] ; then
209+ reboot-and-unlock.sh
210+ adb-shell ${CMD_PREFIX} initctl stop unity8-dash
211+ adb shell powerd-cli active &
212+ PIDS="$PIDS $!"
213+ adb shell powerd-cli display on &
214+ PIDS="$PIDS $!"
215+ sleep 5
216+ else
217+ echo "SKIPPING phone reboot..."
218+ fi
219+
220+ echo "launching benchmark...."
221+ [ -z $ANDROID_SERIAL ] || ADBOPTS="-s $ANDROID_SERIAL"
222+ adb-shell ${CMD_PREFIX} ${BENCHMARK_CMD} $APP $TIMEOUT
223+
224+ cleanup
225+}
226+
227+export REPEAT=1
228+
229+while getopts p:s:a:Qt:r:h opt; do
230+ case $opt in
231+ h)
232+ usage
233+ exit 0
234+ ;;
235+ s)
236+ export ANDROID_SERIAL=$OPTARG
237+ ;;
238+ a)
239+ APP=$OPTARG
240+ ;;
241+ Q)
242+ QUICK=1
243+ ;;
244+ t)
245+ export TIMEOUT=$OPTARG
246+ ;;
247+ r)
248+ export REPEAT=$OPTARG
249+ ;;
250+ esac
251+done
252+
253+if [ -z $ANDROID_SERIAL ] ; then
254+ # ensure we only have one device attached
255+ lines=$(adb devices | wc -l)
256+ if [ $lines -gt 3 ] ; then
257+ echo "ERROR: More than one device attached, please use -s option"
258+ echo
259+ usage
260+ exit 1
261+ fi
262+fi
263+if [ -z $APP ] ; then
264+ echo "ERROR: No app specified"
265+ usage
266+ exit 1
267+fi
268+
269+trap cleanup TERM INT EXIT
270+
271+for X in $(seq $REPEAT) ; do
272+ main
273+done
274
275=== added file 'tests/app-startup-benchmark/blacklist'
276--- tests/app-startup-benchmark/blacklist 1970-01-01 00:00:00 +0000
277+++ tests/app-startup-benchmark/blacklist 2014-11-14 15:22:02 +0000
278@@ -0,0 +1,3 @@
279+com.canonical.payui
280+com.ubuntu.reminders
281+com.ubuntu.scopes.youtube
282
283=== added file 'tests/app-startup-benchmark/master.run'
284--- tests/app-startup-benchmark/master.run 1970-01-01 00:00:00 +0000
285+++ tests/app-startup-benchmark/master.run 2014-11-14 15:22:02 +0000
286@@ -0,0 +1,5 @@
287+---
288+testsuites:
289+ - name: app-startup-benchmark
290+ fetch_method: dev
291+ fetch_location: ./
292
293=== added file 'tests/app-startup-benchmark/setup.sh'
294--- tests/app-startup-benchmark/setup.sh 1970-01-01 00:00:00 +0000
295+++ tests/app-startup-benchmark/setup.sh 2014-11-14 15:22:02 +0000
296@@ -0,0 +1,23 @@
297+#!/bin/sh
298+
299+set -ex
300+
301+echo "Installing LTTng"
302+adb-shell "sudo apt-get install -yq lttng-modules-dkms lttng-tools"
303+
304+echo "Removing old traces"
305+adb-shell "rm -rf /home/phablet/lttng-traces"
306+
307+echo "Allowing LTTng events from confined applications"
308+adb-shell "sudo sed 's/deny \\(.*shm\\/lttng-ust-.*\\)/\\1\nowner @{HOME}\/.lttng\/ rw,\nowner @{HOME}\/.lttng\/\* rwk,\n\/run\/lttng\/ rw,\n\/run\/lttng\/** rwk,/' -i /usr/share/apparmor/easyprof/templates/ubuntu/*/ubuntu-*"
309+
310+echo "Regenerating AppArmor profiles for installed click applications"
311+adb-shell "sudo aa-clickhook -f"
312+
313+echo "Setting environment variables for session"
314+adb-shell "mkdir -p /home/phablet/.config/upstart"
315+adb-shell "echo \"start on starting dbus\" > /home/phablet/.config/upstart/lttng-trace.conf"
316+adb-shell "echo \"script\" >> /home/phablet/.config/upstart/lttng-trace.conf"
317+adb-shell "echo \"initctl set-env --global LTTNG_UST_REGISTER_TIMEOUT=-1\" >> /home/phablet/.config/upstart/lttng-trace.conf"
318+adb-shell "echo \"initctl set-env --global UBUNTU_APP_LAUNCH_LTTNG_ENABLED=TRUE\" >> /home/phablet/.config/upstart/lttng-trace.conf"
319+adb-shell "echo \"end script\" >> /home/phablet/.config/upstart/lttng-trace.conf"
320
321=== added file 'tests/app-startup-benchmark/ts_control'
322--- tests/app-startup-benchmark/ts_control 1970-01-01 00:00:00 +0000
323+++ tests/app-startup-benchmark/ts_control 2014-11-14 15:22:02 +0000
324@@ -0,0 +1,1 @@
325+ts_setup: ./setup.sh
326
327=== added file 'tests/app-startup-benchmark/tslist.auto'
328--- tests/app-startup-benchmark/tslist.auto 1970-01-01 00:00:00 +0000
329+++ tests/app-startup-benchmark/tslist.auto 2014-11-14 15:22:02 +0000
330@@ -0,0 +1,4 @@
331+-
332+ discovery_cmd: adb-shell click list | grep -v "ADB_RC" | awk '{print $1}' | grep -vf app-startup-benchmark/blacklist | cat - app-startup-benchmark/whitelist | sort | uniq
333+ test_cmd: ../app-startup.sh -a {} -r 10 -t 10
334+
335
336=== added file 'tests/app-startup-benchmark/whitelist'
337=== added file 'utils/target/app-startup-benchmark.sh'
338--- utils/target/app-startup-benchmark.sh 1970-01-01 00:00:00 +0000
339+++ utils/target/app-startup-benchmark.sh 2014-11-14 15:22:02 +0000
340@@ -0,0 +1,35 @@
341+#!/bin/bash
342+
343+set -x
344+
345+echo "Setting environment variables for tracing"
346+export LTTNG_UST_REGISTER_TIMEOUT=-1
347+export UBUNTU_APP_LAUNCH_LTTNG_ENABLED=TRUE
348+
349+echo "Creating dummy session without -e to get around first run error"
350+lttng create dummy
351+lttng destroy dummy
352+
353+set -e
354+
355+if [ -z ${1} ]
356+then
357+ echo "Usage:" >&2
358+ echo "$0 APP [TIMEOUT]" >&2
359+ exit 1
360+fi
361+
362+PACKAGE=${1}
363+APP_ID=$(ubuntu-app-triplet ${PACKAGE})
364+
365+DIR=$(lttng create ${PACKAGE}-startup | grep "Traces will be written in" | awk '{print $NF}')
366+
367+lttng enable-event -u -a
368+lttng start
369+
370+ubuntu-app-launch ${APP_ID}
371+
372+sleep ${2-30}
373+lttng stop
374+lttng destroy ${PACKAGE}-startup
375+echo $APP_ID > $DIR/app_id

Subscribers

People subscribed via source and target branches