diff --git a/libnetwork/test/integration/README.md b/libnetwork/test/integration/README.md deleted file mode 100644 index 777b1cfa46..0000000000 --- a/libnetwork/test/integration/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# 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 -``` - - diff --git a/libnetwork/test/integration/daemon-configs.bats b/libnetwork/test/integration/daemon-configs.bats deleted file mode 100644 index fd48fbe199..0000000000 --- a/libnetwork/test/integration/daemon-configs.bats +++ /dev/null @@ -1,104 +0,0 @@ -#!/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 ] -} - diff --git a/libnetwork/test/integration/daemon.cfg b/libnetwork/test/integration/daemon.cfg deleted file mode 100644 index fc93dbd604..0000000000 --- a/libnetwork/test/integration/daemon.cfg +++ /dev/null @@ -1,4 +0,0 @@ -CACERT=/var/lib/boot2docker/ca.pem -SERVERCERT=/var/lib/boot2docker/server-key.pem -SERVERKEY=/var/lib/boot2docker/server.pem -DOCKER_TLS=no diff --git a/libnetwork/test/integration/dnet/bridge.bats b/libnetwork/test/integration/dnet/bridge.bats deleted file mode 100644 index e0648b526a..0000000000 --- a/libnetwork/test/integration/dnet/bridge.bats +++ /dev/null @@ -1,287 +0,0 @@ -# -*- 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" { - echo $(docker ps) - test_single_network_connectivity bridge 3 -} - - -@test "Test default network dnet restart" { - 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" { - 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" { - 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" { - 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" { - 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" { - 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" { - 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" { - 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" { - 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 communicate 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 8.8.8.8" - [[ "$output" == *"1 packets transmitted, 0 packets received, 100% packet loss"* ]] - net_disconnect 1 container_1 internal - # connects to bridge network, confirm it can communicate with outside world - net_connect 1 container_1 bridge - runc $(dnet_container_name 1 bridge) $(get_sbox_id 1 container_1) "ping -c 1 8.8.8.8" - net_disconnect 1 container_1 bridge - dnet_cmd $(inst_id2port 1) container rm container_1 - # test communications within internal network - test_single_network_connectivity internal 3 - dnet_cmd $(inst_id2port 1) network rm internal -} diff --git a/libnetwork/test/integration/dnet/dnet.bats b/libnetwork/test/integration/dnet/dnet.bats deleted file mode 100644 index cf73eab5bb..0000000000 --- a/libnetwork/test/integration/dnet/dnet.bats +++ /dev/null @@ -1,31 +0,0 @@ -#!/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 -} diff --git a/libnetwork/test/integration/dnet/helpers.bash b/libnetwork/test/integration/dnet/helpers.bash deleted file mode 100644 index 6366839172..0000000000 --- a/libnetwork/test/integration/dnet/helpers.bash +++ /dev/null @@ -1,478 +0,0 @@ -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 dnet_container_ip() { - docker inspect --format '{{.NetworkSettings.IPAddress}}' 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} -} - -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 nip - local discovery provider address - - inst=$1 - shift - suffix=$1 - shift - - store=$(echo $suffix | cut -d":" -f1) - nip=$(echo $suffix | cut -s -d":" -f2) - - - stop_dnet ${inst} ${store} - name=$(dnet_container_name ${inst} ${store}) - - hport=$((41000+${inst}-1)) - cport=2385 - hopt="" - - 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} - - mkdir -p /tmp/dnet/${name} - tomlfile="/tmp/dnet/${name}/libnetwork.toml" - - # Try discovery URLs with or without path - neigh_ip="" - neighbors="" - if [ "$nip" != "" ]; then - neighbors=${nip} - fi - - discovery="" - provider="" - address="" - - if [ "$discovery" != "" ]; then - cat > ${tomlfile} < ${tomlfile} <> ${INTEGRATION_ROOT}/test.log 2>&1 || true - 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_local_tests() { - ## Test overlay network in local scope - ## Setup - start_dnet 1 local 1>> ${INTEGRATION_ROOT}/test.log 2>&1 - cmap[dnet - 1 - local]=dnet-1-local - start_dnet 2 local:$(dnet_container_ip 1 local) 1>> ${INTEGRATION_ROOT}/test.log 2>&1 - cmap[dnet - 2 - local]=dnet-2-local - start_dnet 3 local:$(dnet_container_ip 1 local) 1>> ${INTEGRATION_ROOT}/test.log 2>&1 - cmap[dnet - 3 - local]=dnet-3-local - - ## Run the test cases - ./integration-tmp/bin/bats ./test/integration/dnet/overlay-local.bats - - ## Teardown - stop_dnet 1 local 1>> ${INTEGRATION_ROOT}/test.log 2>&1 - unset cmap[dnet-1-local] - stop_dnet 2 local 1>> ${INTEGRATION_ROOT}/test.log 2>&1 - unset cmap[dnet-2-local] - stop_dnet 3 local 1>> ${INTEGRATION_ROOT}/test.log 2>&1 - unset cmap[dnet-3-local] -} - -function run_dnet_tests() { - # Test dnet configuration options - ./integration-tmp/bin/bats ./test/integration/dnet/dnet.bats -} - -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 - suites="dnet bridge" -else - suites="$SUITES" -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 diff --git a/libnetwork/test/integration/dnet/simple.bats b/libnetwork/test/integration/dnet/simple.bats deleted file mode 100644 index 96365eaae3..0000000000 --- a/libnetwork/test/integration/dnet/simple.bats +++ /dev/null @@ -1,80 +0,0 @@ -#!/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 -} diff --git a/libnetwork/test/integration/helpers.bash b/libnetwork/test/integration/helpers.bash deleted file mode 100644 index 8ca3a3c635..0000000000 --- a/libnetwork/test/integration/helpers.bash +++ /dev/null @@ -1,49 +0,0 @@ -#!/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 "$@" -}