~fginther/+junk/python2or3.2

« back to all changes in this revision

Viewing changes to run_otto_job

  • Committer: Christopher Lee
  • Date: 2013-09-01 23:25:42 UTC
  • Revision ID: chris.lee@canonical.com-20130901232542-equz6j9vxyhoqyw0
Initial Commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash -eu
 
2
 
 
3
#
 
4
# Runs an otto job with otto-run. This script must be integrated as part of a
 
5
# jenkins build step
 
6
#
 
7
# This script is part of the project Otto
 
8
#
 
9
 
 
10
# Copyright © 2013 Canonical Ltd.
 
11
# Author: Jean-baptiste Lallement <jean-baptiste.lallement@canonical.com>
 
12
#
 
13
# This program is free software; you can redistribute it and/or modify
 
14
# it under the terms of the GNU General Public License version 2, as
 
15
# published by the Free Software Foundation.
 
16
#
 
17
# This program is distributed in the hope that it will be useful,
 
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
# GNU General Public License for more details.
 
21
#
 
22
# You should have received a copy of the GNU General Public License along
 
23
# with this program; if not, write to the Free Software Foundation, Inc.,
 
24
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
25
 
 
26
# Usual workspace cleanup
 
27
rm -Rf "$WORKSPACE"/*
 
28
 
 
29
show_dl_addr() {
 
30
    # Display the address to download the container used to run this test
 
31
    #
 
32
    # $1: Name of the container
 
33
    #
 
34
    if [ $# -eq 0 ]; then
 
35
        echo "E: Missing argument: <name of container>"
 
36
        return 1
 
37
    fi
 
38
    name="$1"
 
39
    ifdev=$(ip addr show |awk '$1 == "inet" && $3 == "brd" { print $7; exit 0; }')
 
40
    ipaddr=$(ip addr show dev $ifdev |awk '$1 == "inet" && $3 == "brd" { sub (/\/.*/,""); print $2 }')
 
41
 
 
42
    if ! nc -z $ipaddr 80; then
 
43
        echo "W: No http server running on this host"
 
44
        return 0
 
45
    fi
 
46
 
 
47
    containeruri="http://$ipaddr/otto/$name"
 
48
    cat <<EOF
 
49
______________________________________________________________________________
 
50
 
 
51
I: Archive of the container to run this test available for download from:
 
52
    $containeruri
 
53
______________________________________________________________________________
 
54
EOF
 
55
}
 
56
 
 
57
# Location of the testsuite on LP and locally
 
58
TS_BRANCH="${TS_BRANCH:-lp:~otto-dev/otto/testsuite_autopilot-unity}"
 
59
TS_EXPORT="$WORKSPACE/testsuite"
 
60
 
 
61
ARCH=$(dpkg --print-architecture )
 
62
# Find newest container
 
63
CONTAINER=$(lxc-ls "${series}-${ARCH}-*" | tail -1)
 
64
 
 
65
if [ -z "$CONTAINER" ] ; then
 
66
    echo "E: couldn't find containers matching '${series}-${ARCH}-*'".
 
67
    echo "E: Containers available on this system:"
 
68
    lxc-ls -1
 
69
    exit 1
 
70
fi
 
71
 
 
72
# Export the testsuite
 
73
bzr export $TS_EXPORT $TS_BRANCH
 
74
 
 
75
# Set environment for Otto and match with parameters from Jenkins
 
76
ppa="${ppa:-}"
 
77
[ -n "$ppa" ] && export TESTREPOS="ppa:$ppa"
 
78
export TESTPKGS="${testpackages:-}"
 
79
export TESTPKGSSTRICT="${packages:-}"
 
80
export TESTS="${tests:-}"
 
81
export RESULTSDIR="${WORKSPACE}/results"
 
82
 
 
83
# NOTE: Run otto-run with -E to preserve the environment
 
84
sudo -E $HOME/bin/otto-run $CONTAINER $TS_EXPORT || echo "E: otto-run exited with status $?"
 
85
 
 
86
set +e
 
87
show_dl_addr $CONTAINER
 
88
set -e