2015-04-16 03:44:14 +00:00
#!/bin/bash
#
# This is the InfluxDB CircleCI test script. Using this script allows total control
# the environment in which the build and test is run, and matches the official
# build process for InfluxDB.
BUILD_DIR = $HOME /influxdb-build
2015-08-27 00:26:07 +00:00
GO_VERSION = go1.5
2015-05-18 16:44:43 +00:00
PARALLELISM = "-parallel 256"
2015-08-13 21:04:28 +00:00
TIMEOUT = "-timeout 480s"
2015-04-16 03:44:14 +00:00
# Executes the given statement, and exits if the command returns a non-zero code.
function exit_if_fail {
command = $@
echo " Executing ' $command ' "
$command
rc = $?
if [ $rc -ne 0 ] ; then
echo " ' $command ' returned $rc . "
exit $rc
fi
}
source $HOME /.gvm/scripts/gvm
exit_if_fail gvm use $GO_VERSION
# Set up the build directory, and then GOPATH.
exit_if_fail mkdir $BUILD_DIR
export GOPATH = $BUILD_DIR
exit_if_fail mkdir -p $GOPATH /src/github.com/influxdb
2015-05-15 14:15:37 +00:00
# Dump some test config to the log.
echo "Test configuration"
echo "========================================"
echo " \$HOME: $HOME "
echo " \$GOPATH: $GOPATH "
echo " \$CIRCLE_BRANCH: $CIRCLE_BRANCH "
2015-04-16 03:44:14 +00:00
# Move the checked-out source to a better location.
exit_if_fail mv $HOME /influxdb $GOPATH /src/github.com/influxdb
exit_if_fail cd $GOPATH /src/github.com/influxdb/influxdb
2015-04-21 03:36:04 +00:00
exit_if_fail git branch --set-upstream-to= origin/$CIRCLE_BRANCH $CIRCLE_BRANCH
2015-04-16 03:44:14 +00:00
# Install the code.
exit_if_fail cd $GOPATH /src/github.com/influxdb/influxdb
2015-05-15 14:15:37 +00:00
exit_if_fail go get -t -d -v ./...
2015-04-16 03:44:14 +00:00
exit_if_fail git checkout $CIRCLE_BRANCH # 'go get' switches to master. Who knew? Switch back.
exit_if_fail go build -v ./...
# Run the tests.
2015-04-21 03:36:04 +00:00
exit_if_fail go tool vet --composites= false .
2015-04-16 03:44:14 +00:00
case $CIRCLE_NODE_INDEX in
0)
2015-09-02 15:42:39 +00:00
go test $PARALLELISM $TIMEOUT -v ./... 2>& 1 | tee $CIRCLE_ARTIFACTS /test_logs.txt
2015-04-20 20:08:38 +00:00
rc = ${ PIPESTATUS [0] }
2015-09-02 18:23:09 +00:00
; ;
1)
2015-08-18 03:27:43 +00:00
# 32bit tests. (Could be run on a separate node instead)
exit_if_fail docker build -f Dockerfile_test_ubuntu32 -t ubuntu-32-influxdb-test .
2015-09-02 18:02:16 +00:00
docker run -v $( pwd ) :/root/go/src/github.com/influxdb/influxdb -e " CI= ${ CI } " \
2015-08-18 03:27:43 +00:00
-v ${ CIRCLE_ARTIFACTS } :/tmp/artifacts \
-t ubuntu-32-influxdb-test bash \
-c " cd /root/go/src/github.com/influxdb/influxdb && go get -t -d -v ./... && go build -v ./... && go test ${ PARALLELISM } ${ TIMEOUT } -v ./... 2>&1 | tee /tmp/artifacts/test_logs_i386.txt && exit \${PIPESTATUS[0]} "
rc = $?
2015-04-16 03:44:14 +00:00
; ;
2015-09-02 18:39:11 +00:00
2)
2015-09-02 15:42:39 +00:00
GORACE = "halt_on_error=1" go test $PARALLELISM $TIMEOUT -v -race ./... 2>& 1 | tee $CIRCLE_ARTIFACTS /test_logs_race.txt
2015-07-23 19:06:32 +00:00
rc = ${ PIPESTATUS [0] }
; ;
2015-04-16 03:44:14 +00:00
esac
2015-04-20 20:08:38 +00:00
exit $rc