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
=== modified file 'README-cli.rst'
--- README-cli.rst 2014-11-10 19:28:56 +0000
+++ README-cli.rst 2014-11-14 15:22:02 +0000
@@ -64,7 +64,7 @@
6464
65 sudo add-apt-repository ppa:utah/stable65 sudo add-apt-repository ppa:utah/stable
66 sudo apt-get update66 sudo apt-get update
67 sudo apt-get install utah-client67 sudo apt-get install utah utah-client
6868
69With that package installed UTAH tests can be run with::69With that package installed UTAH tests can be run with::
7070
7171
=== modified file 'jenkins/templates/touch-base.xml.jinja2'
--- jenkins/templates/touch-base.xml.jinja2 2014-10-31 03:02:46 +0000
+++ jenkins/templates/touch-base.xml.jinja2 2014-11-14 15:22:02 +0000
@@ -73,6 +73,22 @@
73python3 ${BZRDIR}/tests/memevent/nfss_upload_results.py ./clientlogs/ nfss_insert.py ${NFSS_CONFIG_FILE}73python3 ${BZRDIR}/tests/memevent/nfss_upload_results.py ./clientlogs/ nfss_insert.py ${NFSS_CONFIG_FILE}
74{% endif %}74{% endif %}
75{% endif %}75{% endif %}
76{% if test == 'app-startup-benchmark' %}
77NFSS_CONFIG_FILE=${WORKSPACE}/nfss_config
78cat - > ${NFSS_CONFIG_FILE} <<EOD
79{{nfss_config}}
80EOD
81adb pull /home/phablet/lttng-traces ./clientlogs/lttng-traces
82cd ./clientlogs/lttng-traces
83for DIR in $(find -mindepth 1 -maxdepth 1 -type d)
84do
85 export PACKAGE_NAME=$(echo "$DIR" | sed 's/\.\/\(.*\)-startup.*/\1/')
86 export APP_ID=$(cat $DIR/app_id)
87 export JSON_FILE=$DIR/results.json
88 ${BZRDIR}/scripts/app-trace-export.py ${PACKAGE_NAME} ${APP_ID} ${DIR}/ust/uid/32011/32-bit/
89 cat $JSON_FILE | nfss_insert.py ${NFSS_CONFIG_FILE} app-startup $PACKAGE_NAME
90done
91{% endif %}
76 ]]></command>92 ]]></command>
77 </hudson.tasks.Shell>93 </hudson.tasks.Shell>
78 </builders>94 </builders>
7995
=== modified file 'jenkins/testconfig.py'
--- jenkins/testconfig.py 2014-11-12 03:15:23 +0000
+++ jenkins/testconfig.py 2014-11-14 15:22:02 +0000
@@ -94,6 +94,10 @@
94 Test('bootspeed',94 Test('bootspeed',
95 fmt='{prefix}{testname}-{series}-{imagetype}-{type}-{type}',95 fmt='{prefix}{testname}-{series}-{imagetype}-{type}-{type}',
96 smoke=False),96 smoke=False),
97 Test('app-startup-benchmark',
98 fmt='{prefix}{testname}-{series}-{imagetype}-{type}-{type}',
99 smoke=False,
100 timeout=24300),
97]101]
98102
99103
100104
=== added file 'scripts/app-trace-export.py'
--- scripts/app-trace-export.py 1970-01-01 00:00:00 +0000
+++ scripts/app-trace-export.py 2014-11-14 15:22:02 +0000
@@ -0,0 +1,101 @@
1#!/usr/bin/env python3
2
3"""
4Export application trace events for app startup.
5"""
6
7import argparse
8import json
9import os
10
11from datetime import datetime
12from pprint import pprint
13
14from babeltrace import TraceCollection
15# Install Python bindings for libbabeltrace:
16# $ sudo add-apt-repository -y \
17# $ ppa:canonical-ci-engineering/ci-airline-phase-0
18# $ sudo apt-get update
19# $ sudo apt-get -qy install babeltrace python3-babeltrace
20
21
22def parse_traces(trace_path):
23 """
24 Read binary traces and convert to dict of
25 tracepoint names and timestamps. Timestamp format is:
26 epoch secs + nanosecs.
27 """
28
29 # Tracepoints to include for app startup
30 tracepoints = {
31 'libual_start': {},
32 'libual_start_message_sent': {},
33 'libual_start_message_callback': {},
34 'handshake_wait': {},
35 'handshake_complete': {},
36 'exec_pre_exec': {},
37 }
38
39 # Build up the traces collection
40 traces = TraceCollection()
41 ret = traces.add_trace(trace_path, 'ctf')
42 if ret is None:
43 raise IOError('Error adding trace')
44
45 # Record the timestamps
46 timestamps = {}
47 for event in traces.events:
48 name = event.name.split(':')[1]
49 # We only want the event if it's the first occurance to
50 # handle possibly messy traces.
51 if name not in timestamps:
52 # Keep only the timestamps we care about by event name
53 if name in tracepoints:
54 if len(tracepoints[name]) == 0:
55 timestamps[name] = event.timestamp
56 else:
57 fieldname = name
58 for field in tracepoints[name]:
59 if not event[field] == tracepoints[name][field]:
60 fieldname = None
61 break
62 else:
63 fieldname += ":{}={}".format(
64 field, tracepoints[name][field])
65
66 if fieldname is not None and fieldname not in timestamps:
67 timestamps[fieldname] = event.timestamp
68
69 return timestamps
70
71
72def generate_doc(tracepoints, app_id):
73 return dict(
74 package_name=args.package_name,
75 app_id=app_id,
76 android_serial=os.environ.get('ANDROID_SERIAL'),
77 image_type=os.environ.get('IMAGE_TYPE'),
78 build_num=os.environ.get('BUILD_NUMBER'),
79 build_id=os.environ.get('BUILD_ID'),
80 job_name=os.environ.get('JOB_NAME'),
81 node_name=os.environ.get('NODE_NAME'),
82 datetime=datetime.utcnow().isoformat(),
83 tracepoints=tracepoints,
84 )
85
86
87if __name__ == '__main__':
88 parser = argparse.ArgumentParser()
89 parser.add_argument('package_name', help='click package name')
90 parser.add_argument('app_id', help='application identifier')
91 parser.add_argument('path', help='path to trace')
92 args = parser.parse_args()
93
94 tracepoints = parse_traces(args.path),
95 doc = generate_doc(tracepoints, args.app_id)
96
97 pprint(doc)
98
99 if os.environ.get('JSON_FILE'):
100 with open(os.environ.get('JSON_FILE'), 'w') as jsonfile:
101 json.dump(doc, jsonfile)
0102
=== added directory 'tests/app-startup-benchmark'
=== added file 'tests/app-startup-benchmark/app-startup.sh'
--- tests/app-startup-benchmark/app-startup.sh 1970-01-01 00:00:00 +0000
+++ tests/app-startup-benchmark/app-startup.sh 2014-11-14 15:22:02 +0000
@@ -0,0 +1,107 @@
1#!/bin/bash
2
3## This is the script jenkins should run for app startup benchmarks
4
5set -e
6
7CMD_PREFIX=""
8BENCHMARK_CMD="app-startup-benchmark.sh"
9
10
11usage() {
12 cat <<EOF
13usage: $0 -a APP [-s ANDROID_SERIAL] [-Q] [-t TIMEOUT]
14
15Benchmark the startup of APP
16
17OPTIONS:
18 -h Show this message
19 -s Specify the serial of the device to install
20 -a The name of the application to start
21 -Q "Quick" don't do a reboot of the device before running the test
22 -t Time to wait for application startup (Default is 60)
23 -r Number of times to repeat (Default is 1)
24
25EOF
26}
27
28PIDS=""
29
30cleanup() {
31 set +e
32 echo "killing child pids: $PIDS"
33 for p in $PIDS ; do
34 kill $p
35 done
36}
37
38main() {
39 PIDS=""
40
41 set -x
42 if [ -z $QUICK ] ; then
43 reboot-and-unlock.sh
44 adb-shell ${CMD_PREFIX} initctl stop unity8-dash
45 adb shell powerd-cli active &
46 PIDS="$PIDS $!"
47 adb shell powerd-cli display on &
48 PIDS="$PIDS $!"
49 sleep 5
50 else
51 echo "SKIPPING phone reboot..."
52 fi
53
54 echo "launching benchmark...."
55 [ -z $ANDROID_SERIAL ] || ADBOPTS="-s $ANDROID_SERIAL"
56 adb-shell ${CMD_PREFIX} ${BENCHMARK_CMD} $APP $TIMEOUT
57
58 cleanup
59}
60
61export REPEAT=1
62
63while getopts p:s:a:Qt:r:h opt; do
64 case $opt in
65 h)
66 usage
67 exit 0
68 ;;
69 s)
70 export ANDROID_SERIAL=$OPTARG
71 ;;
72 a)
73 APP=$OPTARG
74 ;;
75 Q)
76 QUICK=1
77 ;;
78 t)
79 export TIMEOUT=$OPTARG
80 ;;
81 r)
82 export REPEAT=$OPTARG
83 ;;
84 esac
85done
86
87if [ -z $ANDROID_SERIAL ] ; then
88 # ensure we only have one device attached
89 lines=$(adb devices | wc -l)
90 if [ $lines -gt 3 ] ; then
91 echo "ERROR: More than one device attached, please use -s option"
92 echo
93 usage
94 exit 1
95 fi
96fi
97if [ -z $APP ] ; then
98 echo "ERROR: No app specified"
99 usage
100 exit 1
101fi
102
103trap cleanup TERM INT EXIT
104
105for X in $(seq $REPEAT) ; do
106 main
107done
0108
=== added file 'tests/app-startup-benchmark/blacklist'
--- tests/app-startup-benchmark/blacklist 1970-01-01 00:00:00 +0000
+++ tests/app-startup-benchmark/blacklist 2014-11-14 15:22:02 +0000
@@ -0,0 +1,3 @@
1com.canonical.payui
2com.ubuntu.reminders
3com.ubuntu.scopes.youtube
04
=== added file 'tests/app-startup-benchmark/master.run'
--- tests/app-startup-benchmark/master.run 1970-01-01 00:00:00 +0000
+++ tests/app-startup-benchmark/master.run 2014-11-14 15:22:02 +0000
@@ -0,0 +1,5 @@
1---
2testsuites:
3 - name: app-startup-benchmark
4 fetch_method: dev
5 fetch_location: ./
06
=== added file 'tests/app-startup-benchmark/setup.sh'
--- tests/app-startup-benchmark/setup.sh 1970-01-01 00:00:00 +0000
+++ tests/app-startup-benchmark/setup.sh 2014-11-14 15:22:02 +0000
@@ -0,0 +1,23 @@
1#!/bin/sh
2
3set -ex
4
5echo "Installing LTTng"
6adb-shell "sudo apt-get install -yq lttng-modules-dkms lttng-tools"
7
8echo "Removing old traces"
9adb-shell "rm -rf /home/phablet/lttng-traces"
10
11echo "Allowing LTTng events from confined applications"
12adb-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-*"
13
14echo "Regenerating AppArmor profiles for installed click applications"
15adb-shell "sudo aa-clickhook -f"
16
17echo "Setting environment variables for session"
18adb-shell "mkdir -p /home/phablet/.config/upstart"
19adb-shell "echo \"start on starting dbus\" > /home/phablet/.config/upstart/lttng-trace.conf"
20adb-shell "echo \"script\" >> /home/phablet/.config/upstart/lttng-trace.conf"
21adb-shell "echo \"initctl set-env --global LTTNG_UST_REGISTER_TIMEOUT=-1\" >> /home/phablet/.config/upstart/lttng-trace.conf"
22adb-shell "echo \"initctl set-env --global UBUNTU_APP_LAUNCH_LTTNG_ENABLED=TRUE\" >> /home/phablet/.config/upstart/lttng-trace.conf"
23adb-shell "echo \"end script\" >> /home/phablet/.config/upstart/lttng-trace.conf"
024
=== added file 'tests/app-startup-benchmark/ts_control'
--- tests/app-startup-benchmark/ts_control 1970-01-01 00:00:00 +0000
+++ tests/app-startup-benchmark/ts_control 2014-11-14 15:22:02 +0000
@@ -0,0 +1,1 @@
1ts_setup: ./setup.sh
02
=== added file 'tests/app-startup-benchmark/tslist.auto'
--- tests/app-startup-benchmark/tslist.auto 1970-01-01 00:00:00 +0000
+++ tests/app-startup-benchmark/tslist.auto 2014-11-14 15:22:02 +0000
@@ -0,0 +1,4 @@
1-
2 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
3 test_cmd: ../app-startup.sh -a {} -r 10 -t 10
4
05
=== added file 'tests/app-startup-benchmark/whitelist'
=== added file 'utils/target/app-startup-benchmark.sh'
--- utils/target/app-startup-benchmark.sh 1970-01-01 00:00:00 +0000
+++ utils/target/app-startup-benchmark.sh 2014-11-14 15:22:02 +0000
@@ -0,0 +1,35 @@
1#!/bin/bash
2
3set -x
4
5echo "Setting environment variables for tracing"
6export LTTNG_UST_REGISTER_TIMEOUT=-1
7export UBUNTU_APP_LAUNCH_LTTNG_ENABLED=TRUE
8
9echo "Creating dummy session without -e to get around first run error"
10lttng create dummy
11lttng destroy dummy
12
13set -e
14
15if [ -z ${1} ]
16then
17 echo "Usage:" >&2
18 echo "$0 APP [TIMEOUT]" >&2
19 exit 1
20fi
21
22PACKAGE=${1}
23APP_ID=$(ubuntu-app-triplet ${PACKAGE})
24
25DIR=$(lttng create ${PACKAGE}-startup | grep "Traces will be written in" | awk '{print $NF}')
26
27lttng enable-event -u -a
28lttng start
29
30ubuntu-app-launch ${APP_ID}
31
32sleep ${2-30}
33lttng stop
34lttng destroy ${PACKAGE}-startup
35echo $APP_ID > $DIR/app_id

Subscribers

People subscribed via source and target branches