From ab0c0df288ba64b324c396eaed3ac804c30e2dfd Mon Sep 17 00:00:00 2001 From: Jana Radhakrishnan Date: Wed, 28 Oct 2015 19:10:38 -0700 Subject: [PATCH] Add IT case for external connectivity Added IT cases for external connectivity check for bridge and overlay networks, both initially and after a restart. Signed-off-by: Jana Radhakrishnan --- libnetwork/cmd/dnet/dnet.go | 10 ++++++++++ libnetwork/test/integration/dnet/bridge.bats | 3 +++ libnetwork/test/integration/dnet/helpers.bash | 15 +++++++++++---- .../test/integration/dnet/overlay-consul.bats | 12 ++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/libnetwork/cmd/dnet/dnet.go b/libnetwork/cmd/dnet/dnet.go index 4f43c4fd68..ab865161bd 100644 --- a/libnetwork/cmd/dnet/dnet.go +++ b/libnetwork/cmd/dnet/dnet.go @@ -225,6 +225,16 @@ func (d *dnetConnection) dnetDaemon(cfgFile string) error { if err == nil { cOptions = processConfig(cfg) } + + bridgeConfig := options.Generic{ + "EnableIPForwarding": true, + "EnableIPTables": true, + } + + bridgeOption := options.Generic{netlabel.GenericData: bridgeConfig} + + cOptions = append(cOptions, config.OptionDriverConfig("bridge", bridgeOption)) + controller, err := libnetwork.New(cOptions...) if err != nil { fmt.Println("Error starting dnetDaemon :", err) diff --git a/libnetwork/test/integration/dnet/bridge.bats b/libnetwork/test/integration/dnet/bridge.bats index eff60eee6f..9920faacc8 100644 --- a/libnetwork/test/integration/dnet/bridge.bats +++ b/libnetwork/test/integration/dnet/bridge.bats @@ -20,6 +20,8 @@ function test_single_network_connectivity() { # Now test connectivity between all the containers using service names for i in `seq ${start} ${end}`; do + runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_${i}) \ + "ping -c 1 www.google.com" for j in `seq ${start} ${end}`; do if [ "$i" -eq "$j" ]; then @@ -49,6 +51,7 @@ function test_single_network_connectivity() { test_single_network_connectivity bridge 3 } + @test "Test default network dnet restart" { skip_for_circleci diff --git a/libnetwork/test/integration/dnet/helpers.bash b/libnetwork/test/integration/dnet/helpers.bash index 5129220365..7b507abf79 100644 --- a/libnetwork/test/integration/dnet/helpers.bash +++ b/libnetwork/test/integration/dnet/helpers.bash @@ -168,7 +168,8 @@ EOF -v $(pwd)/${TMPC_ROOT}:/scratch \ -v /usr/local/bin/runc:/usr/local/bin/runc \ -w /go/src/github.com/docker/libnetwork \ - golang:1.4 ./cmd/dnet/dnet -d -D ${hopt} -c ${tomlfile} + mrjana/golang ./cmd/dnet/dnet -d -D ${hopt} -c ${tomlfile} + wait_for_dnet $(inst_id2port ${inst}) ${name} } @@ -256,14 +257,16 @@ function stop_zookeeper() { function test_overlay() { dnet_suffix=$1 - shift echo $(docker ps) start=1 end=3 # Setup overlay network and connect containers ot it - dnet_cmd $(inst_id2port 1) network create -d overlay multihost + if [ -z "${2}" -o "${2}" != "skip_add" ]; then + dnet_cmd $(inst_id2port 1) network create -d overlay multihost + fi + for i in `seq ${start} ${end}`; do dnet_cmd $(inst_id2port $i) container create container_${i} @@ -273,6 +276,8 @@ function test_overlay() { # Now test connectivity between all the containers using service names for i in `seq ${start} ${end}`; do + runc $(dnet_container_name $i $dnet_suffix) $(get_sbox_id ${i} container_${i}) \ + "ping -c 1 www.google.com" for j in `seq ${start} ${end}`; do if [ "$i" -eq "$j" ]; then @@ -290,7 +295,9 @@ function test_overlay() { dnet_cmd $(inst_id2port $i) container rm container_${i} done - dnet_cmd $(inst_id2port 2) network rm multihost + if [ -z "${2}" -o "${2}" != "skip_rm" ]; then + dnet_cmd $(inst_id2port 2) network rm multihost + fi } function check_etchosts() { diff --git a/libnetwork/test/integration/dnet/overlay-consul.bats b/libnetwork/test/integration/dnet/overlay-consul.bats index 23d3ab0ca3..85a70f2af0 100644 --- a/libnetwork/test/integration/dnet/overlay-consul.bats +++ b/libnetwork/test/integration/dnet/overlay-consul.bats @@ -17,3 +17,15 @@ load helpers skip_for_circleci test_overlay_etchosts consul } + +@test "Test overlay network with dnet restart" { + skip_for_circleci + test_overlay consul skip_rm + docker restart dnet-1-consul + wait_for_dnet $(inst_id2port 1) dnet-1-consul + docker restart dnet-2-consul + wait_for_dnet $(inst_id2port 2) dnet-2-consul + docker restart dnet-3-consul + wait_for_dnet $(inst_id2port 3) dnet-3-consul + test_overlay consul skip_add +}