~abentley/juju-ci-tools/client-from-config-4

« back to all changes in this revision

Viewing changes to run-unit-tests

  • Committer: Martin Packman
  • Date: 2015-11-17 14:19:06 UTC
  • mto: This revision was merged to the branch mainline in revision 1155.
  • Revision ID: martin.packman@canonical.com-20151117141906-a4zmuqre72s7fyf1
Sample script for generating image streams for rackspace

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
export AMI_IMAGE=$2
7
7
shift; shift
8
8
 
9
 
JOB_NAME=${JOB_NAME:-$USER-run-unit-tests}
10
 
export JOB_NAME
11
 
 
12
9
FIXUP_SOURCES=""
13
10
IS_LOCAL="false"
14
11
RETRY="false"
15
12
ROBUST="false"
16
 
REVISION_BUILD="none"
 
13
REVISION_BUILD=${revision_build:-}
17
14
USE_PPA=""
18
 
INSTALL_DEPS=""
19
15
USE_TMPFS="false"
20
16
GOTESTCMD="go test"
21
17
LOG_FILE_PATH="/usr/share/distro-info/ubuntu.csv"
53
49
                exit 1
54
50
            fi
55
51
            ;;
56
 
        --install-deps)
57
 
            shift
58
 
            INSTALL_DEPS=$1
59
 
            ;;
60
52
        --use-tmpfs)
61
53
            USE_TMPFS="true"
62
54
            ;;
68
60
done
69
61
 
70
62
 
71
 
if [[ $IS_LOCAL == "false" && $REVISION_BUILD == "none" ]]; then
72
 
    echo "You must use either the --local or --revision-build option."
73
 
    exit 1
74
 
fi
75
 
 
76
 
 
77
63
if [[ $IS_LOCAL == "false" ]]; then
78
64
    # Download the buildvars and tartfile and lean the tarfile name.
79
 
    tarfile=$(
80
 
        $SCRIPTS/s3ci.py get --config $JUJU_HOME/juju-qa.s3cfg \
81
 
        $REVISION_BUILD build-revision '.*.tar.gz' ./)
82
 
    $SCRIPTS/s3ci.py get-summary --config $JUJU_HOME/juju-qa.s3cfg \
83
 
        $REVISION_BUILD $AMI_IMAGE
 
65
    downloaded=$($SCRIPTS/jujuci.py get build-revision '*' ./)
 
66
    tarfile=$(basename $(echo "$downloaded" | grep -F tar.gz))
 
67
    $SCRIPTS/jujuci.py get-build-vars \
 
68
        --summary --env $AMI_IMAGE $REVISION_BUILD
84
69
fi
85
70
tarfile_path=$(readlink -f $tarfile)
86
71
tarfile_basename=$(basename $tarfile)
142
127
ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" \
143
128
    ubuntu@$instance_name  <<EOT
144
129
set -eux
145
 
if  [[ -L /tmp ]]; then
146
 
    export TMPDIR=\$(readlink -f /tmp)
147
 
fi
148
130
if [[ ! -f ~/.ssh/id_rsa ]]; then
149
131
    ssh-keygen -t rsa -b 2048 -N "" -f ~/.ssh/id_rsa
150
132
fi
153
135
    sudo mount -t tmpfs -o size=3G /mnt/tmp /mnt/tmp
154
136
    export TMPDIR=/mnt/tmp
155
137
fi
 
138
tar -xzf $tarfile_basename
156
139
export GOPATH=\$HOME/$juju_version
157
 
if [[ -d \$GOPATH ]]; then
158
 
    echo "Cleaning up files unpacked into the GOPATH by a previous test."
159
 
    rm -r \$GOPATH
160
 
fi
161
 
tar -xzf $tarfile_basename
162
140
if [[ -d \$HOME/goroot ]]; then
163
141
    export GOROOT=\$HOME/goroot
164
142
fi
174
152
    done
175
153
    $FIXUP_SOURCES
176
154
fi
177
 
export PATH=/usr/lib/go-1.6/bin:$PATH
178
 
export DEBIAN_FRONTEND=noninteractive
179
 
sudo apt-get update
180
 
sudo apt-get upgrade -y --force-yes \
181
 
    -o Dpkg::Options::="--force-confdef" \
182
 
    -o Dpkg::Options::="--force-confold" \
183
 
    -o Dpkg::Options::="--force-confnew"
184
 
sudo apt-get install -y make gcc software-properties-common distro-info-data
185
155
if [[ "$USE_PPA" != "" ]]; then
186
156
    sudo apt-add-repository -y $USE_PPA;
187
 
    sudo apt-get update
188
 
fi
189
 
if [[ "$INSTALL_DEPS" == "" ]]; then
190
 
    echo "Installing default deps."
191
 
    make install-dependencies
192
 
else
193
 
    echo "Installing deps from command line."
194
 
    sudo apt-get install -y $INSTALL_DEPS
195
 
fi
196
 
 
 
157
fi
 
158
sudo apt-get update
 
159
sudo apt-get upgrade -y
 
160
sudo apt-get install -y make python-software-properties distro-info-data
 
161
make install-dependencies
197
162
# TODO(gz): Remove bzr whoami?
198
163
bzr whoami 'J. Random Hacker <jrandom@example.org>'
199
164
go version || gccgo -v
203
168
if ! grep 'Angsty Antelope' $LOG_FILE_PATH ; then
204
169
  echo "$LOG_TXT" | sudo tee -a $LOG_FILE_PATH
205
170
fi
206
 
# Delay Xenial LTS birthday by one month.
207
 
sudo sed -i -e 's,2016-04-21,2016-05-21,' $LOG_FILE_PATH
208
171
 
209
172
if [[ $INSTANCE_TYPE == "host" ]]; then
210
173
    echo "Cleaning up /tmp if it is dirty."
217
180
    sudo rm -rf /tmp/test-* || true
218
181
fi
219
182
 
220
 
make setup-lxd || true
221
 
 
222
183
go test -i ./...
223
184
if [[ "$RETRY" == "true" ]]; then
224
185
    $GOTESTCMD ./... || $GOTESTCMD ./...
253
214
    sudo killall -SIGABRT /usr/bin/mongod || true
254
215
    sudo killall -SIGABRT /usr/lib/juju/bin/mongod || true
255
216
    rm -rf /home/ubuntu/$juju_version
256
 
    rm -rf /tmp/adduser-* || true
257
 
    rm -rf /tmp/go-* || true
258
 
    rm -rf /tmp/gocheck-* || true
259
 
    rm -rf /tmp/gui-* || true
260
 
    rm -rf /tmp/pprof-* || true
261
 
    rm -rf /tmp/juju-* || true
262
 
    rm -rf /tmp/test-* || true
263
 
    rm -rf /tmp/gui-* || true
 
217
    rm -rf /tmp/adduser-*
 
218
    rm -rf /tmp/go-*
 
219
    rm -rf /tmp/gocheck-*
 
220
    rm -rf /tmp/juju-*
 
221
    rm -rf /tmp/test-*
264
222
EOT
265
223
else
266
224
    set +e