Merge lp:~sil2100/otto/autopilot_add_setup_upstart_job into lp:otto

Proposed by Łukasz Zemczak
Status: Superseded
Proposed branch: lp:~sil2100/otto/autopilot_add_setup_upstart_job
Merge into: lp:otto
Diff against target: 368 lines (+314/-0)
8 files modified
config (+2/-0)
hooks/setup (+24/-0)
packages/saucy/proposed.repo (+1/-0)
target-override/etc/init/otto-autopilot-setup.conf (+15/-0)
target-override/etc/xdg/autostart/autopilot.desktop (+9/-0)
target-override/usr/local/bin/capture_procstat (+112/-0)
target-override/usr/local/bin/psd (+42/-0)
target-override/usr/local/bin/run-autopilot.sh (+109/-0)
To merge this branch: bzr merge lp:~sil2100/otto/autopilot_add_setup_upstart_job
Reviewer Review Type Date Requested Status
Otto Developers Pending
Review via email: mp+171074@code.launchpad.net

Commit message

Add the otto-autopilot-setup.conf upstart job for configuring autopilot users correctly

Description of the change

Add the otto-autopilot-setup.conf upstart job for configuring autopilot users correctly. It seems that python-autopilot prepares the autopilot group, but it only adds the currently logged in user (we don't have that). So, to fix permissions, we need to add ubuntu to autopilot automatically. Otherwise, /dev/uinput is inaccessible.

To post a comment you must log in.
39. By Łukasz Zemczak

Remove unnecessary elements

40. By Łukasz Zemczak

Add a check for existence of autopilot and ubuntu

41. By Łukasz Zemczak

Final improvements (I hope)

Unmerged revisions

41. By Łukasz Zemczak

Final improvements (I hope)

40. By Łukasz Zemczak

Add a check for existence of autopilot and ubuntu

39. By Łukasz Zemczak

Remove unnecessary elements

38. By Łukasz Zemczak

Add the otto-autopilot-setup.conf upstart job for configuring autopilot users correctly

37. By Jean-Baptiste Lallement

Use basename instead of full path for lockfile name

36. By Didier Roche-Tolomelli

add saucy-proposed only to saucy

35. By Jean-Baptiste Lallement

Enabled proposed for saucy

34. By Jean-Baptiste Lallement

* capture_procstat:
  - Kill subprocess on exit
  - Do not run multiple instances
* run-autopilot.sh:
  - Capture memory usage

33. By Jean-Baptiste Lallement

Added script to capture ps periodically

32. By Didier Roche-Tolomelli

ok, let's record now on intel and ati

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'config'
2--- config 1970-01-01 00:00:00 +0000
3+++ config 2013-06-24 12:57:44 +0000
4@@ -0,0 +1,2 @@
5+LOGFILES="/var/log/syslog /home/ubuntu/.xsession-errors /home/ubuntu/.cache/upstart/gnome-session.log /var/local/autopilot/autopilot.log"
6+ARTIFACTS="/var/local/autopilot /var/crash"
7
8=== added directory 'hooks'
9=== added file 'hooks/setup'
10--- hooks/setup 1970-01-01 00:00:00 +0000
11+++ hooks/setup 2013-06-24 12:57:44 +0000
12@@ -0,0 +1,24 @@
13+#!/bin/sh -eu
14+#
15+# Customize the test tree _before_ the container starts and the
16+# testsuite directory is copied to $rootfs
17+echo "I: Executing $0"
18+
19+if [ $# -eq 0 ]; then
20+ echo "W: Testsuite path not found. Setup skipped!"
21+ exit 0
22+fi
23+
24+TESTPATH=$1
25+
26+if [ ! -d "$TESTPATH" ]; then
27+ echo "W: Testsuite path '$TESTPATH' not found. Setup skipped!"
28+ exit 0
29+fi
30+
31+TESTSUITES=$TESTPATH/target-override/var/local/autopilot/testsuites
32+mkdir -p $(dirname $TESTSUITES)
33+# $TESTS is passed in the environment
34+TESTS="${TESTS:-}"
35+echo "$TESTS" > $TESTSUITES
36+
37
38=== added directory 'packages'
39=== added directory 'packages/saucy'
40=== added file 'packages/saucy/proposed.repo'
41--- packages/saucy/proposed.repo 1970-01-01 00:00:00 +0000
42+++ packages/saucy/proposed.repo 2013-06-24 12:57:44 +0000
43@@ -0,0 +1,1 @@
44+deb http://archive.ubuntu.com/ubuntu/ saucy-proposed main universe restricted multiverse
45
46=== added directory 'target-override'
47=== added directory 'target-override/etc'
48=== added directory 'target-override/etc/init'
49=== added file 'target-override/etc/init/otto-autopilot-setup.conf'
50--- target-override/etc/init/otto-autopilot-setup.conf 1970-01-01 00:00:00 +0000
51+++ target-override/etc/init/otto-autopilot-setup.conf 2013-06-24 12:57:44 +0000
52@@ -0,0 +1,15 @@
53+description "Setup evnivonment specific to the autopilot jobs for otto"
54+author "Łukasz 'sil2100' Zemczak <lukasz.zemczak@canonical.com>"
55+
56+start on starting lightdm
57+
58+env DEBIAN_FRONTEND=noninteractive
59+
60+pre-start script
61+ # Add the ubuntu user to the autopilot group, as only the autopilot group
62+ # has the required permissions to access /dev/uinput
63+ echo "Adding the ubuntu user to the autopilot group"
64+ usermod -a -G autopilot ubuntu
65+
66+ exit_job 0
67+end script
68
69=== added directory 'target-override/etc/xdg'
70=== added directory 'target-override/etc/xdg/autostart'
71=== added file 'target-override/etc/xdg/autostart/autopilot.desktop'
72--- target-override/etc/xdg/autostart/autopilot.desktop 1970-01-01 00:00:00 +0000
73+++ target-override/etc/xdg/autostart/autopilot.desktop 2013-06-24 12:57:44 +0000
74@@ -0,0 +1,9 @@
75+[Desktop Entry]
76+Encoding=UTF-8
77+Name=Fire-up Autopilot tests
78+Comment=Starts the Autopilot tests
79+Exec=/usr/local/bin/run-autopilot.sh
80+Terminal=false
81+Type=Application
82+Categories=
83+X-GNOME-Autostart-Delay=20
84
85=== added directory 'target-override/usr'
86=== added directory 'target-override/usr/local'
87=== added directory 'target-override/usr/local/bin'
88=== added file 'target-override/usr/local/bin/capture_procstat'
89--- target-override/usr/local/bin/capture_procstat 1970-01-01 00:00:00 +0000
90+++ target-override/usr/local/bin/capture_procstat 2013-06-24 12:57:44 +0000
91@@ -0,0 +1,112 @@
92+#!/bin/sh -e
93+
94+#
95+# This script sends a signal to psd periodically to capture ps data
96+#
97+
98+# Copyright © 2013 Canonical Ltd.
99+# Author: Jean-baptiste Lallement <jean-baptiste.lallement@canonical.com>
100+#
101+# This program is free software; you can redistribute it and/or modify
102+# it under the terms of the GNU General Public License version 2, as
103+# published by the Free Software Foundation.
104+
105+# This program is distributed in the hope that it will be useful,
106+# but WITHOUT ANY WARRANTY; without even the implied warranty of
107+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108+# GNU General Public License for more details.
109+
110+# You should have received a copy of the GNU General Public License along
111+# with this program; if not, write to the Free Software Foundation, Inc.,
112+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
113+#
114+
115+COUNT=-1
116+INTERVAL=1
117+DATAFILE=""
118+COLLECTEXE=$(dirname $(readlink -f $0))/psd
119+
120+if [ ! -x $COLLECTEXE ]; then
121+ echo "E: File not found: $COLLECTEXE. Exiting!"
122+ exit 1
123+fi
124+
125+# Do not run multiple instances
126+lockfilename="/var/lock/$(basename $0)"
127+if [ -z "$FLOCK_SET" ] ; then
128+ exec env FLOCK_SET=1 flock -n "${lockfilename}" "$0" "$@"
129+fi
130+
131+usage() {
132+ cat<<EOF
133+Usage: $(basename $0) [options] [interval [count]]
134+Collect information about processes and memory on a sampling period of length
135+interval and count samples.
136+If count is not specified, default is infinite.
137+Default interval is ${INTERVAL}s .
138+
139+Options:
140+ -h|--help This help
141+ -d|--debug Enable debug mode
142+ -o|--output filename
143+ Output file (default stdout)
144+EOF
145+ exit 1
146+}
147+
148+on_exit() {
149+ if [ -f "$TMPDATAFILE" ]; then
150+ if [ -n "$DATAFILE" ]; then
151+ mv $TMPDATAFILE $DATAFILE
152+ echo "I: Finished. Data stored in $DATAFILE"
153+ else
154+ cat $TMPDATAFILE
155+ rm $TMPDATAFILE
156+ fi
157+ fi
158+ kill -9 $CPID >/dev/null 2>&1||true
159+ exit 0
160+}
161+
162+SOPTS="hdc:n:o:"
163+LOPTS="help,debug,count:,interval:,output:"
164+TEMP=$(getopt -o $SOPTS --long $LOPTS -- "$@")
165+eval set -- "$TEMP"
166+
167+while true ; do
168+ case "$1" in
169+ -h|--help)
170+ usage;;
171+ -d|--debug)
172+ set -x
173+ shift;;
174+ -o|--output)
175+ DATAFILE=$2
176+ shift 2;;
177+ --) shift ; break ;;
178+ *) usage;;
179+ esac
180+done
181+
182+[ $# -gt 0 ] && INTERVAL=$1 && shift
183+[ $# -gt 0 ] && COUNT=$1 && shift
184+
185+trap on_exit EXIT INT QUIT ABRT PIPE TERM
186+
187+TMPDATAFILE=$(mktemp /tmp/$(basename $0).XXXXXX)
188+[ -n "$DATAFILE" ] && mkdir -p $(dirname $DATAFILE)
189+
190+if [ $COUNT -ge 0 ];then
191+ MSGCNT="$COUNT samples"
192+else
193+ MSGCNT="samples until interrupted"
194+fi
195+echo "I: Capturing $MSGCNT with a sampling rate of ${INTERVAL}s"
196+$COLLECTEXE $TMPDATAFILE&
197+CPID=$!
198+sleep .5
199+while [ $COUNT -ne 0 ]; do
200+ kill -10 $CPID
201+ [ $COUNT -gt 0 ] && COUNT=$((COUNT - 1))
202+ sleep $INTERVAL
203+done
204
205=== added file 'target-override/usr/local/bin/psd'
206--- target-override/usr/local/bin/psd 1970-01-01 00:00:00 +0000
207+++ target-override/usr/local/bin/psd 2013-06-24 12:57:44 +0000
208@@ -0,0 +1,42 @@
209+#!/bin/sh
210+
211+#
212+# This script dumps ps data on SIGUSR1
213+#
214+
215+# Copyright © 2013 Canonical Ltd.
216+# Author: Jean-baptiste Lallement <jean-baptiste.lallement@canonical.com>
217+#
218+# This program is free software; you can redistribute it and/or modify
219+# it under the terms of the GNU General Public License version 2, as
220+# published by the Free Software Foundation.
221+
222+# This program is distributed in the hope that it will be useful,
223+# but WITHOUT ANY WARRANTY; without even the implied warranty of
224+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
225+# GNU General Public License for more details.
226+
227+# You should have received a copy of the GNU General Public License along
228+# with this program; if not, write to the Free Software Foundation, Inc.,
229+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
230+#
231+
232+DATAFILE=$1
233+rm -f $DATAFILE
234+
235+PSOPTS="-e --no-headers -ww"
236+PSFIELDS="uid,pid,ppid,pgid,stat,rss,vsz,cputime,etimes,cmd"
237+PSSORTBY="+pgid,ppid,pid"
238+
239+[ -n "$PSFIELDS" ] && PSOPTS="$PSOPTS -o $PSFIELDS"
240+[ -n "$PSSORTBY" ] && PSOPTS="$PSOPTS --sort $PSSORTBY"
241+
242+capture() {
243+ echo "TS:$(date +%s.%N)">>$DATAFILE
244+ ps $PSOPTS >>$DATAFILE
245+}
246+trap capture USR1
247+
248+while :; do
249+ sleep .1
250+done
251
252=== added file 'target-override/usr/local/bin/run-autopilot.sh'
253--- target-override/usr/local/bin/run-autopilot.sh 1970-01-01 00:00:00 +0000
254+++ target-override/usr/local/bin/run-autopilot.sh 2013-06-24 12:57:44 +0000
255@@ -0,0 +1,109 @@
256+#!/bin/sh -eu
257+
258+#
259+# This script runs autopilot
260+#
261+
262+# Copyright © 2013 Canonical Ltd.
263+# Author: Jean-baptiste Lallement <jean-baptiste.lallement@canonical.com>
264+#
265+# This program is free software; you can redistribute it and/or modify
266+# it under the terms of the GNU General Public License version 2, as
267+# published by the Free Software Foundation.
268+
269+# This program is distributed in the hope that it will be useful,
270+# but WITHOUT ANY WARRANTY; without even the implied warranty of
271+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
272+# GNU General Public License for more details.
273+
274+# You should have received a copy of the GNU General Public License along
275+# with this program; if not, write to the Free Software Foundation, Inc.,
276+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
277+#
278+
279+# Required to display stdout in ~/.xsession-error
280+
281+TESTBASE=/var/local/autopilot/
282+AP_ARTIFACTS=$TESTBASE/videos/
283+AP_RESULTS=$TESTBASE/junit/
284+AP_TESTSUITES=$TESTBASE/testsuites
285+AP_LOGFILE=$TESTBASE/autopilot.log
286+SPOOLDIR=$TESTBASE/spool
287+AP_OPTS="-v -r -rd $AP_ARTIFACTS -f xml"
288+# TESTING ONLY -- REcording is disabled
289+#AP_OPTS="-v -f xml"
290+OTTO_SUMMARY=/var/local/otto/summary.log
291+MEMUSAGE_CMD=/usr/local/bin/capture_procstat
292+
293+# Define general configuration files
294+[ -f $TESTBASE/config ] && . $TESTBASE/config
295+
296+setup_tests() {
297+ # Prepares the environment for the tests
298+ flag=$HOME/.ap_setup_done
299+
300+ [ -e "$flag" ] && return 0
301+
302+ # Disable notifications and screensaver
303+ gsettings set com.ubuntu.update-notifier show-apport-crashes false
304+ gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
305+
306+ # Loads the list of test and queue them in test spool
307+ sudo mkdir -p $SPOOLDIR $AP_ARTIFACTS $AP_RESULTS $(dirname $OTTO_SUMMARY)
308+ sudo chown -R $USER:$USER $TESTBASE $SPOOLDIR $AP_ARTIFACTS $AP_RESULTS $(dirname $OTTO_SUMMARY)
309+
310+ if [ -e "$AP_TESTSUITES" ]; then
311+ (cd $SPOOLDIR; touch $(cat $AP_TESTSUITES))
312+ fi
313+ touch $flag
314+}
315+
316+run_tests() {
317+ # Runs all the tests in spooldir
318+ #
319+ # $1: Spool directory
320+ spooldir=$1
321+ if [ ! -d $spooldir ]; then
322+ echo "E: '$spooldir is not a directory. Exiting!"
323+ exit 1
324+ fi
325+
326+ if ! which autopilot >/dev/null 2>&1; then
327+ echo "E: autopilot is required to run autopilot tests"
328+ echo "autopilot_installed (see autopilot.log for details): ERROR" >> $OTTO_SUMMARY
329+ sudo shutdown -h now
330+ exit 1
331+ fi
332+ echo "autopilot_installed: PASS" >> $OTTO_SUMMARY
333+
334+ exec >>$AP_LOGFILE
335+ exec 2>&1
336+
337+ # Capture memusage
338+ $MEMUSAGE_CMD -o $TESTBASE/memusage.log 1 &
339+ [ $? -gt 0 ] && echo "W: Failed to start $MEMUSAGE_CMD ."
340+
341+ for testfile in $(ls -d $spooldir/* 2>/dev/null); do
342+ testname=$(basename $testfile)
343+ # We don't want to fail if AP fail but we want the return code
344+ set +e
345+ echo "I: Running autopilot run $testname $AP_OPTS -o $AP_RESULTS/$testname.xml"
346+ autopilot run $testname $AP_OPTS -o $AP_RESULTS/$testname.xml
347+ AP_RC=$?
348+ if [ $AP_RC -gt 0 ]; then
349+ echo "${testname}: FAIL" >> $OTTO_SUMMARY
350+ else
351+ echo "${testname}: DONE" >> $OTTO_SUMMARY
352+ fi
353+ set -e
354+ sudo rm -f $testfile
355+ done
356+
357+ if [ ! "$(ls -A $spooldir/)" ]; then
358+ echo "I: No test left to run"
359+ sudo shutdown -h now
360+ fi
361+}
362+
363+setup_tests
364+run_tests $SPOOLDIR
365
366=== added directory 'target-override/var'
367=== added directory 'target-override/var/lib'
368=== added directory 'target-override/var/lib/otto'

Subscribers

People subscribed via source and target branches