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
=== added file 'config'
--- config 1970-01-01 00:00:00 +0000
+++ config 2013-06-24 12:57:44 +0000
@@ -0,0 +1,2 @@
1LOGFILES="/var/log/syslog /home/ubuntu/.xsession-errors /home/ubuntu/.cache/upstart/gnome-session.log /var/local/autopilot/autopilot.log"
2ARTIFACTS="/var/local/autopilot /var/crash"
03
=== added directory 'hooks'
=== added file 'hooks/setup'
--- hooks/setup 1970-01-01 00:00:00 +0000
+++ hooks/setup 2013-06-24 12:57:44 +0000
@@ -0,0 +1,24 @@
1#!/bin/sh -eu
2#
3# Customize the test tree _before_ the container starts and the
4# testsuite directory is copied to $rootfs
5echo "I: Executing $0"
6
7if [ $# -eq 0 ]; then
8 echo "W: Testsuite path not found. Setup skipped!"
9 exit 0
10fi
11
12TESTPATH=$1
13
14if [ ! -d "$TESTPATH" ]; then
15 echo "W: Testsuite path '$TESTPATH' not found. Setup skipped!"
16 exit 0
17fi
18
19TESTSUITES=$TESTPATH/target-override/var/local/autopilot/testsuites
20mkdir -p $(dirname $TESTSUITES)
21# $TESTS is passed in the environment
22TESTS="${TESTS:-}"
23echo "$TESTS" > $TESTSUITES
24
025
=== added directory 'packages'
=== added directory 'packages/saucy'
=== added file 'packages/saucy/proposed.repo'
--- packages/saucy/proposed.repo 1970-01-01 00:00:00 +0000
+++ packages/saucy/proposed.repo 2013-06-24 12:57:44 +0000
@@ -0,0 +1,1 @@
1deb http://archive.ubuntu.com/ubuntu/ saucy-proposed main universe restricted multiverse
02
=== added directory 'target-override'
=== added directory 'target-override/etc'
=== added directory 'target-override/etc/init'
=== added file 'target-override/etc/init/otto-autopilot-setup.conf'
--- target-override/etc/init/otto-autopilot-setup.conf 1970-01-01 00:00:00 +0000
+++ target-override/etc/init/otto-autopilot-setup.conf 2013-06-24 12:57:44 +0000
@@ -0,0 +1,15 @@
1description "Setup evnivonment specific to the autopilot jobs for otto"
2author "Łukasz 'sil2100' Zemczak <lukasz.zemczak@canonical.com>"
3
4start on starting lightdm
5
6env DEBIAN_FRONTEND=noninteractive
7
8pre-start script
9 # Add the ubuntu user to the autopilot group, as only the autopilot group
10 # has the required permissions to access /dev/uinput
11 echo "Adding the ubuntu user to the autopilot group"
12 usermod -a -G autopilot ubuntu
13
14 exit_job 0
15end script
016
=== added directory 'target-override/etc/xdg'
=== added directory 'target-override/etc/xdg/autostart'
=== added file 'target-override/etc/xdg/autostart/autopilot.desktop'
--- target-override/etc/xdg/autostart/autopilot.desktop 1970-01-01 00:00:00 +0000
+++ target-override/etc/xdg/autostart/autopilot.desktop 2013-06-24 12:57:44 +0000
@@ -0,0 +1,9 @@
1[Desktop Entry]
2Encoding=UTF-8
3Name=Fire-up Autopilot tests
4Comment=Starts the Autopilot tests
5Exec=/usr/local/bin/run-autopilot.sh
6Terminal=false
7Type=Application
8Categories=
9X-GNOME-Autostart-Delay=20
010
=== added directory 'target-override/usr'
=== added directory 'target-override/usr/local'
=== added directory 'target-override/usr/local/bin'
=== added file 'target-override/usr/local/bin/capture_procstat'
--- target-override/usr/local/bin/capture_procstat 1970-01-01 00:00:00 +0000
+++ target-override/usr/local/bin/capture_procstat 2013-06-24 12:57:44 +0000
@@ -0,0 +1,112 @@
1#!/bin/sh -e
2
3#
4# This script sends a signal to psd periodically to capture ps data
5#
6
7# Copyright © 2013 Canonical Ltd.
8# Author: Jean-baptiste Lallement <jean-baptiste.lallement@canonical.com>
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License version 2, as
12# published by the Free Software Foundation.
13
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18
19# You should have received a copy of the GNU General Public License along
20# with this program; if not, write to the Free Software Foundation, Inc.,
21# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22#
23
24COUNT=-1
25INTERVAL=1
26DATAFILE=""
27COLLECTEXE=$(dirname $(readlink -f $0))/psd
28
29if [ ! -x $COLLECTEXE ]; then
30 echo "E: File not found: $COLLECTEXE. Exiting!"
31 exit 1
32fi
33
34# Do not run multiple instances
35lockfilename="/var/lock/$(basename $0)"
36if [ -z "$FLOCK_SET" ] ; then
37 exec env FLOCK_SET=1 flock -n "${lockfilename}" "$0" "$@"
38fi
39
40usage() {
41 cat<<EOF
42Usage: $(basename $0) [options] [interval [count]]
43Collect information about processes and memory on a sampling period of length
44interval and count samples.
45If count is not specified, default is infinite.
46Default interval is ${INTERVAL}s .
47
48Options:
49 -h|--help This help
50 -d|--debug Enable debug mode
51 -o|--output filename
52 Output file (default stdout)
53EOF
54 exit 1
55}
56
57on_exit() {
58 if [ -f "$TMPDATAFILE" ]; then
59 if [ -n "$DATAFILE" ]; then
60 mv $TMPDATAFILE $DATAFILE
61 echo "I: Finished. Data stored in $DATAFILE"
62 else
63 cat $TMPDATAFILE
64 rm $TMPDATAFILE
65 fi
66 fi
67 kill -9 $CPID >/dev/null 2>&1||true
68 exit 0
69}
70
71SOPTS="hdc:n:o:"
72LOPTS="help,debug,count:,interval:,output:"
73TEMP=$(getopt -o $SOPTS --long $LOPTS -- "$@")
74eval set -- "$TEMP"
75
76while true ; do
77 case "$1" in
78 -h|--help)
79 usage;;
80 -d|--debug)
81 set -x
82 shift;;
83 -o|--output)
84 DATAFILE=$2
85 shift 2;;
86 --) shift ; break ;;
87 *) usage;;
88 esac
89done
90
91[ $# -gt 0 ] && INTERVAL=$1 && shift
92[ $# -gt 0 ] && COUNT=$1 && shift
93
94trap on_exit EXIT INT QUIT ABRT PIPE TERM
95
96TMPDATAFILE=$(mktemp /tmp/$(basename $0).XXXXXX)
97[ -n "$DATAFILE" ] && mkdir -p $(dirname $DATAFILE)
98
99if [ $COUNT -ge 0 ];then
100 MSGCNT="$COUNT samples"
101else
102 MSGCNT="samples until interrupted"
103fi
104echo "I: Capturing $MSGCNT with a sampling rate of ${INTERVAL}s"
105$COLLECTEXE $TMPDATAFILE&
106CPID=$!
107sleep .5
108while [ $COUNT -ne 0 ]; do
109 kill -10 $CPID
110 [ $COUNT -gt 0 ] && COUNT=$((COUNT - 1))
111 sleep $INTERVAL
112done
0113
=== added file 'target-override/usr/local/bin/psd'
--- target-override/usr/local/bin/psd 1970-01-01 00:00:00 +0000
+++ target-override/usr/local/bin/psd 2013-06-24 12:57:44 +0000
@@ -0,0 +1,42 @@
1#!/bin/sh
2
3#
4# This script dumps ps data on SIGUSR1
5#
6
7# Copyright © 2013 Canonical Ltd.
8# Author: Jean-baptiste Lallement <jean-baptiste.lallement@canonical.com>
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License version 2, as
12# published by the Free Software Foundation.
13
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18
19# You should have received a copy of the GNU General Public License along
20# with this program; if not, write to the Free Software Foundation, Inc.,
21# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22#
23
24DATAFILE=$1
25rm -f $DATAFILE
26
27PSOPTS="-e --no-headers -ww"
28PSFIELDS="uid,pid,ppid,pgid,stat,rss,vsz,cputime,etimes,cmd"
29PSSORTBY="+pgid,ppid,pid"
30
31[ -n "$PSFIELDS" ] && PSOPTS="$PSOPTS -o $PSFIELDS"
32[ -n "$PSSORTBY" ] && PSOPTS="$PSOPTS --sort $PSSORTBY"
33
34capture() {
35 echo "TS:$(date +%s.%N)">>$DATAFILE
36 ps $PSOPTS >>$DATAFILE
37}
38trap capture USR1
39
40while :; do
41 sleep .1
42done
043
=== added file 'target-override/usr/local/bin/run-autopilot.sh'
--- target-override/usr/local/bin/run-autopilot.sh 1970-01-01 00:00:00 +0000
+++ target-override/usr/local/bin/run-autopilot.sh 2013-06-24 12:57:44 +0000
@@ -0,0 +1,109 @@
1#!/bin/sh -eu
2
3#
4# This script runs autopilot
5#
6
7# Copyright © 2013 Canonical Ltd.
8# Author: Jean-baptiste Lallement <jean-baptiste.lallement@canonical.com>
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License version 2, as
12# published by the Free Software Foundation.
13
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18
19# You should have received a copy of the GNU General Public License along
20# with this program; if not, write to the Free Software Foundation, Inc.,
21# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22#
23
24# Required to display stdout in ~/.xsession-error
25
26TESTBASE=/var/local/autopilot/
27AP_ARTIFACTS=$TESTBASE/videos/
28AP_RESULTS=$TESTBASE/junit/
29AP_TESTSUITES=$TESTBASE/testsuites
30AP_LOGFILE=$TESTBASE/autopilot.log
31SPOOLDIR=$TESTBASE/spool
32AP_OPTS="-v -r -rd $AP_ARTIFACTS -f xml"
33# TESTING ONLY -- REcording is disabled
34#AP_OPTS="-v -f xml"
35OTTO_SUMMARY=/var/local/otto/summary.log
36MEMUSAGE_CMD=/usr/local/bin/capture_procstat
37
38# Define general configuration files
39[ -f $TESTBASE/config ] && . $TESTBASE/config
40
41setup_tests() {
42 # Prepares the environment for the tests
43 flag=$HOME/.ap_setup_done
44
45 [ -e "$flag" ] && return 0
46
47 # Disable notifications and screensaver
48 gsettings set com.ubuntu.update-notifier show-apport-crashes false
49 gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
50
51 # Loads the list of test and queue them in test spool
52 sudo mkdir -p $SPOOLDIR $AP_ARTIFACTS $AP_RESULTS $(dirname $OTTO_SUMMARY)
53 sudo chown -R $USER:$USER $TESTBASE $SPOOLDIR $AP_ARTIFACTS $AP_RESULTS $(dirname $OTTO_SUMMARY)
54
55 if [ -e "$AP_TESTSUITES" ]; then
56 (cd $SPOOLDIR; touch $(cat $AP_TESTSUITES))
57 fi
58 touch $flag
59}
60
61run_tests() {
62 # Runs all the tests in spooldir
63 #
64 # $1: Spool directory
65 spooldir=$1
66 if [ ! -d $spooldir ]; then
67 echo "E: '$spooldir is not a directory. Exiting!"
68 exit 1
69 fi
70
71 if ! which autopilot >/dev/null 2>&1; then
72 echo "E: autopilot is required to run autopilot tests"
73 echo "autopilot_installed (see autopilot.log for details): ERROR" >> $OTTO_SUMMARY
74 sudo shutdown -h now
75 exit 1
76 fi
77 echo "autopilot_installed: PASS" >> $OTTO_SUMMARY
78
79 exec >>$AP_LOGFILE
80 exec 2>&1
81
82 # Capture memusage
83 $MEMUSAGE_CMD -o $TESTBASE/memusage.log 1 &
84 [ $? -gt 0 ] && echo "W: Failed to start $MEMUSAGE_CMD ."
85
86 for testfile in $(ls -d $spooldir/* 2>/dev/null); do
87 testname=$(basename $testfile)
88 # We don't want to fail if AP fail but we want the return code
89 set +e
90 echo "I: Running autopilot run $testname $AP_OPTS -o $AP_RESULTS/$testname.xml"
91 autopilot run $testname $AP_OPTS -o $AP_RESULTS/$testname.xml
92 AP_RC=$?
93 if [ $AP_RC -gt 0 ]; then
94 echo "${testname}: FAIL" >> $OTTO_SUMMARY
95 else
96 echo "${testname}: DONE" >> $OTTO_SUMMARY
97 fi
98 set -e
99 sudo rm -f $testfile
100 done
101
102 if [ ! "$(ls -A $spooldir/)" ]; then
103 echo "I: No test left to run"
104 sudo shutdown -h now
105 fi
106}
107
108setup_tests
109run_tests $SPOOLDIR
0110
=== added directory 'target-override/var'
=== added directory 'target-override/var/lib'
=== added directory 'target-override/var/lib/otto'

Subscribers

People subscribed via source and target branches