Update tests for 'nginx-proxy-letsencrypt'.
Cleanup test containers when possible during tests. Add 'test-clean' make target for remaining bat-* containers.
This commit is contained in:
parent
0d717fe64b
commit
3a16eee5f7
6 changed files with 26 additions and 11 deletions
7
Makefile
7
Makefile
|
@ -7,8 +7,11 @@ update-dependencies:
|
||||||
docker pull python:3
|
docker pull python:3
|
||||||
docker pull rancher/socat-docker:latest
|
docker pull rancher/socat-docker:latest
|
||||||
docker pull appropriate/curl:latest
|
docker pull appropriate/curl:latest
|
||||||
docker pull docker:1.7
|
docker pull docker:1.9.1
|
||||||
|
|
||||||
test:
|
test:
|
||||||
docker build -t jwilder/nginx-proxy:bats .
|
docker build -t dmp1ce/nginx-proxy-letsencrypt:bats .
|
||||||
bats test
|
bats test
|
||||||
|
|
||||||
|
test-clean:
|
||||||
|
./test/cleanup_test_containers.sh
|
||||||
|
|
|
@ -3,12 +3,12 @@ Test suite
|
||||||
|
|
||||||
This test suite is implemented on top of the [Bats](https://github.com/sstephenson/bats/blob/master/README.md) test framework.
|
This test suite is implemented on top of the [Bats](https://github.com/sstephenson/bats/blob/master/README.md) test framework.
|
||||||
|
|
||||||
It is intended to verify the correct behavior of the Docker image `jwilder/nginx-proxy:bats`.
|
It is intended to verify the correct behavior of the Docker image `dmp1ce/nginx-proxy-letsencrypt:bats`.
|
||||||
|
|
||||||
Running the test suite
|
Running the test suite
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
Make sure you have Bats installed, then run:
|
Make sure you have Bats installed, then run:
|
||||||
|
|
||||||
docker build -t jwilder/nginx-proxy:bats .
|
docker build -t jwilder/nginx-proxy-letsencrypt:bats .
|
||||||
bats test/
|
bats test/
|
8
test/cleanup_test_containers.sh
Executable file
8
test/cleanup_test_containers.sh
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Remove "bats-*" containers
|
||||||
|
function teardown {
|
||||||
|
docker rm -f $(docker ps -aq -f name=bats-*)
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown
|
|
@ -62,7 +62,7 @@ load test_helpers
|
||||||
-v /etc/nginx/certs/ \
|
-v /etc/nginx/certs/ \
|
||||||
nginx:latest
|
nginx:latest
|
||||||
assert_success
|
assert_success
|
||||||
run retry 5 1s docker run appropriate/curl --silent --fail --head http://$(docker_ip bats-nginx)/
|
run retry 5 1s docker run --rm appropriate/curl --silent --fail --head http://$(docker_ip bats-nginx)/
|
||||||
assert_output -l 0 $'HTTP/1.1 200 OK\r'
|
assert_output -l 0 $'HTTP/1.1 200 OK\r'
|
||||||
|
|
||||||
# WHEN docker-gen runs on our docker host
|
# WHEN docker-gen runs on our docker host
|
||||||
|
@ -114,4 +114,3 @@ function assert_nginxproxy_behaves {
|
||||||
run curl_container $container /data --header "Host: webFOO.bats" --head
|
run curl_container $container /data --header "Host: webFOO.bats" --head
|
||||||
assert_output -l 0 $'HTTP/1.1 503 Service Temporarily Unavailable\r'
|
assert_output -l 0 $'HTTP/1.1 503 Service Temporarily Unavailable\r'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,5 +56,10 @@ function docker_tcp {
|
||||||
--expose 2375 \
|
--expose 2375 \
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
rancher/socat-docker
|
rancher/socat-docker
|
||||||
docker run --link "$container_name:docker" docker:1.7 version
|
docker run --rm --link "$container_name:docker" docker:1.9.1 version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Remove "bats-*" containers after each test
|
||||||
|
#function teardown {
|
||||||
|
#docker rm -f $(docker ps -aq -f name=bats-*)
|
||||||
|
#}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
|
|
||||||
# set a few global variables
|
# set a few global variables
|
||||||
SUT_IMAGE=jwilder/nginx-proxy:bats
|
SUT_IMAGE=dmp1ce/nginx-proxy-letsencrypt:bats
|
||||||
TEST_FILE=$(basename $BATS_TEST_FILENAME .bats)
|
TEST_FILE=$(basename $BATS_TEST_FILENAME .bats)
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ function curl_container {
|
||||||
local -r container=$1
|
local -r container=$1
|
||||||
local -r path=$2
|
local -r path=$2
|
||||||
shift 2
|
shift 2
|
||||||
docker run appropriate/curl --silent \
|
docker run --rm appropriate/curl --silent \
|
||||||
--connect-timeout 5 \
|
--connect-timeout 5 \
|
||||||
--max-time 20 \
|
--max-time 20 \
|
||||||
"$@" \
|
"$@" \
|
||||||
|
@ -128,7 +128,7 @@ function prepare_web_container {
|
||||||
# THEN querying directly port works
|
# THEN querying directly port works
|
||||||
IFS=$' \t\n' # See https://github.com/sstephenson/bats/issues/89
|
IFS=$' \t\n' # See https://github.com/sstephenson/bats/issues/89
|
||||||
for port in $ports; do
|
for port in $ports; do
|
||||||
run retry 5 1s docker run appropriate/curl --silent --fail http://$(docker_ip $container_name):$port/data
|
run retry 5 1s docker run --rm appropriate/curl --silent --fail http://$(docker_ip $container_name):$port/data
|
||||||
assert_output "answer from port $port"
|
assert_output "answer from port $port"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue