Merge lp:~doanac/ubuntu-test-cases/statsd into lp:ubuntu-test-cases/touch

Proposed by Andy Doan
Status: Merged
Merged at revision: 102
Proposed branch: lp:~doanac/ubuntu-test-cases/statsd
Merge into: lp:ubuntu-test-cases/touch
Diff against target: 182 lines (+94/-36)
5 files modified
jenkins/setup_jenkins.py (+1/-0)
jenkins/staging.py (+1/-0)
jenkins/templates/touch-smoke.xml.jinja2 (+1/-0)
scripts/run-smoke (+73/-36)
scripts/statsd-cli (+18/-0)
To merge this branch: bzr merge lp:~doanac/ubuntu-test-cases/statsd
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+192734@code.launchpad.net

Description of the change

Gets us the ability to send some statsd metrics the mega job in staging

To post a comment you must log in.
lp:~doanac/ubuntu-test-cases/statsd updated
98. By Paul Larson

Use bootstrap option on all images

99. By Andy Doan

change order of operations in provision.sh

100. By Andy Doan

increase timeout waiting for device in reboot-and-wait

We see places in automation where the phablet-network script
starts printing tons of:

  error: device not found

The wait-for-device is coming back too fast. ie - its not really ready
yet.

101. By Paul Larson

Modify whoopsie-upload-all in the images we provision so that whoopsie
gets restarted after .crash files are processed to work around a bug,
and use the new utah option to to force running whoopsie-upload-all
at the end of the job

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

Looks good, just need to remember to go back and add stats for production once it goes into play :)

review: Approve
lp:~doanac/ubuntu-test-cases/statsd updated
102. By Andy Doan

add statsd support for test-execution-service

Revision history for this message
Evan (ev) wrote :

Shouldn't STATSD_KEY only be set if {{statsd_key}} is set?

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

On 10/29/2013 03:25 PM, Evan Dandrea wrote:
> Shouldn't STATSD_KEY only be set if {{statsd_key}} is set?

setup_jenkins.py will set it to an empty string so "[ -z $STATSD_KEY ]"
should still evaluate properly for people's development setups.

Revision history for this message
Evan (ev) wrote :

Will it?

+export STATSD_KEY={{statsd_key}}.{{imagetype}}

That seems to imply that it will end up as STATSD_KEY=.{{imagetype}}

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

oh - so embarrassed and have no idea how this worked at home. must have forgotten to regenerate the job.

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

its fixed in trunk now.

Revision history for this message
Evan (ev) wrote :

:D

