mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
commit
ca8c899f2b
5 changed files with 108 additions and 8 deletions
1
libnetwork/.gitignore
vendored
1
libnetwork/.gitignore
vendored
|
@ -4,6 +4,7 @@
|
||||||
*.so
|
*.so
|
||||||
|
|
||||||
# Folders
|
# Folders
|
||||||
|
integration-tmp/
|
||||||
_obj
|
_obj
|
||||||
_test
|
_test
|
||||||
|
|
||||||
|
|
|
@ -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
|
SHELL=/bin/bash
|
||||||
build_image=libnetwork-build
|
build_image=libnetwork-build
|
||||||
dockerargs = --privileged -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork
|
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"
|
ciargs = -e "COVERALLS_TOKEN=$$COVERALLS_TOKEN" -e "INSIDECONTAINER=-incontainer=true"
|
||||||
cidocker = docker run ${ciargs} ${dockerargs} golang:1.4
|
cidocker = docker run ${ciargs} ${dockerargs} golang:1.4
|
||||||
|
|
||||||
all: ${build_image}.created
|
all: ${build_image}.created build check integration-tests
|
||||||
${docker} ./wrapmake.sh all-local
|
|
||||||
|
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
|
all-local: check-local build-local
|
||||||
|
|
||||||
|
@ -19,13 +26,16 @@ ${build_image}.created:
|
||||||
touch ${build_image}.created
|
touch ${build_image}.created
|
||||||
|
|
||||||
build: ${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:
|
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
|
check: ${build_image}.created
|
||||||
${docker} ./wrapmake.sh check-local
|
@${docker} ./wrapmake.sh check-local
|
||||||
|
|
||||||
check-code:
|
check-code:
|
||||||
@echo "Checking code... "
|
@echo "Checking code... "
|
||||||
|
@ -76,4 +86,5 @@ coveralls:
|
||||||
# The following target is a workaround for this
|
# The following target is a workaround for this
|
||||||
|
|
||||||
circle-ci:
|
circle-ci:
|
||||||
@${cidocker} make install-deps check-local coveralls
|
@${cidocker} make install-deps build-local check-local coveralls
|
||||||
|
make integration-tests
|
||||||
|
|
|
@ -27,7 +27,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// DefaultHTTPHost is used if only port is provided to -H flag e.g. docker -d -H tcp://:8080
|
// 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 is the default http port used by dnet
|
||||||
DefaultHTTPPort = 2385
|
DefaultHTTPPort = 2385
|
||||||
// DefaultUnixSocket exported
|
// DefaultUnixSocket exported
|
||||||
|
|
54
libnetwork/test/integration/dnet/helpers.bash
Normal file
54
libnetwork/test/integration/dnet/helpers.bash
Normal file
|
@ -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} <<EOF
|
||||||
|
title = "LibNetwork Configuration file"
|
||||||
|
|
||||||
|
[daemon]
|
||||||
|
debug = false
|
||||||
|
defaultnetwork = "${2}"
|
||||||
|
defaultdriver = "${3}"
|
||||||
|
labels = ["com.docker.network.driver.overlay.bind_interface=eth0"]
|
||||||
|
[datastore]
|
||||||
|
embedded = false
|
||||||
|
[datastore.client]
|
||||||
|
provider = "consul"
|
||||||
|
Address = "${bridge_ip}:8500"
|
||||||
|
EOF
|
||||||
|
docker run -d --name=${name} --privileged -p ${hport}:2385 -v $(pwd)/:/go/src/github.com/docker/libnetwork -v /tmp:/tmp -w /go/src/github.com/docker/libnetwork golang:1.4 ./cmd/dnet/dnet -dD -c ${tomlfile}
|
||||||
|
sleep 2
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop_dnet() {
|
||||||
|
name="dnet-$1"
|
||||||
|
rm -rf /tmp/dnet/${name}
|
||||||
|
docker stop ${name}
|
||||||
|
# You cannot destroy a container in Circle CI. So do not attempt destroy in circleci
|
||||||
|
if [ -z "$CIRCLECI" ]; then
|
||||||
|
docker rm ${name} || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function dnet_cmd() {
|
||||||
|
hport=$((41000+${1}-1))
|
||||||
|
shift
|
||||||
|
./cmd/dnet/dnet -H 127.0.0.1:${hport} $*
|
||||||
|
}
|
34
libnetwork/test/integration/dnet/simple.bats
Normal file
34
libnetwork/test/integration/dnet/simple.bats
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load helpers
|
||||||
|
|
||||||
|
export BATS_TEST_CNT=0
|
||||||
|
|
||||||
|
function setup() {
|
||||||
|
if [ "${BATS_TEST_CNT}" -eq 0 ]; then
|
||||||
|
start_consul
|
||||||
|
start_dnet 1 multihost overlay
|
||||||
|
export BATS_TEST_CNT=$((${BATS_TEST_CNT}+1))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function teardown() {
|
||||||
|
export BATS_TEST_CNT=$((${BATS_TEST_CNT}-1))
|
||||||
|
if [ "${BATS_TEST_CNT}" -eq 0 ]; then
|
||||||
|
stop_dnet 1
|
||||||
|
stop_consul
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@test "Test default network" {
|
||||||
|
echo $(docker ps)
|
||||||
|
run dnet_cmd 1 network ls
|
||||||
|
echo ${output}
|
||||||
|
echo ${lines[1]}
|
||||||
|
name=$(echo ${lines[1]} | cut -d" " -f2)
|
||||||
|
driver=$(echo ${lines[1]} | cut -d" " -f3)
|
||||||
|
echo ${name} ${driver}
|
||||||
|
[ "$name" = "multihost" ]
|
||||||
|
[ "$driver" = "overlay" ]
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue