From 028bae8f040654d4aeebf9c4d6067f6baaf5a8d5 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Wed, 28 Oct 2015 11:59:19 -0600 Subject: [PATCH] Run make in circle, don't build arm and 32-bit --- CHANGELOG.md | 1 + Makefile | 9 +++++++++ scripts/circle-test.sh | 32 +++++--------------------------- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5011ec59f..da2f5931c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Telegraf will no longer use docker-compose for "long" unit test, it has been changed to just run docker commands in the Makefile. See `make docker-run` and `make docker-kill`. `make test` will still run all unit tests with docker. +- Long unit tests are now run in CircleCI, with docker & race detector ### Features - [#325](https://github.com/influxdb/telegraf/pull/325): NSQ output. Thanks @jrxFive! diff --git a/Makefile b/Makefile index 3c5b7bd8f..65a6a8d98 100644 --- a/Makefile +++ b/Makefile @@ -4,16 +4,19 @@ ifndef GOBIN GOBIN = $(GOPATH)/bin endif +# Standard Telegraf build build: prepare $(GOBIN)/godep go build -o telegraf -ldflags \ "-X main.Version=$(VERSION)" \ ./cmd/telegraf/telegraf.go +# Build with race detector dev: prepare $(GOBIN)/godep go build -race -o telegraf -ldflags \ "-X main.Version=$(VERSION)" \ ./cmd/telegraf/telegraf.go +# Build linux 64-bit, 32-bit and arm architectures build-linux-bins: prepare GOARCH=amd64 GOOS=linux $(GOBIN)/godep go build -o telegraf_linux_amd64 \ -ldflags "-X main.Version=$(VERSION)" \ @@ -25,9 +28,11 @@ build-linux-bins: prepare -ldflags "-X main.Version=$(VERSION)" \ ./cmd/telegraf/telegraf.go +# Get godep prepare: go get github.com/tools/godep +# Run all docker containers necessary for unit tests docker-run: ifeq ($(UNAME), Darwin) docker run --name kafka \ @@ -52,6 +57,7 @@ endif docker run --name aerospike -p "3000:3000" -d aerospike docker run --name nsq -p "4150:4150" -d nsqio/nsq /nsqd +# Run docker containers necessary for CircleCI unit tests docker-run-circle: docker run --name kafka \ -e ADVERTISED_HOST=localhost \ @@ -62,16 +68,19 @@ docker-run-circle: docker run --name aerospike -p "3000:3000" -d aerospike docker run --name nsq -p "4150:4150" -d nsqio/nsq /nsqd +# Kill all docker containers, ignore errors docker-kill: -docker kill nsq aerospike redis opentsdb rabbitmq postgres memcached mysql kafka -docker rm nsq aerospike redis opentsdb rabbitmq postgres memcached mysql kafka +# Run full unit tests using docker containers (includes setup and teardown) test: docker-kill prepare docker-run # Sleeping for kafka leadership election, TSDB setup, etc. sleep 60 # SUCCESS, running tests godep go test -race ./... +# Run "short" unit tests test-short: prepare $(GOBIN)/godep go test -short ./... diff --git a/scripts/circle-test.sh b/scripts/circle-test.sh index 0287622a3..e3b66e8f2 100755 --- a/scripts/circle-test.sh +++ b/scripts/circle-test.sh @@ -28,15 +28,6 @@ function check_go_fmt { fi } -# build takes three arguments: GOOS & GOARCH & VERSION -function build { - echo -n "=> $1-$2: " - GOOS=$1 GOARCH=$2 godep go build -o telegraf-$1-$2 \ - -ldflags "-X main.Version=$3" \ - ./cmd/telegraf/telegraf.go - du -h telegraf-$1-$2 -} - # Set up the build directory, and then GOPATH. exit_if_fail mkdir $BUILD_DIR export GOPATH=$BUILD_DIR @@ -45,11 +36,6 @@ export GOGC=off export PATH=$GOPATH/bin:$PATH exit_if_fail mkdir -p $GOPATH/src/github.com/influxdb -# Get golint -go get github.com/golang/lint/golint -# Get godep tool -go get github.com/tools/godep - # Dump some test config to the log. echo "Test configuration" echo "========================================" @@ -65,29 +51,21 @@ exit_if_fail cd $GOPATH/src/github.com/influxdb/telegraf check_go_fmt # Build the code -exit_if_fail godep go build -v ./... +exit_if_fail make # Run the tests exit_if_fail godep go vet ./... exit_if_fail make docker-run-circle -sleep 30 +sleep 10 exit_if_fail godep go test -race ./... -# Build binaries -build "linux" "amd64" $VERSION -build "linux" "386" $VERSION -build "linux" "arm" $VERSION - # Simple Integration Tests # check that version was properly set -exit_if_fail "./telegraf-linux-amd64 -version | grep $VERSION" +exit_if_fail "./telegraf -version | grep $VERSION" # check that one test cpu & mem output work tmpdir=$(mktemp -d) -./telegraf-linux-amd64 -sample-config > $tmpdir/config.toml -exit_if_fail ./telegraf-linux-amd64 -config $tmpdir/config.toml \ +./telegraf -sample-config > $tmpdir/config.toml +exit_if_fail ./telegraf -config $tmpdir/config.toml \ -test -filter cpu:mem -# Artifact binaries -mv telegraf* $CIRCLE_ARTIFACTS - exit $rc