Skip to content

Commit 2b41831

Browse files
Test to support overlay networks
1 parent 163d1ce commit 2b41831

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

test/docker.bats

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,21 @@ load test_helpers
5454
@test "[$TEST_FILE] separated containers (nginx + docker-gen + nginx.tmpl)" {
5555
docker_clean bats-nginx
5656
docker_clean bats-docker-gen
57+
docker_network_clean bats-docker-gen-network
58+
59+
# MAKE network
60+
run docker network create bats-docker-gen-network
61+
assert_success
5762

5863
# GIVEN a simple nginx container
5964
run docker run -d \
6065
--name bats-nginx \
66+
--net=bats-docker-gen-network \
6167
-v /etc/nginx/conf.d/ \
6268
-v /etc/nginx/certs/ \
6369
nginx:latest
6470
assert_success
65-
run retry 5 1s docker run appropriate/curl --silent --fail --head http://$(docker_ip bats-nginx)/
71+
run retry 5 1s docker run --net=bats-docker-gen-network appropriate/curl --silent --fail --head http://$(docker_ips bats-nginx)/
6672
assert_output -l 0 $'HTTP/1.1 200 OK\r'
6773

6874
# WHEN docker-gen runs on our docker host

test/lib/docker_helpers.bash

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,22 @@ function docker_clean {
88
sleep .25s
99
}
1010

11+
# Removes network $1
12+
function docker_network_clean {
13+
docker network rm $1 &>/dev/null ||:
14+
sleep .25s
15+
}
16+
1117
# get the ip of docker container $1
1218
function docker_ip {
1319
docker inspect --format '{{ .NetworkSettings.IPAddress }}' $1
1420
}
1521

22+
# get the ip of docker container $1
23+
function docker_ips {
24+
docker inspect --format '{{ range .NetworkSettings.Networks }}{{ .IPAddress }}{{ end }}' $1
25+
}
26+
1627
# get the running state of container $1
1728
# → true/false
1829
# fails if the container does not exist

0 commit comments

Comments
 (0)