From 97749f3f2d6e58eb12ca87fddb93b79d3a4d39a5 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Fri, 29 Jan 2016 06:04:55 -0800 Subject: [PATCH] add docker run --net-alias, docker network connect --ip and docker network connect --alias tests Signed-off-by: Victor Vieux --- test/integration/api/network.bats | 54 +++++++++++++++++++++++++++++++ test/integration/api/run.bats | 17 ++++++++++ 2 files changed, 71 insertions(+) diff --git a/test/integration/api/network.bats b/test/integration/api/network.bats index 60825eb7bd..c75f90aabd 100644 --- a/test/integration/api/network.bats +++ b/test/integration/api/network.bats @@ -94,3 +94,57 @@ function teardown() { run docker_swarm network inspect node-0/bridge [[ "${output}" == *"\"Containers\": {}"* ]] } + +@test "docker network connect --ip" { + # docker network connect --ip is introduced in docker 1.10, skip older version without --ip + run docker network connect --help + if [[ "${output}" != *"--ip"* ]]; then + skip + fi + + start_docker_with_busybox 1 + swarm_manage + + docker_swarm network create -d bridge --subnet 10.0.0.0/24 testn + + run docker_swarm network inspect testn + [[ "${output}" == *"\"Containers\": {}"* ]] + + # run + docker_swarm run -d --name test_container busybox sleep 100 + + docker_swarm network connect --ip 10.0.0.42 testn test_container + + run docker_swarm inspect test_container + [[ "${output}" == *"10.0.0.42"* ]] + + run docker_swarm network inspect testn + [[ "${output}" != *"\"Containers\": {}"* ]] +} + +@test "docker network connect --alias" { + # docker network connect --alias is introduced in docker 1.10, skip older version without --alias + run docker network connect --help + if [[ "${output}" != *"--alias"* ]]; then + skip + fi + + start_docker_with_busybox 1 + swarm_manage + + docker_swarm network create -d bridge testn + + run docker_swarm network inspect testn + [[ "${output}" == *"\"Containers\": {}"* ]] + + # run + docker_swarm run -d --name test_container busybox sleep 100 + + docker_swarm network connect --alias testa testn test_container + + run docker_swarm inspect test_container + [[ "${output}" == *"testa"* ]] + + run docker_swarm network inspect testn + [[ "${output}" != *"\"Containers\": {}"* ]] +} diff --git a/test/integration/api/run.bats b/test/integration/api/run.bats index 99da324f12..6d3d21912e 100644 --- a/test/integration/api/run.bats +++ b/test/integration/api/run.bats @@ -119,6 +119,23 @@ function teardown() { [[ "${output}" == *"10.0.0.42"* ]] } +@test "docker run --net-alias" { + # docker run --net-alias is introduced in docker 1.10, skip older version without --net-alias + run docker run --help + if [[ "${output}" != *"--net-alias"* ]]; then + skip + fi + + start_docker_with_busybox 1 + swarm_manage + + docker_swarm network create -d bridge testn + + docker_swarm run --name testc --net testn -d --net-alias=testa busybox sh + run docker_swarm inspect testc + [[ "${output}" == *"testa"* ]] +} + @test "docker run - reschedule with image affinity" { start_docker_with_busybox 1 start_docker 1