Test to support overlay networks

This commit is contained in:
Baptiste Donaux 2016-02-25 09:58:17 +01:00
parent 163d1ce174
commit 2b418319f2
2 changed files with 18 additions and 1 deletions

View File

@ -54,15 +54,21 @@ load test_helpers
@test "[$TEST_FILE] separated containers (nginx + docker-gen + nginx.tmpl)" {
docker_clean bats-nginx
docker_clean bats-docker-gen
docker_network_clean bats-docker-gen-network
# MAKE network
run docker network create bats-docker-gen-network
assert_success
# GIVEN a simple nginx container
run docker run -d \
--name bats-nginx \
--net=bats-docker-gen-network \
-v /etc/nginx/conf.d/ \
-v /etc/nginx/certs/ \
nginx:latest
assert_success
run retry 5 1s docker run appropriate/curl --silent --fail --head http://$(docker_ip bats-nginx)/
run retry 5 1s docker run --net=bats-docker-gen-network appropriate/curl --silent --fail --head http://$(docker_ips bats-nginx)/
assert_output -l 0 $'HTTP/1.1 200 OK\r'
# WHEN docker-gen runs on our docker host

View File

@ -8,11 +8,22 @@ function docker_clean {
sleep .25s
}
# Removes network $1
function docker_network_clean {
docker network rm $1 &>/dev/null ||:
sleep .25s
}
# get the ip of docker container $1
function docker_ip {
docker inspect --format '{{ .NetworkSettings.IPAddress }}' $1
}
# get the ip of docker container $1
function docker_ips {
docker inspect --format '{{ range .NetworkSettings.Networks }}{{ .IPAddress }}{{ end }}' $1
}
# get the running state of container $1
# → true/false
# fails if the container does not exist