VMware vSphere Integrated Containers provider (#206)
* Add Virtual Kubelet provider for VIC Initial virtual kubelet provider for VMware VIC. This provider currently handles creating and starting of a pod VM via the VIC portlayer and persona server. Image store handling via the VIC persona server. This provider currently requires the feature/wolfpack branch of VIC. * Added pod stop and delete. Also added node capacity. Added the ability to stop and delete pod VMs via VIC. Also retrieve node capacity information from the VCH. * Cleanup and readme file Some file clean up and added a Readme.md markdown file for the VIC provider. * Cleaned up errors, added function comments, moved operation code 1. Cleaned up error handling. Set standard for creating errors. 2. Added method prototype comments for all interface functions. 3. Moved PodCreator, PodStarter, PodStopper, and PodDeleter to a new folder. * Add mocking code and unit tests for podcache, podcreator, and podstarter Used the unit test framework used in VIC to handle assertions in the provider's unit test. Mocking code generated using OSS project mockery, which is compatible with the testify assertion framework. * Vendored packages for the VIC provider Requires feature/wolfpack branch of VIC and a few specific commit sha of projects used within VIC. * Implementation of POD Stopper and Deleter unit tests (#4) * Updated files for initial PR
This commit is contained in:
34
vendor/github.com/docker/libnetwork/test/integration/README.md
generated
vendored
Normal file
34
vendor/github.com/docker/libnetwork/test/integration/README.md
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
# LibNetwork Integration Tests
|
||||
|
||||
Integration tests provide end-to-end testing of LibNetwork and Drivers.
|
||||
|
||||
While unit tests verify the code is working as expected by relying on mocks and
|
||||
artificially created fixtures, integration tests actually use real docker
|
||||
engines and communicate to it through the CLI.
|
||||
|
||||
Note that integration tests do **not** replace unit tests and Docker is used as a good use-case.
|
||||
|
||||
As a rule of thumb, code should be tested thoroughly with unit tests.
|
||||
Integration tests on the other hand are meant to test a specific feature end to end.
|
||||
|
||||
Integration tests are written in *bash* using the
|
||||
[bats](https://github.com/sstephenson/bats) framework.
|
||||
|
||||
## Pre-Requisites
|
||||
|
||||
1. Bats (https://github.com/sstephenson/bats#installing-bats-from-source)
|
||||
2. Docker Machine (https://github.com/docker/machine)
|
||||
3. Virtualbox (as a Docker machine driver)
|
||||
|
||||
## Running integration tests
|
||||
|
||||
* Start by [installing] (https://github.com/sstephenson/bats#installing-bats-from-source) *bats* on your system.
|
||||
* If not done already, [install](https://docs.docker.com/machine/) *docker-machine* into /usr/bin
|
||||
* Make sure Virtualbox is installed as well, which will be used by docker-machine as a driver to launch VMs
|
||||
|
||||
In order to run all integration tests, pass *bats* the test path:
|
||||
```
|
||||
$ bats test/integration/daemon-configs.bats
|
||||
```
|
||||
|
||||
|
||||
104
vendor/github.com/docker/libnetwork/test/integration/daemon-configs.bats
generated
vendored
Normal file
104
vendor/github.com/docker/libnetwork/test/integration/daemon-configs.bats
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
export DRIVER=virtualbox
|
||||
export NAME="bats-$DRIVER-daemon-configs"
|
||||
export MACHINE_STORAGE_PATH=/tmp/machine-bats-daemon-test-$DRIVER
|
||||
# Default memsize is 1024MB and disksize is 20000MB
|
||||
# These values are defined in drivers/virtualbox/virtualbox.go
|
||||
export DEFAULT_MEMSIZE=1024
|
||||
export DEFAULT_DISKSIZE=20000
|
||||
export CUSTOM_MEMSIZE=1536
|
||||
export CUSTOM_DISKSIZE=10000
|
||||
export CUSTOM_CPUCOUNT=1
|
||||
export BAD_URL="http://dev.null:9111/bad.iso"
|
||||
|
||||
function setup() {
|
||||
# add sleep because vbox; ugh
|
||||
sleep 1
|
||||
}
|
||||
|
||||
findDiskSize() {
|
||||
# SATA-0-0 is usually the boot2disk.iso image
|
||||
# We assume that SATA 1-0 is root disk VMDK and grab this UUID
|
||||
# e.g. "SATA-ImageUUID-1-0"="fb5f33a7-e4e3-4cb9-877c-f9415ae2adea"
|
||||
# TODO(slashk): does this work on Windows ?
|
||||
run bash -c "VBoxManage showvminfo --machinereadable $NAME | grep SATA-ImageUUID-1-0 | cut -d'=' -f2"
|
||||
run bash -c "VBoxManage showhdinfo $output | grep "Capacity:" | awk -F' ' '{ print $2 }'"
|
||||
}
|
||||
|
||||
findMemorySize() {
|
||||
run bash -c "VBoxManage showvminfo --machinereadable $NAME | grep memory= | cut -d'=' -f2"
|
||||
}
|
||||
|
||||
findCPUCount() {
|
||||
run bash -c "VBoxManage showvminfo --machinereadable $NAME | grep cpus= | cut -d'=' -f2"
|
||||
}
|
||||
|
||||
buildMachineWithOldIsoCheckUpgrade() {
|
||||
run wget https://github.com/boot2docker/boot2docker/releases/download/v1.4.1/boot2docker.iso -O $MACHINE_STORAGE_PATH/cache/boot2docker.iso
|
||||
run machine create -d virtualbox $NAME
|
||||
run machine upgrade $NAME
|
||||
}
|
||||
|
||||
@test "$DRIVER: machine should not exist" {
|
||||
run machine active $NAME
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "$DRIVER: VM should not exist" {
|
||||
run VBoxManage showvminfo $NAME
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "$DRIVER: create" {
|
||||
run machine create -d $DRIVER $NAME
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "$DRIVER: active" {
|
||||
run machine active $NAME
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "$DRIVER: check default machine memory size" {
|
||||
findMemorySize
|
||||
[[ ${output} == "${DEFAULT_MEMSIZE}" ]]
|
||||
}
|
||||
|
||||
@test "$DRIVER: check default machine disksize" {
|
||||
findDiskSize
|
||||
[[ ${output} == *"$DEFAULT_DISKSIZE"* ]]
|
||||
}
|
||||
|
||||
@test "$DRIVER: test bridge-ip" {
|
||||
run machine ssh $NAME sudo /etc/init.d/docker stop
|
||||
run machine ssh $NAME sudo ifconfig docker0 down
|
||||
run machine ssh $NAME sudo ip link delete docker0
|
||||
BIP='--bip=172.168.45.1/24'
|
||||
set_extra_config $BIP
|
||||
cat ${TMP_EXTRA_ARGS_FILE} | machine ssh $NAME sudo tee /var/lib/boot2docker/profile
|
||||
cat ${DAEMON_CFG_FILE} | machine ssh $NAME "sudo tee -a /var/lib/boot2docker/profile"
|
||||
run machine ssh $NAME sudo /etc/init.d/docker start
|
||||
run machine ssh $NAME ifconfig docker0
|
||||
[ "$status" -eq 0 ]
|
||||
[[ ${lines[1]} =~ "172.168.45.1" ]]
|
||||
}
|
||||
|
||||
@test "$DRIVER: run busybox container" {
|
||||
run machine ssh $NAME sudo cat /var/lib/boot2docker/profile
|
||||
run docker $(machine config $NAME) run busybox echo hello world
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "$DRIVER: remove machine" {
|
||||
run machine rm -f $NAME
|
||||
}
|
||||
|
||||
# Cleanup of machine store should always be the last 'test'
|
||||
@test "$DRIVER: cleanup" {
|
||||
run rm -rf $MACHINE_STORAGE_PATH
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
4
vendor/github.com/docker/libnetwork/test/integration/daemon.cfg
generated
vendored
Normal file
4
vendor/github.com/docker/libnetwork/test/integration/daemon.cfg
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
CACERT=/var/lib/boot2docker/ca.pem
|
||||
SERVERCERT=/var/lib/boot2docker/server-key.pem
|
||||
SERVERKEY=/var/lib/boot2docker/server.pem
|
||||
DOCKER_TLS=no
|
||||
305
vendor/github.com/docker/libnetwork/test/integration/dnet/bridge.bats
generated
vendored
Normal file
305
vendor/github.com/docker/libnetwork/test/integration/dnet/bridge.bats
generated
vendored
Normal file
@@ -0,0 +1,305 @@
|
||||
# -*- mode: sh -*-
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
function test_single_network_connectivity() {
|
||||
local nw_name start end
|
||||
|
||||
nw_name=${1}
|
||||
start=1
|
||||
end=${2}
|
||||
|
||||
# Create containers and connect them to the network
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
dnet_cmd $(inst_id2port 1) container create container_${i}
|
||||
net_connect 1 container_${i} ${nw_name}
|
||||
done
|
||||
|
||||
# Now test connectivity between all the containers using service names
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
if [ "${nw_name}" != "internal" ]; then
|
||||
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_${i}) \
|
||||
"ping -c 1 www.google.com"
|
||||
fi
|
||||
for j in `seq ${start} ${end}`;
|
||||
do
|
||||
if [ "$i" -eq "$j" ]; then
|
||||
continue
|
||||
fi
|
||||
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_${i}) \
|
||||
"ping -c 1 container_${j}"
|
||||
done
|
||||
done
|
||||
|
||||
if [ -n "$3" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Teardown the container connections and the network
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
net_disconnect 1 container_${i} ${nw_name}
|
||||
dnet_cmd $(inst_id2port 1) container rm container_${i}
|
||||
done
|
||||
}
|
||||
|
||||
@test "Test default bridge network" {
|
||||
skip_for_circleci
|
||||
|
||||
echo $(docker ps)
|
||||
test_single_network_connectivity bridge 3
|
||||
}
|
||||
|
||||
|
||||
@test "Test default network dnet restart" {
|
||||
skip_for_circleci
|
||||
|
||||
echo $(docker ps)
|
||||
|
||||
for iter in `seq 1 2`;
|
||||
do
|
||||
test_single_network_connectivity bridge 3
|
||||
if [ "$iter" -eq 1 ]; then
|
||||
docker restart dnet-1-bridge
|
||||
wait_for_dnet $(inst_id2port 1) dnet-1-bridge
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
@test "Test default network dnet ungraceful restart" {
|
||||
skip_for_circleci
|
||||
|
||||
echo $(docker ps)
|
||||
|
||||
for iter in `seq 1 2`;
|
||||
do
|
||||
if [ "$iter" -eq 1 ]; then
|
||||
test_single_network_connectivity bridge 3 skip
|
||||
docker restart dnet-1-bridge
|
||||
wait_for_dnet $(inst_id2port 1) dnet-1-bridge
|
||||
else
|
||||
test_single_network_connectivity bridge 3
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
@test "Test bridge network" {
|
||||
skip_for_circleci
|
||||
|
||||
echo $(docker ps)
|
||||
dnet_cmd $(inst_id2port 1) network create -d bridge singlehost
|
||||
test_single_network_connectivity singlehost 3
|
||||
dnet_cmd $(inst_id2port 1) network rm singlehost
|
||||
}
|
||||
|
||||
@test "Test bridge network dnet restart" {
|
||||
skip_for_circleci
|
||||
|
||||
echo $(docker ps)
|
||||
dnet_cmd $(inst_id2port 1) network create -d bridge singlehost
|
||||
|
||||
for iter in `seq 1 2`;
|
||||
do
|
||||
test_single_network_connectivity singlehost 3
|
||||
if [ "$iter" -eq 1 ]; then
|
||||
docker restart dnet-1-bridge
|
||||
wait_for_dnet $(inst_id2port 1) dnet-1-bridge
|
||||
fi
|
||||
done
|
||||
|
||||
dnet_cmd $(inst_id2port 1) network rm singlehost
|
||||
}
|
||||
|
||||
@test "Test bridge network dnet ungraceful restart" {
|
||||
skip_for_circleci
|
||||
|
||||
echo $(docker ps)
|
||||
dnet_cmd $(inst_id2port 1) network create -d bridge singlehost
|
||||
|
||||
for iter in `seq 1 2`;
|
||||
do
|
||||
if [ "$iter" -eq 1 ]; then
|
||||
test_single_network_connectivity singlehost 3 skip
|
||||
docker restart dnet-1-bridge
|
||||
wait_for_dnet $(inst_id2port 1) dnet-1-bridge
|
||||
else
|
||||
test_single_network_connectivity singlehost 3
|
||||
fi
|
||||
done
|
||||
|
||||
dnet_cmd $(inst_id2port 1) network rm singlehost
|
||||
}
|
||||
|
||||
@test "Test multiple bridge networks" {
|
||||
skip_for_circleci
|
||||
|
||||
echo $(docker ps)
|
||||
|
||||
start=1
|
||||
end=3
|
||||
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
dnet_cmd $(inst_id2port 1) container create container_${i}
|
||||
for j in `seq ${start} ${end}`;
|
||||
do
|
||||
if [ "$i" -eq "$j" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$i" -lt "$j" ]; then
|
||||
dnet_cmd $(inst_id2port 1) network create -d bridge sh${i}${j}
|
||||
nw=sh${i}${j}
|
||||
else
|
||||
nw=sh${j}${i}
|
||||
fi
|
||||
|
||||
osvc="svc${i}${j}"
|
||||
dnet_cmd $(inst_id2port 1) service publish ${osvc}.${nw}
|
||||
dnet_cmd $(inst_id2port 1) service attach container_${i} ${osvc}.${nw}
|
||||
done
|
||||
done
|
||||
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
echo ${i1}
|
||||
for j in `seq ${start} ${end}`;
|
||||
do
|
||||
echo ${j1}
|
||||
if [ "$i" -eq "$j" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
osvc="svc${j}${i}"
|
||||
echo "pinging ${osvc}"
|
||||
dnet_cmd $(inst_id2port 1) service ls
|
||||
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_${i}) "cat /etc/hosts"
|
||||
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_${i}) "ping -c 1 ${osvc}"
|
||||
done
|
||||
done
|
||||
|
||||
svcs=(
|
||||
0,0
|
||||
2,3
|
||||
1,3
|
||||
1,2
|
||||
)
|
||||
|
||||
echo "Test connectivity failure"
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
IFS=, read a b <<<"${svcs[$i]}"
|
||||
osvc="svc${a}${b}"
|
||||
echo "pinging ${osvc}"
|
||||
runc_nofail $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_${i}) "ping -c 1 ${osvc}"
|
||||
[ "${status}" -ne 0 ]
|
||||
done
|
||||
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
for j in `seq ${start} ${end}`;
|
||||
do
|
||||
if [ "$i" -eq "$j" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$i" -lt "$j" ]; then
|
||||
nw=sh${i}${j}
|
||||
else
|
||||
nw=sh${j}${i}
|
||||
fi
|
||||
|
||||
osvc="svc${i}${j}"
|
||||
dnet_cmd $(inst_id2port 1) service detach container_${i} ${osvc}.${nw}
|
||||
dnet_cmd $(inst_id2port 1) service unpublish ${osvc}.${nw}
|
||||
|
||||
done
|
||||
dnet_cmd $(inst_id2port 1) container rm container_${i}
|
||||
done
|
||||
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
for j in `seq ${start} ${end}`;
|
||||
do
|
||||
if [ "$i" -eq "$j" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$i" -lt "$j" ]; then
|
||||
dnet_cmd $(inst_id2port 1) network rm sh${i}${j}
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
@test "Test bridge network alias support" {
|
||||
skip_for_circleci
|
||||
dnet_cmd $(inst_id2port 1) network create -d bridge br1
|
||||
dnet_cmd $(inst_id2port 1) container create container_1
|
||||
net_connect 1 container_1 br1 container_2:c2
|
||||
dnet_cmd $(inst_id2port 1) container create container_2
|
||||
net_connect 1 container_2 br1
|
||||
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_1) "ping -c 1 container_2"
|
||||
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_1) "ping -c 1 c2"
|
||||
net_disconnect 1 container_1 br1
|
||||
net_disconnect 1 container_2 br1
|
||||
dnet_cmd $(inst_id2port 1) container rm container_1
|
||||
dnet_cmd $(inst_id2port 1) container rm container_2
|
||||
dnet_cmd $(inst_id2port 1) network rm br1
|
||||
}
|
||||
|
||||
|
||||
@test "Test bridge network global alias support" {
|
||||
skip_for_circleci
|
||||
dnet_cmd $(inst_id2port 1) network create -d bridge br1
|
||||
dnet_cmd $(inst_id2port 1) network create -d bridge br2
|
||||
dnet_cmd $(inst_id2port 1) container create container_1
|
||||
net_connect 1 container_1 br1 : c1
|
||||
dnet_cmd $(inst_id2port 1) container create container_2
|
||||
net_connect 1 container_2 br1 : shared
|
||||
dnet_cmd $(inst_id2port 1) container create container_3
|
||||
net_connect 1 container_3 br1 : shared
|
||||
|
||||
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_2) "ping -c 1 container_1"
|
||||
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_2) "ping -c 1 c1"
|
||||
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_1) "ping -c 1 container_2"
|
||||
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_1) "ping -c 1 shared"
|
||||
|
||||
net_disconnect 1 container_2 br1
|
||||
dnet_cmd $(inst_id2port 1) container rm container_2
|
||||
|
||||
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_1) "ping -c 1 container_3"
|
||||
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_1) "ping -c 1 shared"
|
||||
|
||||
net_disconnect 1 container_1 br1
|
||||
dnet_cmd $(inst_id2port 1) container rm container_1
|
||||
net_disconnect 1 container_3 br1
|
||||
dnet_cmd $(inst_id2port 1) container rm container_3
|
||||
|
||||
dnet_cmd $(inst_id2port 1) network rm br1
|
||||
}
|
||||
|
||||
@test "Test bridge network internal network" {
|
||||
skip_for_circleci
|
||||
|
||||
echo $(docker ps)
|
||||
dnet_cmd $(inst_id2port 1) network create -d bridge --internal internal
|
||||
dnet_cmd $(inst_id2port 1) container create container_1
|
||||
# connects to internal network, confirm it can't conmunicate with outside world
|
||||
net_connect 1 container_1 internal
|
||||
run runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_1) "ping -c 1 www.google.com"
|
||||
[[ "$output" == *"1 packets transmitted, 0 packets received, 100% packet loss"* ]]
|
||||
net_disconnect 1 container_1 internal
|
||||
# connects to bridge network, confirm it can conmunicate with outside world
|
||||
net_connect 1 container_1 bridge
|
||||
runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_1) "ping -c 1 www.google.com"
|
||||
net_disconnect 1 container_1 bridge
|
||||
dnet_cmd $(inst_id2port 1) container rm container_1
|
||||
# test conmunications within internal network
|
||||
test_single_network_connectivity internal 3
|
||||
dnet_cmd $(inst_id2port 1) network rm internal
|
||||
}
|
||||
31
vendor/github.com/docker/libnetwork/test/integration/dnet/dnet.bats
generated
vendored
Normal file
31
vendor/github.com/docker/libnetwork/test/integration/dnet/dnet.bats
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
@test "Test dnet custom port" {
|
||||
start_dnet 1 a 4567
|
||||
dnet_cmd 4567 network ls
|
||||
stop_dnet 1 a
|
||||
}
|
||||
|
||||
@test "Test dnet invalid custom port" {
|
||||
start_dnet 1 b 4567
|
||||
run dnet_cmd 4568 network ls
|
||||
echo ${output}
|
||||
[ "$status" -ne 0 ]
|
||||
stop_dnet 1 b
|
||||
}
|
||||
|
||||
@test "Test dnet invalid params" {
|
||||
start_dnet 1 c
|
||||
run dnet_cmd 8080 network ls
|
||||
echo ${output}
|
||||
[ "$status" -ne 0 ]
|
||||
run ./bin/dnet -H=unix://var/run/dnet.sock network ls
|
||||
echo ${output}
|
||||
[ "$status" -ne 0 ]
|
||||
run ./bin/dnet -H= -l=invalid network ls
|
||||
echo ${output}
|
||||
[ "$status" -ne 0 ]
|
||||
stop_dnet 1 c
|
||||
}
|
||||
480
vendor/github.com/docker/libnetwork/test/integration/dnet/helpers.bash
generated
vendored
Normal file
480
vendor/github.com/docker/libnetwork/test/integration/dnet/helpers.bash
generated
vendored
Normal file
@@ -0,0 +1,480 @@
|
||||
function get_docker_bridge_ip() {
|
||||
echo $(docker run --rm -it busybox ip route show | grep default | cut -d" " -f3)
|
||||
}
|
||||
|
||||
function inst_id2port() {
|
||||
echo $((41000+${1}-1))
|
||||
}
|
||||
|
||||
function dnet_container_name() {
|
||||
echo dnet-$1-$2
|
||||
}
|
||||
|
||||
function get_sbox_id() {
|
||||
local line
|
||||
|
||||
line=$(dnet_cmd $(inst_id2port ${1}) service ls | grep ${2})
|
||||
echo ${line} | cut -d" " -f5
|
||||
}
|
||||
|
||||
function net_connect() {
|
||||
local al gl
|
||||
if [ -n "$4" ]; then
|
||||
if [ "${4}" != ":" ]; then
|
||||
al="--alias=${4}"
|
||||
fi
|
||||
fi
|
||||
if [ -n "$5" ]; then
|
||||
gl="--alias=${5}"
|
||||
fi
|
||||
dnet_cmd $(inst_id2port ${1}) service publish $gl ${2}.${3}
|
||||
dnet_cmd $(inst_id2port ${1}) service attach $al ${2} ${2}.${3}
|
||||
}
|
||||
|
||||
function net_disconnect() {
|
||||
dnet_cmd $(inst_id2port ${1}) service detach ${2} ${2}.${3}
|
||||
dnet_cmd $(inst_id2port ${1}) service unpublish ${2}.${3}
|
||||
}
|
||||
|
||||
function start_consul() {
|
||||
stop_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() {
|
||||
echo "consul started"
|
||||
docker stop pr_consul || true
|
||||
# You cannot destroy a container in Circle CI. So do not attempt destroy in circleci
|
||||
if [ -z "$CIRCLECI" ]; then
|
||||
docker rm -f pr_consul || true
|
||||
fi
|
||||
}
|
||||
|
||||
hrun() {
|
||||
local e E T oldIFS
|
||||
[[ ! "$-" =~ e ]] || e=1
|
||||
[[ ! "$-" =~ E ]] || E=1
|
||||
[[ ! "$-" =~ T ]] || T=1
|
||||
set +e
|
||||
set +E
|
||||
set +T
|
||||
output="$("$@" 2>&1)"
|
||||
status="$?"
|
||||
oldIFS=$IFS
|
||||
IFS=$'\n' lines=($output)
|
||||
[ -z "$e" ] || set -e
|
||||
[ -z "$E" ] || set -E
|
||||
[ -z "$T" ] || set -T
|
||||
IFS=$oldIFS
|
||||
}
|
||||
|
||||
function wait_for_dnet() {
|
||||
local hport
|
||||
|
||||
hport=$1
|
||||
echo "waiting on dnet to come up ..."
|
||||
for i in `seq 1 10`;
|
||||
do
|
||||
hrun ./bin/dnet -H tcp://127.0.0.1:${hport} network ls
|
||||
echo ${output}
|
||||
if [ "$status" -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "${lines[1]}" =~ .*EOF.* ]]
|
||||
then
|
||||
docker logs ${2}
|
||||
fi
|
||||
echo "still waiting after ${i} seconds"
|
||||
sleep 1
|
||||
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 store bridge_ip labels tomlfile
|
||||
local discovery provider address
|
||||
|
||||
inst=$1
|
||||
shift
|
||||
suffix=$1
|
||||
shift
|
||||
|
||||
stop_dnet ${inst} ${suffix}
|
||||
name=$(dnet_container_name ${inst} ${suffix})
|
||||
|
||||
hport=$((41000+${inst}-1))
|
||||
cport=2385
|
||||
hopt=""
|
||||
store=${suffix}
|
||||
|
||||
while [ -n "$1" ]
|
||||
do
|
||||
if [[ "$1" =~ ^[0-9]+$ ]]
|
||||
then
|
||||
hport=$1
|
||||
cport=$1
|
||||
hopt="-H tcp://0.0.0.0:${cport}"
|
||||
else
|
||||
store=$1
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
bridge_ip=$(get_docker_bridge_ip)
|
||||
|
||||
echo "start_dnet parsed values: " ${inst} ${suffix} ${name} ${hport} ${cport} ${hopt} ${store} ${labels}
|
||||
|
||||
mkdir -p /tmp/dnet/${name}
|
||||
tomlfile="/tmp/dnet/${name}/libnetwork.toml"
|
||||
|
||||
# Try discovery URLs with or without path
|
||||
if [ "$store" = "zookeeper" ]; then
|
||||
read discovery provider address < <(parse_discovery_str zk://${bridge_ip}:2182)
|
||||
elif [ "$store" = "etcd" ]; then
|
||||
read discovery provider address < <(parse_discovery_str etcd://${bridge_ip}:42000/custom_prefix)
|
||||
else
|
||||
read discovery provider address < <(parse_discovery_str consul://${bridge_ip}:8500/custom_prefix)
|
||||
fi
|
||||
|
||||
cat > ${tomlfile} <<EOF
|
||||
title = "LibNetwork Configuration file for ${name}"
|
||||
|
||||
[daemon]
|
||||
debug = false
|
||||
[cluster]
|
||||
discovery = "${discovery}"
|
||||
Heartbeat = 10
|
||||
[scopes]
|
||||
[scopes.global]
|
||||
[scopes.global.client]
|
||||
provider = "${provider}"
|
||||
address = "${address}"
|
||||
EOF
|
||||
cat ${tomlfile}
|
||||
docker run \
|
||||
-d \
|
||||
--name=${name} \
|
||||
--privileged \
|
||||
-p ${hport}:${cport} \
|
||||
-e _OVERLAY_HOST_MODE \
|
||||
-v $(pwd)/:/go/src/github.com/docker/libnetwork \
|
||||
-v /tmp:/tmp \
|
||||
-v $(pwd)/${TMPC_ROOT}:/scratch \
|
||||
-v /usr/local/bin/runc:/usr/local/bin/runc \
|
||||
-w /go/src/github.com/docker/libnetwork \
|
||||
mrjana/golang ./bin/dnet -d -D ${hopt} -c ${tomlfile}
|
||||
|
||||
wait_for_dnet $(inst_id2port ${inst}) ${name}
|
||||
}
|
||||
|
||||
function skip_for_circleci() {
|
||||
if [ -n "$CIRCLECI" ]; then
|
||||
skip
|
||||
fi
|
||||
}
|
||||
|
||||
function stop_dnet() {
|
||||
local name
|
||||
|
||||
name=$(dnet_container_name $1 $2)
|
||||
rm -rf /tmp/dnet/${name} || true
|
||||
docker stop ${name} || true
|
||||
# You cannot destroy a container in Circle CI. So do not attempt destroy in circleci
|
||||
if [ -z "$CIRCLECI" ]; then
|
||||
docker rm -f ${name} || true
|
||||
fi
|
||||
}
|
||||
|
||||
function dnet_cmd() {
|
||||
local hport
|
||||
|
||||
hport=$1
|
||||
shift
|
||||
./bin/dnet -H tcp://127.0.0.1:${hport} $*
|
||||
}
|
||||
|
||||
function dnet_exec() {
|
||||
docker exec -it ${1} bash -c "$2"
|
||||
}
|
||||
|
||||
function runc() {
|
||||
local dnet
|
||||
|
||||
dnet=${1}
|
||||
shift
|
||||
dnet_exec ${dnet} "cp /var/lib/docker/network/files/${1}*/* /scratch/rootfs/etc"
|
||||
dnet_exec ${dnet} "mkdir -p /var/run/netns"
|
||||
dnet_exec ${dnet} "touch /var/run/netns/c && mount -o bind /var/run/docker/netns/${1} /var/run/netns/c"
|
||||
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 runc_nofail() {
|
||||
local dnet
|
||||
|
||||
dnet=${1}
|
||||
shift
|
||||
dnet_exec ${dnet} "cp /var/lib/docker/network/files/${1}*/* /scratch/rootfs/etc"
|
||||
dnet_exec ${dnet} "mkdir -p /var/run/netns"
|
||||
dnet_exec ${dnet} "touch /var/run/netns/c && mount -o bind /var/run/docker/netns/${1} /var/run/netns/c"
|
||||
set +e
|
||||
dnet_exec ${dnet} "ip netns exec c unshare -fmuip --mount-proc chroot \"/scratch/rootfs\" /bin/sh -c \"/bin/mount -t proc proc /proc && ${2}\""
|
||||
status="$?"
|
||||
set -e
|
||||
dnet_exec ${dnet} "umount /var/run/netns/c && rm /var/run/netns/c"
|
||||
}
|
||||
|
||||
function start_etcd() {
|
||||
local bridge_ip
|
||||
stop_etcd
|
||||
|
||||
bridge_ip=$(get_docker_bridge_ip)
|
||||
docker run -d \
|
||||
--net=host \
|
||||
--name=dn_etcd \
|
||||
mrjana/etcd --listen-client-urls http://0.0.0.0:42000 \
|
||||
--advertise-client-urls http://${bridge_ip}:42000
|
||||
sleep 2
|
||||
}
|
||||
|
||||
function stop_etcd() {
|
||||
docker stop dn_etcd || true
|
||||
# You cannot destroy a container in Circle CI. So do not attempt destroy in circleci
|
||||
if [ -z "$CIRCLECI" ]; then
|
||||
docker rm -f dn_etcd || true
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
echo $(docker ps)
|
||||
|
||||
start=1
|
||||
end=3
|
||||
# Setup overlay network and connect containers ot it
|
||||
if [ -z "${2}" -o "${2}" != "skip_add" ]; then
|
||||
if [ -z "${2}" -o "${2}" != "internal" ]; then
|
||||
dnet_cmd $(inst_id2port 1) network create -d overlay multihost
|
||||
else
|
||||
dnet_cmd $(inst_id2port 1) network create -d overlay --internal multihost
|
||||
fi
|
||||
fi
|
||||
|
||||
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
|
||||
if [ -z "${2}" -o "${2}" != "internal" ]; then
|
||||
runc $(dnet_container_name $i $dnet_suffix) $(get_sbox_id ${i} container_${i}) \
|
||||
"ping -c 1 www.google.com"
|
||||
else
|
||||
default_route=`runc $(dnet_container_name $i $dnet_suffix) $(get_sbox_id ${i} container_${i}) "ip route | grep default"`
|
||||
[ "$default_route" = "" ]
|
||||
fi
|
||||
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
|
||||
|
||||
if [ -z "${2}" -o "${2}" != "skip_rm" ]; then
|
||||
dnet_cmd $(inst_id2port 2) network rm multihost
|
||||
fi
|
||||
}
|
||||
|
||||
function check_etchosts() {
|
||||
local dnet sbid retval
|
||||
dnet=${1}
|
||||
shift
|
||||
sbid=${1}
|
||||
shift
|
||||
|
||||
retval="true"
|
||||
|
||||
for i in $*;
|
||||
do
|
||||
run runc ${dnet} ${sbid} "cat /etc/hosts"
|
||||
if [ "$status" -ne 0 ]; then
|
||||
retval="${output}"
|
||||
break
|
||||
fi
|
||||
|
||||
line=$(echo ${output} | grep ${i})
|
||||
if [ "${line}" == "" ]; then
|
||||
retval="false"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ${retval}
|
||||
}
|
||||
|
||||
function test_overlay_singlehost() {
|
||||
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 1) container create container_${i}
|
||||
net_connect 1 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 1 $dnet_suffix) $(get_sbox_id 1 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 1 container_${i} multihost
|
||||
dnet_cmd $(inst_id2port 1) container rm container_${i}
|
||||
done
|
||||
|
||||
dnet_cmd $(inst_id2port 1) network rm multihost
|
||||
}
|
||||
|
||||
function test_overlay_hostmode() {
|
||||
dnet_suffix=$1
|
||||
shift
|
||||
|
||||
echo $(docker ps)
|
||||
|
||||
start=1
|
||||
end=2
|
||||
# Setup overlay network and connect containers ot it
|
||||
dnet_cmd $(inst_id2port 1) network create -d overlay multihost1
|
||||
dnet_cmd $(inst_id2port 1) network create -d overlay multihost2
|
||||
dnet_cmd $(inst_id2port 1) network ls
|
||||
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
dnet_cmd $(inst_id2port 1) container create mh1_${i}
|
||||
net_connect 1 mh1_${i} multihost1
|
||||
done
|
||||
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
dnet_cmd $(inst_id2port 1) container create mh2_${i}
|
||||
net_connect 1 mh2_${i} multihost2
|
||||
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
|
||||
|
||||
# Find the IP addresses of the j containers on both networks
|
||||
hrun runc $(dnet_container_name 1 $dnet_suffix) $(get_sbox_id 1 mh1_${i}) "nslookup mh1_$j"
|
||||
mh1_j_ip=$(echo ${output} | awk '{print $11}')
|
||||
|
||||
hrun runc $(dnet_container_name 1 $dnet_suffix) $(get_sbox_id 1 mh2_${i}) "nslookup mh2_$j"
|
||||
mh2_j_ip=$(echo ${output} | awk '{print $11}')
|
||||
|
||||
# Ping the j containers in the same network and ensure they are successfull
|
||||
runc $(dnet_container_name 1 $dnet_suffix) $(get_sbox_id 1 mh1_${i}) \
|
||||
"ping -c 1 mh1_$j"
|
||||
runc $(dnet_container_name 1 $dnet_suffix) $(get_sbox_id 1 mh2_${i}) \
|
||||
"ping -c 1 mh2_$j"
|
||||
|
||||
# Try pinging j container IPs from the container in the other network and make sure that they are not successfull
|
||||
runc_nofail $(dnet_container_name 1 $dnet_suffix) $(get_sbox_id 1 mh1_${i}) "ping -c 1 ${mh2_j_ip}"
|
||||
[ "${status}" -ne 0 ]
|
||||
|
||||
runc_nofail $(dnet_container_name 1 $dnet_suffix) $(get_sbox_id 1 mh2_${i}) "ping -c 1 ${mh1_j_ip}"
|
||||
[ "${status}" -ne 0 ]
|
||||
|
||||
# Try pinging the j container IPS from the host(dnet container in this case) and make syre that they are not successfull
|
||||
hrun docker exec -it $(dnet_container_name 1 $dnet_suffix) "ping -c 1 ${mh1_j_ip}"
|
||||
[ "${status}" -ne 0 ]
|
||||
|
||||
hrun docker exec -it $(dnet_container_name 1 $dnet_suffix) "ping -c 1 ${mh2_j_ip}"
|
||||
[ "${status}" -ne 0 ]
|
||||
done
|
||||
done
|
||||
|
||||
# Teardown the container connections and the network
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
net_disconnect 1 mh1_${i} multihost1
|
||||
dnet_cmd $(inst_id2port 1) container rm mh1_${i}
|
||||
done
|
||||
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
net_disconnect 1 mh2_${i} multihost2
|
||||
dnet_cmd $(inst_id2port 1) container rm mh2_${i}
|
||||
done
|
||||
|
||||
dnet_cmd $(inst_id2port 1) network rm multihost1
|
||||
dnet_cmd $(inst_id2port 1) network rm multihost2
|
||||
}
|
||||
130
vendor/github.com/docker/libnetwork/test/integration/dnet/multi.bats
generated
vendored
Normal file
130
vendor/github.com/docker/libnetwork/test/integration/dnet/multi.bats
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
# -*- mode: sh -*-
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
function is_network_exist() {
|
||||
line=$(dnet_cmd $(inst_id2port $1) network ls | grep ${2})
|
||||
name=$(echo ${line} | cut -d" " -f2)
|
||||
driver=$(echo ${line} | cut -d" " -f3)
|
||||
if [ "$name" == "$2" -a "$driver" == "$3" ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
@test "Test multinode network create" {
|
||||
echo $(docker ps)
|
||||
for i in `seq 1 3`;
|
||||
do
|
||||
oname="mh$i"
|
||||
run dnet_cmd $(inst_id2port $i) network create -d test ${oname}
|
||||
echo ${output}
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
for j in `seq 1 3`;
|
||||
do
|
||||
result=$(is_network_exist $j ${oname} test)
|
||||
[ "$result" = "true" ]
|
||||
done
|
||||
|
||||
# Always try to remove the network from the second node
|
||||
dnet_cmd $(inst_id2port 2) network rm ${oname}
|
||||
echo "delete ${oname}"
|
||||
nresult=$(is_network_exist 1 ${oname} test)
|
||||
echo ${nresult}
|
||||
dnet_cmd $(inst_id2port 1) network ls
|
||||
[ "$nresult" = "false" ]
|
||||
done
|
||||
}
|
||||
|
||||
@test "Test multinode service create" {
|
||||
echo $(docker ps)
|
||||
dnet_cmd $(inst_id2port 1) network create -d test multihost
|
||||
for i in `seq 1 3`;
|
||||
do
|
||||
oname="svc$i"
|
||||
run dnet_cmd $(inst_id2port $i) service publish ${oname}.multihost
|
||||
echo ${output}
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
for j in `seq 1 3`;
|
||||
do
|
||||
run dnet_cmd $(inst_id2port $j) service ls
|
||||
[ "$status" -eq 0 ]
|
||||
echo ${output}
|
||||
echo ${lines[1]}
|
||||
svc=$(echo ${lines[1]} | cut -d" " -f2)
|
||||
network=$(echo ${lines[1]} | cut -d" " -f3)
|
||||
echo ${svc} ${network}
|
||||
[ "$network" = "multihost" ]
|
||||
[ "$svc" = "${oname}" ]
|
||||
done
|
||||
dnet_cmd $(inst_id2port 2) service unpublish ${oname}.multihost
|
||||
done
|
||||
dnet_cmd $(inst_id2port 3) network rm multihost
|
||||
}
|
||||
|
||||
@test "Test multinode service attach" {
|
||||
echo $(docker ps)
|
||||
dnet_cmd $(inst_id2port 2) network create -d test multihost
|
||||
dnet_cmd $(inst_id2port 3) service publish svc.multihost
|
||||
for i in `seq 1 3`;
|
||||
do
|
||||
dnet_cmd $(inst_id2port $i) container create container_${i}
|
||||
dnet_cmd $(inst_id2port $i) service attach container_${i} svc.multihost
|
||||
run dnet_cmd $(inst_id2port $i) service ls
|
||||
[ "$status" -eq 0 ]
|
||||
echo ${output}
|
||||
echo ${lines[1]}
|
||||
container=$(echo ${lines[1]} | cut -d" " -f4)
|
||||
[ "$container" = "container_$i" ]
|
||||
for j in `seq 1 3`;
|
||||
do
|
||||
if [ "$j" = "$i" ]; then
|
||||
continue
|
||||
fi
|
||||
dnet_cmd $(inst_id2port $j) container create container_${j}
|
||||
run dnet_cmd $(inst_id2port $j) service attach container_${j} svc.multihost
|
||||
echo ${output}
|
||||
[ "$status" -ne 0 ]
|
||||
dnet_cmd $(inst_id2port $j) container rm container_${j}
|
||||
done
|
||||
dnet_cmd $(inst_id2port $i) service detach container_${i} svc.multihost
|
||||
dnet_cmd $(inst_id2port $i) container rm container_${i}
|
||||
done
|
||||
dnet_cmd $(inst_id2port 1) service unpublish svc.multihost
|
||||
dnet_cmd $(inst_id2port 3) network rm multihost
|
||||
}
|
||||
|
||||
@test "Test multinode network and service delete" {
|
||||
echo $(docker ps)
|
||||
for i in `seq 1 3`;
|
||||
do
|
||||
oname="mh$i"
|
||||
osvc="svc$i"
|
||||
dnet_cmd $(inst_id2port $i) network create -d test ${oname}
|
||||
dnet_cmd $(inst_id2port $i) service publish ${osvc}.${oname}
|
||||
dnet_cmd $(inst_id2port $i) container create container_${i}
|
||||
dnet_cmd $(inst_id2port $i) network ls
|
||||
dnet_cmd $(inst_id2port $i) service attach container_${i} ${osvc}.${oname}
|
||||
|
||||
for j in `seq 1 3`;
|
||||
do
|
||||
run dnet_cmd $(inst_id2port $i) service unpublish ${osvc}.${oname}
|
||||
echo ${output}
|
||||
[ "$status" -ne 0 ]
|
||||
run dnet_cmd $(inst_id2port $j) network rm ${oname}
|
||||
echo ${output}
|
||||
[ "$status" -ne 0 ]
|
||||
done
|
||||
|
||||
dnet_cmd $(inst_id2port $i) service detach container_${i} ${osvc}.${oname}
|
||||
dnet_cmd $(inst_id2port $i) container rm container_${i}
|
||||
|
||||
# Always try to remove the service from different nodes
|
||||
dnet_cmd $(inst_id2port 2) service unpublish ${osvc}.${oname}
|
||||
dnet_cmd $(inst_id2port 3) network rm ${oname}
|
||||
done
|
||||
}
|
||||
9
vendor/github.com/docker/libnetwork/test/integration/dnet/overlay-consul-host.bats
generated
vendored
Normal file
9
vendor/github.com/docker/libnetwork/test/integration/dnet/overlay-consul-host.bats
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# -*- mode: sh -*-
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
@test "Test overlay network hostmode with consul" {
|
||||
skip_for_circleci
|
||||
test_overlay_hostmode consul
|
||||
}
|
||||
61
vendor/github.com/docker/libnetwork/test/integration/dnet/overlay-consul.bats
generated
vendored
Normal file
61
vendor/github.com/docker/libnetwork/test/integration/dnet/overlay-consul.bats
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
# -*- mode: sh -*-
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
@test "Test overlay network with consul" {
|
||||
skip_for_circleci
|
||||
test_overlay consul
|
||||
}
|
||||
|
||||
@test "Test overlay network singlehost with consul" {
|
||||
skip_for_circleci
|
||||
test_overlay_singlehost 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
|
||||
}
|
||||
|
||||
@test "Test overlay network with dnet ungraceful shutdown" {
|
||||
skip_for_circleci
|
||||
dnet_cmd $(inst_id2port 1) network create -d overlay multihost
|
||||
start=1
|
||||
end=3
|
||||
for i in `seq ${start} ${end}`;
|
||||
do
|
||||
dnet_cmd $(inst_id2port $i) container create container_${i}
|
||||
net_connect ${i} container_${i} multihost
|
||||
done
|
||||
|
||||
hrun runc $(dnet_container_name 1 consul) $(get_sbox_id 1 container_1) "ifconfig eth0"
|
||||
container_1_ip=$(echo ${output} | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
|
||||
|
||||
# ungracefully kill dnet-1-consul container
|
||||
docker rm -f dnet-1-consul
|
||||
|
||||
# forcefully unpublish the service from dnet2 when dnet1 is dead.
|
||||
dnet_cmd $(inst_id2port 2) service unpublish -f container_1.multihost
|
||||
dnet_cmd $(inst_id2port 2) container create container_1
|
||||
net_connect 2 container_1 multihost
|
||||
|
||||
hrun runc $(dnet_container_name 2 consul) $(get_sbox_id 2 container_1) "ifconfig eth0"
|
||||
container_1_new_ip=$(echo ${output} | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
|
||||
|
||||
if [ "$container_1_ip" != "$container_1_new_ip" ]; then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
@test "Test overlay network internal network with consul" {
|
||||
skip_for_circleci
|
||||
test_overlay consul internal
|
||||
}
|
||||
9
vendor/github.com/docker/libnetwork/test/integration/dnet/overlay-etcd.bats
generated
vendored
Normal file
9
vendor/github.com/docker/libnetwork/test/integration/dnet/overlay-etcd.bats
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# -*- mode: sh -*-
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
@test "Test overlay network with etcd" {
|
||||
skip_for_circleci
|
||||
test_overlay etcd
|
||||
}
|
||||
9
vendor/github.com/docker/libnetwork/test/integration/dnet/overlay-zookeeper.bats
generated
vendored
Normal file
9
vendor/github.com/docker/libnetwork/test/integration/dnet/overlay-zookeeper.bats
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# -*- mode: sh -*-
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
@test "Test overlay network with zookeeper" {
|
||||
skip_for_circleci
|
||||
test_overlay zookeeper
|
||||
}
|
||||
257
vendor/github.com/docker/libnetwork/test/integration/dnet/run-integration-tests.sh
generated
vendored
Executable file
257
vendor/github.com/docker/libnetwork/test/integration/dnet/run-integration-tests.sh
generated
vendored
Executable file
@@ -0,0 +1,257 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
export INTEGRATION_ROOT=./integration-tmp
|
||||
export TMPC_ROOT=./integration-tmp/tmpc
|
||||
|
||||
declare -A cmap
|
||||
|
||||
trap "cleanup_containers" EXIT SIGINT
|
||||
|
||||
function cleanup_containers() {
|
||||
for c in "${!cmap[@]}";
|
||||
do
|
||||
docker stop $c 1>>${INTEGRATION_ROOT}/test.log 2>&1 || true
|
||||
if [ -z "$CIRCLECI" ]; then
|
||||
docker rm -f $c 1>>${INTEGRATION_ROOT}/test.log 2>&1 || true
|
||||
fi
|
||||
done
|
||||
|
||||
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_consul_host_tests() {
|
||||
export _OVERLAY_HOST_MODE="true"
|
||||
## Setup
|
||||
start_dnet 1 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-consul]=dnet-1-consul
|
||||
|
||||
## Run the test cases
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/overlay-consul-host.bats
|
||||
|
||||
## Teardown
|
||||
stop_dnet 1 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-consul]
|
||||
unset _OVERLAY_HOST_MODE
|
||||
}
|
||||
|
||||
function run_overlay_zk_tests() {
|
||||
## Test overlay network with zookeeper
|
||||
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]
|
||||
}
|
||||
|
||||
function run_overlay_etcd_tests() {
|
||||
## Test overlay network with etcd
|
||||
start_dnet 1 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-etcd]=dnet-1-etcd
|
||||
start_dnet 2 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-2-etcd]=dnet-2-etcd
|
||||
start_dnet 3 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-3-etcd]=dnet-3-etcd
|
||||
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/overlay-etcd.bats
|
||||
|
||||
stop_dnet 1 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-etcd]
|
||||
stop_dnet 2 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-2-etcd]
|
||||
stop_dnet 3 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-3-etcd]
|
||||
}
|
||||
|
||||
function run_dnet_tests() {
|
||||
# Test dnet configuration options
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/dnet.bats
|
||||
}
|
||||
|
||||
function run_simple_consul_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_consul_tests() {
|
||||
# Test multi node configuration with a global scope test driver backed by consul
|
||||
|
||||
## Setup
|
||||
start_dnet 1 multi_consul consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-multi_consul]=dnet-1-multi_consul
|
||||
start_dnet 2 multi_consul consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-2-multi_consul]=dnet-2-multi_consul
|
||||
start_dnet 3 multi_consul consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-3-multi_consul]=dnet-3-multi_consul
|
||||
|
||||
## Run the test cases
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/multi.bats
|
||||
|
||||
## Teardown
|
||||
stop_dnet 1 multi_consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-multi_consul]
|
||||
stop_dnet 2 multi_consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-2-multi_consul]
|
||||
stop_dnet 3 multi_consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-3-multi_consul]
|
||||
}
|
||||
|
||||
function run_multi_zk_tests() {
|
||||
# Test multi node configuration with a global scope test driver backed by zookeeper
|
||||
|
||||
## Setup
|
||||
start_dnet 1 multi_zk zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-multi_zk]=dnet-1-multi_zk
|
||||
start_dnet 2 multi_zk zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-2-multi_zk]=dnet-2-multi_zk
|
||||
start_dnet 3 multi_zk zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-3-multi_zk]=dnet-3-multi_zk
|
||||
|
||||
## Run the test cases
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/multi.bats
|
||||
|
||||
## Teardown
|
||||
stop_dnet 1 multi_zk 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-multi_zk]
|
||||
stop_dnet 2 multi_zk 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-2-multi_zk]
|
||||
stop_dnet 3 multi_zk 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-3-multi_zk]
|
||||
}
|
||||
|
||||
function run_multi_etcd_tests() {
|
||||
# Test multi node configuration with a global scope test driver backed by etcd
|
||||
|
||||
## Setup
|
||||
start_dnet 1 multi_etcd etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-1-multi_etcd]=dnet-1-multi_etcd
|
||||
start_dnet 2 multi_etcd etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-2-multi_etcd]=dnet-2-multi_etcd
|
||||
start_dnet 3 multi_etcd etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dnet-3-multi_etcd]=dnet-3-multi_etcd
|
||||
|
||||
## Run the test cases
|
||||
./integration-tmp/bin/bats ./test/integration/dnet/multi.bats
|
||||
|
||||
## Teardown
|
||||
stop_dnet 1 multi_etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-1-multi_etcd]
|
||||
stop_dnet 2 multi_etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-2-multi_etcd]
|
||||
stop_dnet 3 multi_etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
unset cmap[dnet-3-multi_etcd]
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
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_consul multi_consul multi_zk multi_etcd"
|
||||
else
|
||||
suites="dnet simple_consul multi_consul multi_zk multi_etcd bridge overlay_consul overlay_consul_host overlay_zk overlay_etcd"
|
||||
fi
|
||||
else
|
||||
suites="$SUITES"
|
||||
fi
|
||||
|
||||
if [[ ( "$suites" =~ .*consul.* ) || ( "$suites" =~ .*bridge.* ) ]]; then
|
||||
echo "Starting consul ..."
|
||||
start_consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[pr_consul]=pr_consul
|
||||
fi
|
||||
|
||||
if [[ "$suites" =~ .*zk.* ]]; then
|
||||
echo "Starting zookeeper ..."
|
||||
start_zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[zookeeper_server]=zookeeper_server
|
||||
fi
|
||||
|
||||
if [[ "$suites" =~ .*etcd.* ]]; then
|
||||
echo "Starting etcd ..."
|
||||
start_etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
|
||||
cmap[dn_etcd]=dn_etcd
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
for suite in ${suites};
|
||||
do
|
||||
suite_func=run_${suite}_tests
|
||||
echo "Running ${suite}_tests ..."
|
||||
declare -F $suite_func >/dev/null && $suite_func
|
||||
echo ""
|
||||
done
|
||||
80
vendor/github.com/docker/libnetwork/test/integration/dnet/simple.bats
generated
vendored
Normal file
80
vendor/github.com/docker/libnetwork/test/integration/dnet/simple.bats
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
@test "Test network create" {
|
||||
echo $(docker ps)
|
||||
run dnet_cmd $(inst_id2port 1) network create -d test mh1
|
||||
echo ${output}
|
||||
[ "$status" -eq 0 ]
|
||||
run dnet_cmd $(inst_id2port 1) network ls
|
||||
echo ${output}
|
||||
line=$(dnet_cmd $(inst_id2port 1) network ls | grep mh1)
|
||||
echo ${line}
|
||||
name=$(echo ${line} | cut -d" " -f2)
|
||||
driver=$(echo ${line} | cut -d" " -f3)
|
||||
echo ${name} ${driver}
|
||||
[ "$name" = "mh1" ]
|
||||
[ "$driver" = "test" ]
|
||||
dnet_cmd $(inst_id2port 1) network rm mh1
|
||||
}
|
||||
|
||||
@test "Test network delete with id" {
|
||||
echo $(docker ps)
|
||||
run dnet_cmd $(inst_id2port 1) network create -d test mh1
|
||||
[ "$status" -eq 0 ]
|
||||
echo ${output}
|
||||
dnet_cmd $(inst_id2port 1) network rm ${output}
|
||||
}
|
||||
|
||||
@test "Test service create" {
|
||||
echo $(docker ps)
|
||||
dnet_cmd $(inst_id2port 1) network create -d test multihost
|
||||
run dnet_cmd $(inst_id2port 1) service publish svc1.multihost
|
||||
echo ${output}
|
||||
[ "$status" -eq 0 ]
|
||||
run dnet_cmd $(inst_id2port 1) service ls
|
||||
echo ${output}
|
||||
echo ${lines[1]}
|
||||
[ "$status" -eq 0 ]
|
||||
svc=$(echo ${lines[1]} | cut -d" " -f2)
|
||||
network=$(echo ${lines[1]} | cut -d" " -f3)
|
||||
echo ${svc} ${network}
|
||||
[ "$network" = "multihost" ]
|
||||
[ "$svc" = "svc1" ]
|
||||
dnet_cmd $(inst_id2port 1) service unpublish svc1.multihost
|
||||
dnet_cmd $(inst_id2port 1) network rm multihost
|
||||
}
|
||||
|
||||
@test "Test service delete with id" {
|
||||
echo $(docker ps)
|
||||
dnet_cmd $(inst_id2port 1) network create -d test multihost
|
||||
run dnet_cmd $(inst_id2port 1) service publish svc1.multihost
|
||||
[ "$status" -eq 0 ]
|
||||
echo ${output}
|
||||
run dnet_cmd $(inst_id2port 1) service ls
|
||||
[ "$status" -eq 0 ]
|
||||
echo ${output}
|
||||
echo ${lines[1]}
|
||||
id=$(echo ${lines[1]} | cut -d" " -f1)
|
||||
dnet_cmd $(inst_id2port 1) service unpublish ${id}.multihost
|
||||
dnet_cmd $(inst_id2port 1) network rm multihost
|
||||
}
|
||||
|
||||
@test "Test service attach" {
|
||||
echo $(docker ps)
|
||||
dnet_cmd $(inst_id2port 1) network create -d test multihost
|
||||
dnet_cmd $(inst_id2port 1) service publish svc1.multihost
|
||||
dnet_cmd $(inst_id2port 1) container create container_1
|
||||
dnet_cmd $(inst_id2port 1) service attach container_1 svc1.multihost
|
||||
run dnet_cmd $(inst_id2port 1) service ls
|
||||
[ "$status" -eq 0 ]
|
||||
echo ${output}
|
||||
echo ${lines[1]}
|
||||
container=$(echo ${lines[1]} | cut -d" " -f4)
|
||||
[ "$container" = "container_1" ]
|
||||
dnet_cmd $(inst_id2port 1) service detach container_1 svc1.multihost
|
||||
dnet_cmd $(inst_id2port 1) container rm container_1
|
||||
dnet_cmd $(inst_id2port 1) service unpublish svc1.multihost
|
||||
dnet_cmd $(inst_id2port 1) network rm multihost
|
||||
}
|
||||
50
vendor/github.com/docker/libnetwork/test/integration/helpers.bash
generated
vendored
Normal file
50
vendor/github.com/docker/libnetwork/test/integration/helpers.bash
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Root directory of the repository.
|
||||
MACHINE_ROOT=/usr/bin
|
||||
|
||||
PLATFORM=`uname -s | tr '[:upper:]' '[:lower:]'`
|
||||
ARCH=`uname -m`
|
||||
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
ARCH="amd64"
|
||||
else
|
||||
ARCH="386"
|
||||
fi
|
||||
MACHINE_BIN_NAME=docker-machine_$PLATFORM-$ARCH
|
||||
BATS_LOG=/tmp/bats.log
|
||||
|
||||
touch ${BATS_LOG}
|
||||
rm ${BATS_LOG}
|
||||
|
||||
teardown() {
|
||||
echo "$BATS_TEST_NAME
|
||||
----------
|
||||
$output
|
||||
----------
|
||||
|
||||
" >> ${BATS_LOG}
|
||||
}
|
||||
|
||||
EXTRA_ARGS_CFG='EXTRA_ARGS'
|
||||
EXTRA_ARGS='--tlsverify --tlscacert=/var/lib/boot2docker/ca.pem --tlskey=/var/lib/boot2docker/server-key.pem --tlscert=/var/lib/boot2docker/server.pem --label=provider=virtualbox -H tcp://0.0.0.0:2376'
|
||||
TMP_EXTRA_ARGS_FILE=/tmp/tmp_extra_args
|
||||
DAEMON_CFG_FILE=${BATS_TEST_DIRNAME}/daemon.cfg
|
||||
set_extra_config() {
|
||||
if [ -f ${TMP_EXTRA_ARGS_FILE} ];
|
||||
then
|
||||
rm ${TMP_EXTRA_ARGS_FILE}
|
||||
fi
|
||||
echo -n "${EXTRA_ARGS_CFG}='" > ${TMP_EXTRA_ARGS_FILE}
|
||||
echo -n "$1 " >> ${TMP_EXTRA_ARGS_FILE}
|
||||
echo "${EXTRA_ARGS}'" >> ${TMP_EXTRA_ARGS_FILE}
|
||||
}
|
||||
|
||||
if [ ! -e $MACHINE_ROOT/$MACHINE_BIN_NAME ]; then
|
||||
echo "${MACHINE_ROOT}/${MACHINE_BIN_NAME} not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function machine() {
|
||||
${MACHINE_ROOT}/$MACHINE_BIN_NAME "$@"
|
||||
}
|
||||
Reference in New Issue
Block a user