Merge branch 'zk_test'
This commit is contained in:
commit
a9d95c3b70
|
@ -123,7 +123,27 @@ function start_dnet() {
|
|||
|
||||
mkdir -p /tmp/dnet/${name}
|
||||
tomlfile="/tmp/dnet/${name}/libnetwork.toml"
|
||||
cat > ${tomlfile} <<EOF
|
||||
echo suffix $suffix
|
||||
if [ "$suffix" = "zookeeper" ]; then
|
||||
echo suffix equal zookeeper
|
||||
cat > ${tomlfile} <<EOF
|
||||
title = "LibNetwork Configuration file for ${name}"
|
||||
|
||||
[daemon]
|
||||
debug = false
|
||||
labels = [${labels}]
|
||||
[cluster]
|
||||
discovery = "zk://${bridge_ip}:2182"
|
||||
Heartbeat = 10
|
||||
[scopes]
|
||||
[scopes.global]
|
||||
[scopes.global.client]
|
||||
provider = "zk"
|
||||
address = "${bridge_ip}:2182"
|
||||
EOF
|
||||
else
|
||||
echo suffix equal consul
|
||||
cat > ${tomlfile} <<EOF
|
||||
title = "LibNetwork Configuration file for ${name}"
|
||||
|
||||
[daemon]
|
||||
|
@ -139,6 +159,7 @@ title = "LibNetwork Configuration file for ${name}"
|
|||
provider = "consul"
|
||||
address = "${bridge_ip}:8500"
|
||||
EOF
|
||||
fi
|
||||
docker run \
|
||||
-d \
|
||||
--name=${name} \
|
||||
|
@ -194,3 +215,59 @@ function runc() {
|
|||
dnet_exec ${dnet} "ip netns exec c unshare -fmuip --mount-proc chroot \"/scratch/rootfs\" /bin/sh -c \"/bin/mount -t proc proc /proc && ${2}\""
|
||||
dnet_exec ${dnet} "umount /var/run/netns/c && rm /var/run/netns/c"
|
||||
}
|
||||
|
||||
function start_zookeeper() {
|
||||
stop_zookeeper
|
||||
docker run -d \
|
||||
--name=zookeeper_server \
|
||||
-p 2182:2181 \
|
||||
-h zookeeper \
|
||||
dnephin/docker-zookeeper:3.4.6
|
||||
sleep 2
|
||||
}
|
||||
|
||||
function stop_zookeeper() {
|
||||
echo "zookeeper started"
|
||||
docker stop zookeeper_server || true
|
||||
# You cannot destroy a container in Circle CI. So do not attempt destroy in circleci
|
||||
if [ -z "$CIRCLECI" ]; then
|
||||
docker rm -f zookeeper_server || true
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
dnet_cmd $(inst_id2port $i) container create container_${i}
|
||||
net_connect ${i} container_${i} multihost
|
||||
done
|
||||
|
||||
# Now test connectivity between all the containers using service names
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
for j in `seq ${start} ${end}`;
|
||||
do
|
||||
if [ "$i" -eq "$j" ]; then
|
||||
continue
|
||||
fi
|
||||
runc $(dnet_container_name $i $dnet_suffix) $(get_sbox_id ${i} container_${i}) \
|
||||
"ping -c 1 container_$j"
|
||||
done
|
||||
done
|
||||
|
||||
# Teardown the container connections and the network
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
net_disconnect ${i} container_${i} multihost
|
||||
dnet_cmd $(inst_id2port $i) container rm container_${i}
|
||||
done
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
# -*- mode: sh -*-
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
@test "Test overlay network with consul" {
|
||||
skip_for_circleci
|
||||
run test_overlay consul
|
||||
[ "$status" -eq 0 ]
|
||||
run dnet_cmd $(inst_id2port 2) network rm multihost
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
# -*- mode: sh -*-
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
@test "Test overlay network with zookeeper" {
|
||||
skip_for_circleci
|
||||
run test_overlay zookeeper
|
||||
[ "$status" -eq 0 ]
|
||||
run dnet_cmd $(inst_id2port 2) network rm multihost
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
# -*- mode: sh -*-
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
@test "Test overlay network" {
|
||||
skip_for_circleci
|
||||
|
||||
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
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
dnet_cmd $(inst_id2port $i) container create container_${i}
|
||||
net_connect ${i} container_${i} multihost
|
||||
done
|
||||
|
||||
# Now test connectivity between all the containers using service names
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
for j in `seq ${start} ${end}`;
|
||||
do
|
||||
if [ "$i" -eq "$j" ]; then
|
||||
continue
|
||||
fi
|
||||
runc $(dnet_container_name $i overlay) $(get_sbox_id ${i} container_${i}) \
|
||||
"ping -c 1 container_$j"
|
||||
done
|
||||
done
|
||||
|
||||
# Teardown the container connections and the network
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
net_disconnect ${i} container_${i} multihost
|
||||
dnet_cmd $(inst_id2port $i) container rm container_${i}
|
||||
done
|
||||
|
||||
run dnet_cmd $(inst_id2port 2) network rm multihost
|
||||
}
|
|
@ -90,24 +90,48 @@ cmap[dnet-1-bridge]=dnet-1-bridge
|
|||
stop_dnet 1 bridge 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-bridge]
|
||||
|
||||
## Test overlay network with consul
|
||||
## Setup
|
||||
start_dnet 1 overlay 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-overlay]=dnet-1-overlay
|
||||
start_dnet 2 overlay 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-2-overlay]=dnet-2-overlay
|
||||
start_dnet 3 overlay 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-3-overlay]=dnet-3-overlay
|
||||
start_dnet 1 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-consul]=dnet-1-consul
|
||||
start_dnet 2 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-2-consul]=dnet-2-consul
|
||||
start_dnet 3 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-3-consul]=dnet-3-consul
|
||||
|
||||
## Run the test cases
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/overlay.bats
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/overlay-consul.bats
|
||||
|
||||
## Teardown
|
||||
stop_dnet 1 overlay 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-overlay]
|
||||
stop_dnet 2 overlay 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-2-overlay]
|
||||
stop_dnet 3 overlay 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-3-overlay]
|
||||
stop_dnet 1 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-consul]
|
||||
stop_dnet 2 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-2-consul]
|
||||
stop_dnet 3 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-3-consul]
|
||||
|
||||
## Test overlay network with zookeeper
|
||||
start_zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[zookeeper_server]=zookeeper_server
|
||||
|
||||
start_dnet 1 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-zookeeper]=dnet-1-zookeeper
|
||||
start_dnet 2 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-2-zookeeper]=dnet-2-zookeeper
|
||||
start_dnet 3 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-3-zookeeper]=dnet-3-zookeeper
|
||||
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/overlay-zookeeper.bats
|
||||
|
||||
stop_dnet 1 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-zookeeper]
|
||||
stop_dnet 2 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-2-zookeeper]
|
||||
stop_dnet 3 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-3-zookeeper]
|
||||
|
||||
stop_zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[zookeeper_server]
|
||||
|
||||
# Suite teardowm
|
||||
stop_consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
|
|
Loading…
Reference in New Issue