Update build toolchain to the use of docker…

… for integration tests.

- Update circle.yml to start the docker daemon listening on TCP (to be
  able to talk to it from the container running test-integration)
- Update script/test-integration to prepare the use of go-check
- Update Makefile in order to run less "binary" target and setting up
  the right environment variable for the builds

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2015-09-27 15:56:53 +02:00
parent 47015433cc
commit a5a8d6929e
5 changed files with 39 additions and 14 deletions

View file

@ -5,15 +5,16 @@ TRAEFIK_ENVS := \
-e OS_PLATFORM_ARG \
-e TESTFLAGS
BIND_DIR := $(if $(DOCKER_HOST),,dist)
TRAEFIK_MOUNT := $(if $(BIND_DIR),-v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/emilevauge/traefik/$(BIND_DIR)")
BIND_DIR := "dist"
TRAEFIK_MOUNT := -v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/emilevauge/traefik/$(BIND_DIR)"
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
TRAEFIK_DEV_IMAGE := traefik-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH))
REPONAME := $(shell echo $(REPO) | tr '[:upper:]' '[:lower:]')
TRAEFIK_IMAGE := $(if $(REPONAME),$(REPONAME),"emilevauge/traefik")
INTEGRATION_OPTS := $(if $(MAKE_DOCKER_HOST),-e "DOCKER_HOST=$(MAKE_DOCKER_HOST)", -v "/var/run/docker.sock:/var/run/docker.sock")
DOCKER_RUN_TRAEFIK := docker run $(if $(CIRCLECI),,--rm) -it $(TRAEFIK_ENVS) $(TRAEFIK_MOUNT) "$(TRAEFIK_DEV_IMAGE)"
DOCKER_RUN_TRAEFIK := docker run $(if $(CIRCLECI),,--rm) $(INTEGRATION_OPTS) -it $(TRAEFIK_ENVS) $(TRAEFIK_MOUNT) "$(TRAEFIK_DEV_IMAGE)"
print-%: ; @echo $*=$($*)
@ -22,14 +23,17 @@ default: binary
binary: build
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate binary
crossbinary: build
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate crossbinary
test: build
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate test-unit test-integration
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate test-unit binary test-integration
test-unit: build
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate test-unit
test-integration: build
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate binary test-integration
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate test-integration
validate: build
$(DOCKER_RUN_TRAEFIK) ./script/make.sh validate-gofmt validate-govet
@ -47,10 +51,6 @@ shell: build
$(DOCKER_RUN_TRAEFIK) /bin/bash
image: build
if ! [ -a dist/traefik_linux-386 ] ; \
then \
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate binary; \
fi;
docker build -t $(TRAEFIK_IMAGE) .
dist:

View file

@ -4,10 +4,26 @@ RUN go get github.com/tools/godep
RUN go get github.com/mitchellh/gox
RUN go get github.com/tcnksm/ghr
# Which docker version to test on
ENV DOCKER_VERSION 1.6.2
# Download docker
RUN set -ex; \
curl https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION} -o /usr/local/bin/docker-${DOCKER_VERSION}; \
chmod +x /usr/local/bin/docker-${DOCKER_VERSION}
# Set the default Docker to be run
RUN ln -s /usr/local/bin/docker-${DOCKER_VERSION} /usr/local/bin/docker
ENV PATH /go/src/github.com/emilevauge/traefik/Godeps/_workspace/bin:$PATH
WORKDIR /go/src/github.com/emilevauge/traefik
# This is a hack (see libcompose#32) - will be removed when libcompose will be fixed
# (i.e go get able)
RUN mkdir -p /go/src/github.com/docker/docker/autogen/dockerversion/
COPY Godeps/_workspace/src/github.com/docker/docker/autogen/dockerversion/dockerversion.go /go/src/github.com/docker/docker/autogen/dockerversion/dockerversion.go
RUN mkdir Godeps
COPY Godeps/Godeps.json Godeps/
RUN godep restore

View file

@ -1,11 +1,15 @@
machine:
services:
- docker
pre:
- sudo docker -d -e lxc -s btrfs -H tcp://0.0.0.0:2375:
background: true
- sleep 5
environment:
REPO: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
DOCKER_HOST: tcp://172.17.42.1:2375
dependencies:
pre:
- docker version
- go get github.com/tcnksm/ghr
- make validate
override:
@ -13,8 +17,10 @@ dependencies:
test:
override:
- make test
- make test-unit
- make MAKE_DOCKER_HOST=$DOCKER_HOST test-integration
post:
- make crossbinary
- make image
deployment:

View file

@ -4,6 +4,7 @@ set -e
# List of bundles to create when no argument is passed
DEFAULT_BUNDLES=(
validate-gofmt
validate-govet
binary
test-unit

View file

@ -3,6 +3,8 @@
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export DEST=.
TESTFLAGS="$TESTFLAGS"
#godep go test -v ./integration
TESTFLAGS="$TESTFLAGS -test.timeout=30m -check.v"
cd integration
GOPATH=`godep path`:$GOPATH go test $TESTFLAGS