3
# IMPORTANT: The ssh options are always remapped to $@ which preserves
7
: ${LOCAL_JENKINS_URL=$JENKINS_URL}
8
ssh_options='-o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null"'
11
if [[ $1 =~ .*@.* ]]; then
13
remote_user=$(echo $1 | cut -d @ -f1)
14
instance_name=$(echo $1 | cut -d @ -f2)
16
eval "set -- $ssh_options $1"
19
export INSTANCE_TYPE=$1
21
eval "set -- $ssh_options"
24
if [[ $is_ephemeral == "true" ]]; then
25
instance_id=$($SCRIPTS/ec2-run-instance-get-id)
26
$SCRIPTS/ec2-tag-job-instances $instance_id
28
echo Starting instance $instance_id
29
instance_name=$($SCRIPTS/ec2-get-name $instance_id)
30
echo Instance has ip $instance_name
32
$SCRIPTS/wait-for-port $instance_name 22
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
41
rev=${REVNO-$(echo $REVISION_ID | head -c8)}
42
echo "Testing $BRANCH $rev"
44
tarfile=$($SCRIPTS/get-tarfile-name $revision_build)
45
test -f $tarfile && rm $tarfile
46
wget -q $archive/$tarfile
48
juju_version=$(basename $tarfile .tar.gz)
52
DEPS="make bzr distro-info-data git-core mercurial zip rsyslog-gnutls"
53
ssh "$@" $remote_user@$instance_name <<EOT
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
59
elif [ "\$attempt" == "10" ]; then
60
echo "Universe is not available to install packages from."
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;
71
if [[ $is_ephemeral == "true" ]]; then
72
# sudo apt-get upgrade -y
73
echo "Skipping upgrade."
75
if [[ \$(apt-cache madison juju-mongodb) =~ .*juju-mongodb.* ]]; then
76
juju_db="juju-mongodb"
78
juju_db="mongodb-server"
80
if [[ \$(uname -p) =~ .*86|armel|armhf.* ]]; then
81
juju_compiler="golang"
83
juju_compiler="gccgo-4.9 gccgo-go"
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
91
scp "$@" $tarfile $remote_user@$instance_name:~/
93
ssh "$@" $remote_user@$instance_name <<EOT
95
if [[ ! -f ~/.ssh/id_rsa ]]; then
96
ssh-keygen -t rsa -b 2048 -N "" -f ~/.ssh/id_rsa
98
export GOPATH=\$HOME/$juju_version
99
if [[ -d \$GOPATH ]]; then
103
if [[ -d \$GOPATH/src/launchpad.net/juju-core ]]; then
104
cd \$GOPATH/src/launchpad.net/juju-core
106
cd \$GOPATH/src/github.com/juju/juju
108
bzr whoami 'J. Random Hacker <jrandom@example.org>'
109
go version || gccgo -v
111
# Hack match for i386.
112
sed -i 's/x86/86/' Makefile
113
export JUJU_NOTEST_MONGOJS=1
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
129
if [[ $is_ephemeral == "true" ]]; then
130
$SCRIPTS/ec2-terminate-job-instances