mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #645 from mrjana/integ
Add support for selectively running a suite
This commit is contained in:
commit
6c104e114a
2 changed files with 159 additions and 139 deletions
|
@ -84,8 +84,19 @@ function wait_for_dnet() {
|
|||
done
|
||||
}
|
||||
|
||||
function parse_discovery_str() {
|
||||
local d provider address
|
||||
discovery=$1
|
||||
provider=$(echo ${discovery} | cut -d":" -f1)
|
||||
address=$(echo ${discovery} | cut -d":" -f2):$(echo ${discovery} | cut -d":" -f3)
|
||||
address=${address:2}
|
||||
echo "${discovery} ${provider} ${address}"
|
||||
}
|
||||
|
||||
function start_dnet() {
|
||||
local inst suffix name hport cport hopt neighip bridge_ip labels tomlfile
|
||||
local inst suffix name hport cport hopt store bridge_ip labels tomlfile
|
||||
local discovery provider address
|
||||
|
||||
inst=$1
|
||||
shift
|
||||
suffix=$1
|
||||
|
@ -106,60 +117,40 @@ function start_dnet() {
|
|||
cport=$1
|
||||
hopt="-H tcp://0.0.0.0:${cport}"
|
||||
else
|
||||
neighip=$1
|
||||
store=$1
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
bridge_ip=$(docker inspect --format '{{.NetworkSettings.Gateway}}' pr_consul)
|
||||
|
||||
if [ -z "$neighip" ]; then
|
||||
labels="\"com.docker.network.driver.overlay.bind_interface=eth0\""
|
||||
else
|
||||
labels="\"com.docker.network.driver.overlay.bind_interface=eth0\", \"com.docker.network.driver.overlay.neighbor_ip=${neighip}\""
|
||||
fi
|
||||
|
||||
echo "parsed values: " ${name} ${hport} ${cport} ${hopt} ${neighip} ${labels}
|
||||
echo "start_dnet parsed values: " ${inst} ${suffix} ${name} ${hport} ${cport} ${hopt} ${store} ${labels}
|
||||
|
||||
mkdir -p /tmp/dnet/${name}
|
||||
tomlfile="/tmp/dnet/${name}/libnetwork.toml"
|
||||
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
|
||||
if [ "$store" = "zookeeper" ]; then
|
||||
read discovery provider address < <(parse_discovery_str zk://${bridge_ip}:2182)
|
||||
else
|
||||
echo suffix equal consul
|
||||
cat > ${tomlfile} <<EOF
|
||||
read discovery provider address < <(parse_discovery_str consul://${bridge_ip}:8500)
|
||||
fi
|
||||
|
||||
cat > ${tomlfile} <<EOF
|
||||
title = "LibNetwork Configuration file for ${name}"
|
||||
|
||||
[daemon]
|
||||
debug = false
|
||||
labels = [${labels}]
|
||||
[cluster]
|
||||
discovery = "consul://${bridge_ip}:8500"
|
||||
discovery = "${discovery}"
|
||||
Heartbeat = 10
|
||||
[scopes]
|
||||
[scopes.global]
|
||||
embedded = false
|
||||
[scopes.global.client]
|
||||
provider = "consul"
|
||||
address = "${bridge_ip}:8500"
|
||||
provider = "${provider}"
|
||||
address = "${address}"
|
||||
EOF
|
||||
fi
|
||||
echo $tomlfile}
|
||||
cat ${tomlfile}
|
||||
docker run \
|
||||
-d \
|
||||
--name=${name} \
|
||||
|
@ -270,4 +261,4 @@ function test_overlay() {
|
|||
net_disconnect ${i} container_${i} multihost
|
||||
dnet_cmd $(inst_id2port $i) container rm container_${i}
|
||||
done
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,20 +5,6 @@ set -e
|
|||
export INTEGRATION_ROOT=./integration-tmp
|
||||
export TMPC_ROOT=./integration-tmp/tmpc
|
||||
|
||||
if [ ! -d ${INTEGRATION_ROOT} ]; then
|
||||
mkdir -p ${INTEGRATION_ROOT}
|
||||
git clone https://github.com/sstephenson/bats.git ${INTEGRATION_ROOT}/bats
|
||||
./integration-tmp/bats/install.sh ./integration-tmp
|
||||
fi
|
||||
|
||||
if [ ! -d ${TMPC_ROOT} ]; then
|
||||
mkdir -p ${TMPC_ROOT}
|
||||
docker pull busybox:ubuntu
|
||||
docker export $(docker create busybox:ubuntu) > ${TMPC_ROOT}/busybox.tar
|
||||
mkdir -p ${TMPC_ROOT}/rootfs
|
||||
tar -C ${TMPC_ROOT}/rootfs -xf ${TMPC_ROOT}/busybox.tar
|
||||
fi
|
||||
|
||||
declare -A cmap
|
||||
|
||||
trap "cleanup_containers" EXIT SIGINT
|
||||
|
@ -35,103 +21,146 @@ function cleanup_containers() {
|
|||
unset cmap
|
||||
}
|
||||
|
||||
function run_bridge_tests() {
|
||||
## Setup
|
||||
start_dnet 1 bridge 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-bridge]=dnet-1-bridge
|
||||
|
||||
## Run the test cases
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/bridge.bats
|
||||
|
||||
## Teardown
|
||||
stop_dnet 1 bridge 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-bridge]
|
||||
}
|
||||
|
||||
function run_overlay_consul_tests() {
|
||||
## Test overlay network with consul
|
||||
## Setup
|
||||
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-consul.bats
|
||||
|
||||
## Teardown
|
||||
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]
|
||||
}
|
||||
|
||||
function run_overlay_zk_tests() {
|
||||
## 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]
|
||||
}
|
||||
|
||||
function run_dnet_tests() {
|
||||
# Test dnet configuration options
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/dnet.bats
|
||||
}
|
||||
|
||||
function run_simple_tests() {
|
||||
# Test a single node configuration with a global scope test driver
|
||||
## Setup
|
||||
start_dnet 1 simple 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-simple]=dnet-1-simple
|
||||
|
||||
## Run the test cases
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/simple.bats
|
||||
|
||||
## Teardown
|
||||
stop_dnet 1 simple 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-simple]
|
||||
}
|
||||
|
||||
function run_multi_tests() {
|
||||
# Test multi node configuration with a global scope test driver
|
||||
|
||||
## Setup
|
||||
start_dnet 1 multi 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-multi]=dnet-1-multi
|
||||
start_dnet 2 multi 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-2-multi]=dnet-2-multi
|
||||
start_dnet 3 multi 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-3-multi]=dnet-3-multi
|
||||
|
||||
## Run the test cases
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/multi.bats
|
||||
|
||||
## Teardown
|
||||
stop_dnet 1 multi 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-multi]
|
||||
stop_dnet 2 multi 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-2-multi]
|
||||
stop_dnet 3 multi 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-3-multi]
|
||||
}
|
||||
|
||||
source ./test/integration/dnet/helpers.bash
|
||||
|
||||
if [ ! -d ${INTEGRATION_ROOT} ]; then
|
||||
mkdir -p ${INTEGRATION_ROOT}
|
||||
git clone https://github.com/sstephenson/bats.git ${INTEGRATION_ROOT}/bats
|
||||
./integration-tmp/bats/install.sh ./integration-tmp
|
||||
fi
|
||||
|
||||
if [ ! -d ${TMPC_ROOT} ]; then
|
||||
mkdir -p ${TMPC_ROOT}
|
||||
docker pull busybox:ubuntu
|
||||
docker export $(docker create busybox:ubuntu) > ${TMPC_ROOT}/busybox.tar
|
||||
mkdir -p ${TMPC_ROOT}/rootfs
|
||||
tar -C ${TMPC_ROOT}/rootfs -xf ${TMPC_ROOT}/busybox.tar
|
||||
fi
|
||||
|
||||
# Suite setup
|
||||
start_consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[pr_consul]=pr_consul
|
||||
|
||||
# Test dnet configuration options
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/dnet.bats
|
||||
if [ -z "$SUITES" ]; then
|
||||
if [ -n "$CIRCLECI" ]
|
||||
then
|
||||
# We can only run a limited list of suites in circleci because of the
|
||||
# old kernel and limited docker environment.
|
||||
suites="dnet simple multi"
|
||||
else
|
||||
suites="dnet simple multi bridge overlay_consul overlay_zk"
|
||||
fi
|
||||
else
|
||||
suites="$SUITES"
|
||||
fi
|
||||
|
||||
# Test a single node configuration with a global scope test driver
|
||||
|
||||
## Setup
|
||||
start_dnet 1 simple 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-simple]=dnet-1-simple
|
||||
|
||||
## Run the test cases
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/simple.bats
|
||||
|
||||
## Teardown
|
||||
stop_dnet 1 simple 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-simple]
|
||||
|
||||
# Test multi node configuration with a global scope test driver
|
||||
|
||||
## Setup
|
||||
start_dnet 1 multi 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-multi]=dnet-1-multi
|
||||
start_dnet 2 multi 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-2-multi]=dnet-2-multi
|
||||
start_dnet 3 multi 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-3-multi]=dnet-3-multi
|
||||
|
||||
## Run the test cases
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/multi.bats
|
||||
|
||||
## Teardown
|
||||
stop_dnet 1 multi 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-multi]
|
||||
stop_dnet 2 multi 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-2-multi]
|
||||
stop_dnet 3 multi 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-3-multi]
|
||||
|
||||
## Setup
|
||||
start_dnet 1 bridge 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-bridge]=dnet-1-bridge
|
||||
|
||||
## Run the test cases
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/bridge.bats
|
||||
#docker logs dnet-1-bridge
|
||||
|
||||
## Teardown
|
||||
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 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-consul.bats
|
||||
|
||||
## Teardown
|
||||
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]
|
||||
for suite in ${suites};
|
||||
do
|
||||
suite_func=run_${suite}_tests
|
||||
declare -F $suite_func >/dev/null && $suite_func
|
||||
done
|
||||
|
||||
# Suite teardowm
|
||||
stop_consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
|
|
Loading…
Reference in a new issue