~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to run-unit-tests-new-archs

  • Committer: Curtis Hovey
  • Date: 2014-08-01 12:44:38 UTC
  • Revision ID: curtis@canonical.com-20140801124438-l48516pldkzh7g5n
Do not show all the files in the tarball because it distracts from the test output.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
# IMPORTANT: The ssh options are always remapped to $@ which preserves
 
4
# their tokenisation.
 
5
 
 
6
set -eux
 
7
: ${LOCAL_JENKINS_URL=$JENKINS_URL}
 
8
ssh_options='-o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null"'
 
9
remote_user="ubuntu"
 
10
 
 
11
if [[ $1 =~ .*@.* ]]; then
 
12
    is_ephemeral="false"
 
13
    remote_user=$(echo $1 | cut -d @ -f1)
 
14
    instance_name=$(echo $1 | cut -d @ -f2)
 
15
    shift
 
16
    eval "set -- $ssh_options $1"
 
17
else
 
18
    is_ephemeral="true"
 
19
    export INSTANCE_TYPE=$1
 
20
    export AMI_IMAGE=$2
 
21
    eval "set -- $ssh_options"
 
22
fi
 
23
 
 
24
if [[ $is_ephemeral == "true" ]]; then
 
25
    instance_id=$($SCRIPTS/ec2-run-instance-get-id)
 
26
    $SCRIPTS/ec2-tag-job-instances $instance_id
 
27
    set +x
 
28
    echo Starting instance $instance_id
 
29
    instance_name=$($SCRIPTS/ec2-get-name $instance_id)
 
30
    echo Instance has ip $instance_name
 
31
    sleep 30
 
32
    $SCRIPTS/wait-for-port $instance_name 22
 
33
fi
 
34
 
 
35
# Define common vars for remote scripts; do not make them evalaute
 
36
# what is known in this script to ensure the logs line order is sane.
 
37
archive="$LOCAL_JENKINS_URL/job/build-revision/lastSuccessfulBuild/artifact"
 
38
test -f buildvars.bash && rm buildvars.bash
 
39
wget -q $archive/buildvars.bash
 
40
source buildvars.bash
 
41
rev=${REVNO-$(echo $REVISION_ID | head -c8)}
 
42
echo "Testing $BRANCH $rev"
 
43
 
 
44
tarfile=$($SCRIPTS/get-tarfile-name $revision_build)
 
45
test -f $tarfile && rm $tarfile
 
46
wget -q $archive/$tarfile
 
47
 
 
48
juju_version=$(basename $tarfile .tar.gz)
 
49
 
 
50
set -x
 
51
set +e
 
52
DEPS="make bzr distro-info-data git-core mercurial zip rsyslog-gnutls"
 
53
ssh "$@" $remote_user@$instance_name  <<EOT
 
54
set -eux
 
55
if [[ $is_ephemeral == "true" ]]; then
 
56
    for attempt in \$(seq 10); do
 
57
        if grep -r '^deb .* universe$' /etc/apt/sources.list > /dev/null; then
 
58
            break
 
59
        elif [ "\$attempt" == "10" ]; then
 
60
            echo "Universe is not available to install packages from."
 
61
            exit 1
 
62
        fi
 
63
        sleep 10m
 
64
    done
 
65
fi
 
66
needs_ppa=\$(lsb_release -sc | sed -r 's,(saucy|precise),true,')
 
67
if [[ \$needs_ppa == 'true' ]]; then
 
68
    sudo apt-add-repository -y ppa:juju/experimental;
 
69
fi
 
70
sudo apt-get update
 
71
if [[ $is_ephemeral == "true" ]]; then
 
72
    # sudo apt-get upgrade -y
 
73
    echo "Skipping upgrade."
 
74
fi
 
75
if [[ \$(apt-cache madison juju-mongodb) =~ .*juju-mongodb.* ]]; then
 
76
    juju_db="juju-mongodb"
 
77
else
 
78
    juju_db="mongodb-server"
 
79
fi
 
80
if [[ \$(uname -p) =~  .*86|armel|armhf.* ]]; then
 
81
    juju_compiler="golang"
 
82
else
 
83
    juju_compiler="gccgo-4.9 gccgo-go"
 
84
fi
 
85
sudo apt-get install -y --no-install-recommends $DEPS \$juju_db \$juju_compiler
 
86
if [[ \$(lsb_release -sc) == "trusty" ]]; then
 
87
    sudo apt-get install -y mongodb-server
 
88
fi
 
89
EOT
 
90
 
 
91
scp "$@" $tarfile $remote_user@$instance_name:~/
 
92
 
 
93
ssh "$@" $remote_user@$instance_name <<EOT
 
94
set -eux
 
95
if [[ ! -f ~/.ssh/id_rsa ]]; then
 
96
    ssh-keygen -t rsa -b 2048 -N "" -f ~/.ssh/id_rsa
 
97
fi
 
98
export GOPATH=\$HOME/$juju_version
 
99
if [[ -d \$GOPATH ]]; then
 
100
  rm -r \$GOPATH
 
101
fi
 
102
tar -xzf $tarfile
 
103
if [[ -d \$GOPATH/src/launchpad.net/juju-core ]]; then
 
104
    cd \$GOPATH/src/launchpad.net/juju-core
 
105
else
 
106
    cd \$GOPATH/src/github.com/juju/juju
 
107
fi
 
108
bzr whoami 'J. Random Hacker <jrandom@example.org>'
 
109
go version || gccgo -v
 
110
make build
 
111
# Hack match for i386.
 
112
sed -i 's/x86/86/' Makefile
 
113
export JUJU_NOTEST_MONGOJS=1
 
114
make check
 
115
EOT
 
116
EXIT_STATUS=$?
 
117
 
 
118
ssh "$@" $remote_user@$instance_name <<EOT
 
119
echo "Cleaning up /tmp"
 
120
sudo killall -SIGABRT /usr/bin/mongod
 
121
rm -r /tmp/adduser-* || true
 
122
rm -r /tmp/go-* || true
 
123
rm -r /tmp/gocheck-* || true
 
124
rm -r /tmp/juju-* || true
 
125
rm -r /tmp/test-* || true
 
126
EOT
 
127
 
 
128
 
 
129
if [[ $is_ephemeral == "true" ]]; then
 
130
    $SCRIPTS/ec2-terminate-job-instances
 
131
fi
 
132
 
 
133
exit $EXIT_STATUS