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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#!/bin/bash -eu
#
# Runs an otto job with otto-run. This script must be integrated as part of a
# jenkins build step
#
show_dl_addr() {
# Display the address to download the container used to run this test
#
# $1: Name of the container
#
if [ $# -eq 0 ]; then
echo "E: Missing argument: <name of container>"
return 1
fi
name="$1"
ifdev=$(ip addr show |awk '$1 == "inet" && $3 == "brd" { print $7; exit 0; }')
ipaddr=$(ip addr show dev $ifdev |awk '$1 == "inet" && $3 == "brd" { sub (/\/.*/,""); print $2 }')
if ! nc -z $ipaddr 80; then
echo "W: No http server running on this host"
return 0
fi
containeruri="http://$ipaddr/otto/$name"
cat <<EOF
______________________________________________________________________________
I: Archive of the container to run this test available for download from:
$containeruri
______________________________________________________________________________
EOF
}
print_usage() {
cat <<EOF
usage $0 [-l LOCALDIR | -b BRANCH]
Run otto using either:
-l LOCALDIR Local folder containing the overrides etc.
-b BRANCH Bzr branch containing the overrides etc. to export and use.
EOF
}
if [ $# -eq "0" ]; then
echo "Arguments needed"
print_usage
exit 1
fi
while getopts "b:l:s:h" option
do
case "${option}" in
b) TS_BRANCH=${OPTARG};;
l) TS_EXPORT=${OPTARG};;
s) series=${OPTARG};;
h | *)
print_usage
exit 0
;;
esac
done
# default series.
if [ -z "${series-}" ]; then
series="saucy"
fi
ARCH=$(dpkg --print-architecture )
# Find newest container
CONTAINER=$(sudo lxc-ls "${series}-${ARCH}-*" | tail -1)
if [ -z "$CONTAINER" ] ; then
echo "E: couldn't find containers matching '${series}-${ARCH}-*'".
echo "E: Containers available on this system:"
sudo lxc-ls -1
exit 1
fi
# Only need to export the branch if is doesn't already exist.
if [ -z ${TS_EXPORT} ]; then
# Usual workspace as we're exporting the target branch (otherwise this
# should be handled by the calling script.)
rm -Rf "$WORKSPACE"/*
# Location of the testsuite on LP and locally
TS_BRANCH="${TS_BRANCH:-lp:~otto-dev/otto/testsuite_autopilot-unity}"
TS_EXPORT="$WORKSPACE/testsuite"
# Export the testsuite
bzr export $TS_EXPORT $TS_BRANCH
fi
# Set environment for Otto and match with parameters from Jenkins
ppa="${ppa:-}"
[ -n "$ppa" ] && export TESTREPOS="ppa:$ppa"
export TESTPKGS="${testpackages:-}"
export TESTPKGSSTRICT="${packages:-}"
export TESTS="${tests:-}"
export RESULTSDIR="${WORKSPACE}/results"
# NOTE: Run otto-run with -E to preserve the environment
sudo -E $HOME/bin/otto-run $CONTAINER $TS_EXPORT || echo "E: otto-run exited with status $?"
set +e
show_dl_addr $CONTAINER
set -e
|