3
JUJU_HOME="$HOME/.juju"
6
REVISION_BUILD="lastSuccessfulBuild"
7
while [[ "${1-}" != "" && $1 =~ ^-.* ]]; do
11
JUJU_HOME=$(cd $1; pwd)
29
if [[ -z $AMI_IMAGE || -z $SERIES ]]; then
30
echo "--ami-image and --series are required"
38
SCRIPTS=$(readlink -f $(dirname $0))
41
export PATH="$SCRIPTS:$PATH"
42
source $JUJU_HOME/ec2rc
44
$SCRIPTS/jujuci.py get -a -b $REVISION_BUILD build-revision buildvars.bash bash
45
source bash/buildvars.bash
46
ec2-terminate-job-instances
48
export INSTANCE_TYPE=m1.large
49
instance_id=$(ec2-run-instance-get-id)
50
instance_name=$(ec2-get-name $instance_id)
51
ec2-tag-job-instances $instance_id
52
wait-for-port $instance_name 22
54
RELEASE=$(ssh -o 'StrictHostKeyChecking no' -o 'UserKnownHostsFile /dev/null' \
55
ubuntu@$instance_name lsb_release -sr)
56
ARCH=$(ssh -o 'StrictHostKeyChecking no' -o 'UserKnownHostsFile /dev/null' \
57
ubuntu@$instance_name dpkg --print-architecture)
63
$SCRIPTS/s3ci.py get \
64
$revision_build build-binary-trusty-$ARCH 'juju.*\.deb' debs
66
scp -o 'StrictHostKeyChecking no' -o 'UserKnownHostsFile /dev/null' \
67
debs/*.deb ubuntu@$instance_name:
70
ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" \
71
ubuntu@$instance_name "SERIES=$SERIES bash"<<"EOT"
73
for attempt in $(seq 10); do
74
if grep ec2.archive.ubuntu.com /etc/apt/sources.list > /dev/null; then
76
elif [ "$attempt" == "10" ]; then
81
sudo sed s,//.*ec2.archive.ubuntu.com,//archive.ubuntu.com, \
82
/etc/apt/sources.list -i
83
if [[ $SERIES == "precise" ]]; then
84
sudo add-apt-repository cloud-archive:tools
87
sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
88
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y bzr
90
# prevent spurious failure on success
92
afact=lastSuccessfulBuild/artifact
93
sudo dpkg -i *.deb || true
94
sudo apt-get install -y -f
95
export JUJU_REPOSITORY="$HOME/repo"
96
mkdir -p $JUJU_REPOSITORY/$SERIES
97
bzr branch lp:charms/ubuntu $JUJU_REPOSITORY/$SERIES/ubuntu
99
cat > ~/.juju/environments.yaml <<EOT2
104
tools-metadata-url: http://juju-dist.s3.amazonaws.com/testing/tools
105
enable-os-refresh-update: true
106
default-series: trusty
108
ssh-keygen -t rsa -b 2048 -N "" -f ~/.ssh/id_rsa
119
report_network "The starting network conditions:"
120
echo "Restricting the network:"
121
login_ip=$(netstat --tcp -n|sed -nr 's/.*:22 *([^ ]*):.* .*/\1/p')
122
gateway=$(route -n | sed -rn 's/^0.0.0.0 *([0-7.]*) .*/\1/p')
123
nameservers="$(sed /etc/resolv.conf -nr -e 's/nameserver (.*)/\1/p')"
124
for ns in $nameservers; do
125
sudo route add $ns gw $gateway
127
sudo route add $login_ip gw $gateway
128
for ip in $(dig archive.ubuntu.com ubuntu-cloud.archive.canonical.com\
129
security.ubuntu.com cloud-images.ubuntu.com +short |sort|uniq); do
130
sudo route add $ip gw $gateway
132
sudo route add -net 172.16.0.0 netmask 255.240.0.0 gw $gateway
133
sudo route del default gw $gateway
134
report_network "The final network conditions:"
135
juju bootstrap --show-log
136
for x in $(seq 6); do
137
if juju deploy --show-log local:$SERIES/ubuntu; then
139
elif [ "$x" == "6" ]; then
143
for x in $(seq 30); do
144
# relying on the indentation of ubuntu/0's agent-state here...
145
# but current: idle matches only the unit of the ubuntu service.
146
if juju status --format yaml | grep -E ' {8}agent-state: started|current: idle'; then
151
juju status --format yaml
152
report_network "The failing network conditions:"
153
# Restore some routing so that staff can do an autopsy
154
sudo route add default gw $gateway eth0
159
ec2-terminate-job-instances