diff --git a/libnetwork/.gitignore b/libnetwork/.gitignore index c03c9653ab..0f3e6e30dd 100644 --- a/libnetwork/.gitignore +++ b/libnetwork/.gitignore @@ -4,6 +4,7 @@ *.so # Folders +integration-tmp/ _obj _test diff --git a/libnetwork/Makefile b/libnetwork/Makefile index 830a75b046..e9d06e5e8f 100644 --- a/libnetwork/Makefile +++ b/libnetwork/Makefile @@ -1,4 +1,4 @@ -.PHONY: all all-local build build-local check check-code check-format run-tests check-local install-deps coveralls circle-ci +.PHONY: all all-local build build-local check check-code check-format run-tests check-local integration-tests install-deps coveralls circle-ci SHELL=/bin/bash build_image=libnetwork-build dockerargs = --privileged -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork @@ -7,8 +7,15 @@ docker = docker run --rm -it ${dockerargs} ${container_env} ${build_image} ciargs = -e "COVERALLS_TOKEN=$$COVERALLS_TOKEN" -e "INSIDECONTAINER=-incontainer=true" cidocker = docker run ${ciargs} ${dockerargs} golang:1.4 -all: ${build_image}.created - ${docker} ./wrapmake.sh all-local +all: ${build_image}.created build check integration-tests + +integration-tests: + @if [ ! -d ./integration-tmp ]; then \ + mkdir -p ./integration-tmp; \ + git clone https://github.com/sstephenson/bats.git ./integration-tmp/bats; \ + ./integration-tmp/bats/install.sh ./integration-tmp; \ + fi + @./integration-tmp/bin/bats ./test/integration/dnet all-local: check-local build-local @@ -19,13 +26,16 @@ ${build_image}.created: touch ${build_image}.created build: ${build_image}.created - ${docker} ./wrapmake.sh build-local + @echo "Building code... " + @${docker} ./wrapmake.sh build-local + @echo "Done building code" build-local: - $(shell which godep) go build -tags libnetwork_discovery ./... + @$(shell which godep) go build -tags libnetwork_discovery ./... + @$(shell which godep) go build -o ./cmd/dnet/dnet ./cmd/dnet check: ${build_image}.created - ${docker} ./wrapmake.sh check-local + @${docker} ./wrapmake.sh check-local check-code: @echo "Checking code... " @@ -76,4 +86,5 @@ coveralls: # The following target is a workaround for this circle-ci: - @${cidocker} make install-deps check-local coveralls + @${cidocker} make install-deps build-local check-local coveralls + make integration-tests diff --git a/libnetwork/cmd/dnet/dnet.go b/libnetwork/cmd/dnet/dnet.go index c0d497d4c1..a66c548285 100644 --- a/libnetwork/cmd/dnet/dnet.go +++ b/libnetwork/cmd/dnet/dnet.go @@ -27,7 +27,7 @@ import ( const ( // DefaultHTTPHost is used if only port is provided to -H flag e.g. docker -d -H tcp://:8080 - DefaultHTTPHost = "127.0.0.1" + DefaultHTTPHost = "0.0.0.0" // DefaultHTTPPort is the default http port used by dnet DefaultHTTPPort = 2385 // DefaultUnixSocket exported diff --git a/libnetwork/test/integration/dnet/helpers.bash b/libnetwork/test/integration/dnet/helpers.bash new file mode 100644 index 0000000000..65533a15df --- /dev/null +++ b/libnetwork/test/integration/dnet/helpers.bash @@ -0,0 +1,54 @@ +function start_consul() { + docker run -d --name=pr_consul -p 8500:8500 -p 8300-8302:8300-8302/tcp -p 8300-8302:8300-8302/udp -h consul progrium/consul -server -bootstrap + sleep 2 +} + +function stop_consul() { + docker stop pr_consul + # You cannot destroy a container in Circle CI. So do not attempt destroy in circleci + if [ -z "$CIRCLECI" ]; then + docker rm pr_consul + fi +} + +function start_dnet() { + name="dnet-$1" + hport=$((41000+${1}-1)) + + bridge_ip=$(docker inspect --format '{{.NetworkSettings.Gateway}}' pr_consul) + mkdir -p /tmp/dnet/${name} + tomlfile="/tmp/dnet/${name}/libnetwork.toml" + cat > ${tomlfile} <