Merge pull request #1726 from vieux/more_network_tests

add docker run --net-alias, docker network connect --ip and docker network connect --alias tests
This commit is contained in:
Alexandre Beslic 2016-02-01 16:08:54 -08:00
commit 79f255355d
2 changed files with 71 additions and 0 deletions

View File

@ -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\": {}"* ]]
}

View File

@ -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