Excited for this.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'jenkins/setup_jenkins.py'
2--- jenkins/setup_jenkins.py 2013-10-24 18:41:16 +0000
3+++ jenkins/setup_jenkins.py 2013-10-25 18:22:20 +0000
4@@ -121,6 +121,7 @@
5 'trigger_url': device['trigger_url'],
6 'imagetype': config_item['image-type'],
7 'image_opt': config_item.get('IMAGE_OPT', ''),
8+ 'statsd_key': config_item.get('statsd-key', ''),
9 }
10 # a hack so we can use _get_job_name
11 test = testconfig.Test('', fmt='{prefix}{series}-{imagetype}-{type}')
12
13=== modified file 'jenkins/staging.py'
14--- jenkins/staging.py 2013-10-24 22:09:13 +0000
15+++ jenkins/staging.py 2013-10-25 18:22:20 +0000
16@@ -11,6 +11,7 @@
17 {
18 'image-type': 'touch',
19 'node-label': 'ashes',
20+ 'statsd-key': 'ubuntu-ci.test-execution-service.staging',
21 'devices': [
22 {
23 'name': 'mako-06 || mako-07 || mako-08',
24
25=== modified file 'jenkins/templates/touch-smoke.xml.jinja2'
26--- jenkins/templates/touch-smoke.xml.jinja2 2013-10-24 19:58:18 +0000
27+++ jenkins/templates/touch-smoke.xml.jinja2 2013-10-25 18:22:20 +0000
28@@ -83,6 +83,7 @@
29
30 export ANDROID_SERIAL={{serial}}
31 export IMAGE_TYPE={{imagetype}}
32+export STATSD_KEY={{statsd_key}}.{{imagetype}}
33
34 {{image_opt}}
35 ${BZRDIR}/scripts/run-smoke
36
37=== modified file 'scripts/run-smoke'
38--- scripts/run-smoke 2013-10-24 19:58:18 +0000
39+++ scripts/run-smoke 2013-10-25 18:22:20 +0000
40@@ -11,6 +11,7 @@
41 ## PACKAGES - debian packages to install
42 ## APPS - autopilot apps to run or ALL
43 ## TESTS - UTAH tests to run or ALL
44+## STATSD_KEY - If provided metrics will be sent to statsd with this prefix
45
46 set -e
47
48@@ -19,39 +20,75 @@
49 IMAGE_TYPE="${IMAGE_TYPE-touch}"
50 RESDIR="${RESDIR-$(pwd)/clientlogs}"
51
52-if [ -z $INSTALL_URL ] ; then
53- if [ "$PACKAGES" = "ALL" ] ; then
54- PACKAGES="$(${BASEDIR}/jenkins/testconfig.py packages -i $IMAGE_TYPE)"
55- fi
56-
57- custom_args=""
58- set +x
59- for p in $PACKAGES ; do
60- custom_args="$custom_args -p $p"
61- done
62- for p in $PPAS ; do
63- custom_args="$custom_args -P $p"
64- done
65- set -x
66- ${BASEDIR}/scripts/provision.sh -i ${IMAGE_TYPE} $custom_args
67-else
68- ${BASEDIR}/scripts/assert-image
69-fi
70-
71-if [ "$APPS" = "ALL" ] ; then
72- APPS="$(${BASEDIR}/jenkins/testconfig.py apps -i $IMAGE_TYPE)"
73-fi
74-
75-rc=0
76-
77-[ -z "$APPS" ] || APPS=${APPS} ${BASEDIR}/scripts/run-autopilot-tests.sh || rc=1
78-
79-if [ "$TESTS" = "ALL" ] ; then
80- TESTS="$(${BASEDIR}/jenkins/testconfig.py utah -i $IMAGE_TYPE)"
81-fi
82-
83-for test in $TESTS ; do
84- echo == testing $test =======================================================
85- RESDIR=${RESDIR}/$test ${BASEDIR}/scripts/jenkins.sh -a $test || rc=1
86-done
87-exit $rc
88+add_stat() {
89+ [ -z $STATSD_KEY ] || ${BASEDIR}/scripts/statsd-cli "${STATSD_KEY}.$1:$2|$3"
90+}
91+
92+timeit() {
93+ rc=0
94+ start=$(date +%s.%N)
95+ $* || rc=1
96+ end=$(date +%s.%N)
97+ diff=$(echo "($end - $start) * 1000" | bc)
98+ add_stat $1 $diff ms
99+ return $rc
100+}
101+
102+gaugeit() {
103+ val=$(eval "echo \$$1" | wc -w)
104+ add_stat $1 $val g
105+}
106+
107+provision() {
108+ if [ -z $INSTALL_URL ] ; then
109+ if [ "$PACKAGES" = "ALL" ] ; then
110+ PACKAGES="$(${BASEDIR}/jenkins/testconfig.py packages -i $IMAGE_TYPE)"
111+ fi
112+
113+ custom_args=""
114+ set +x
115+ gaugeit PACKAGES
116+ for p in $PACKAGES ; do
117+ custom_args="$custom_args -p $p"
118+ done
119+ for p in $PPAS ; do
120+ custom_args="$custom_args -P $p"
121+ done
122+ set -x
123+ ${BASEDIR}/scripts/provision.sh -i ${IMAGE_TYPE} $custom_args
124+ else
125+ ${BASEDIR}/scripts/assert-image
126+ fi
127+}
128+
129+test_autopilot() {
130+ if [ "$APPS" = "ALL" ] ; then
131+ APPS="$(${BASEDIR}/jenkins/testconfig.py apps -i $IMAGE_TYPE)"
132+ fi
133+ gaugeit APPS
134+ [ -z "$APPS" ] || APPS=${APPS} ${BASEDIR}/scripts/run-autopilot-tests.sh || return 1
135+}
136+
137+test_utah() {
138+ if [ "$TESTS" = "ALL" ] ; then
139+ TESTS="$(${BASEDIR}/jenkins/testconfig.py utah -i $IMAGE_TYPE)"
140+ fi
141+ gaugeit TESTS
142+
143+ rc=0
144+ for test in $TESTS ; do
145+ echo == testing $test =======================================================
146+ RESDIR=${RESDIR}/$test ${BASEDIR}/scripts/jenkins.sh -a $test || rc=1
147+ done
148+ return $rc
149+}
150+
151+main() {
152+ rc=0
153+ timeit provision
154+ timeit test_autopilot || rc=1
155+ timeit test_utah || rc=1
156+ return $rc
157+}
158+
159+timeit main
160
161=== added file 'scripts/statsd-cli'
162--- scripts/statsd-cli 1970-01-01 00:00:00 +0000
163+++ scripts/statsd-cli 2013-10-25 18:22:20 +0000
164@@ -0,0 +1,18 @@
165+#!/bin/bash
166+
167+set -e
168+
169+SERVER=${SERVER-"snakefruit.canonical.com"}
170+PORT=${PORT-"10041"}
171+
172+send_msg() {
173+ exec 3<>/dev/udp/$SERVER/$PORT
174+
175+ echo $* >&3
176+
177+ exec 3<&-
178+ exec 3>&-
179+}
180+
181+[ $# -gt 0 ] || (echo "Must provide statsd formatted string" && exit 1)
182+send_msg $*

Subscribers

People subscribed via source and target branches