1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/bin/sh
# Ubuntu CI Engine
# Copyright 2014 Canonical Ltd.
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License version 3, as
# published by the Free Software Foundation.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# REQUIRES: python-pip python-virtualenv python-setuptools python-dev
export CI_DEPS_BRANCH="lp:~canonical-ci-engineering/ubuntu-ci-services-itself/deps"
set -e
if [ -z $1 ] ; then
# Create a temporary venv
venv=$(mktemp -d)
trap "echo cleaning up venv...; rm -rf $venv" EXIT
virtualenv $venv
else
# Use the provided one
venv=$1
fi
# Activate the venv for the tests duration
. $venv/bin/activate
# ci-utils comes first as it's common to several components and should be
# setup first
SERVICES='
ci-utils
branch-source-builder
cli
image-builder
lander
ppa-assigner
ticket_system
test_runner
'
FAILURES=0
for x in $SERVICES ; do
echo "== Testing $x ...."
./$x/setup.py develop
if ! ./$x/setup.py test ; then
FAILURES=$(( ${FAILURES} + 1 ))
fi
done
GLUE_TESTS='
./juju-deployer/update.py --assert-pinned
./juju-deployer/test_update.py
./juju-deployer/test_deploy.py
./tests/test_run.py
'
# Do not want to parse newlines as the internal field separator. It would break
# any test with arguments.
SAVE="$IFS"
IFS='
'
for test_command in $GLUE_TESTS; do
echo "== Testing $test_command ...."
# test_deploy needs user set, but its presence shouldn't hurt the other
# tests.
# Use eval, as $test_command may have arguments.
if ! USER=foo eval "$test_command" ; then
echo FAILED
FAILURES=$(( ${FAILURES} + 1 ))
fi
done
IFS="$SAVE"
# If any test failed, fail the whole script
if [ "$FAILURES" != "0" ] ; then
# We can't get the number of *tests* that failed, only the number of
# runs
echo "Number of test suite failures: $FAILURES"
fi
exit $FAILURES
|