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:
David Parrish 2015-12-13 19:54:18 -05:00
parent 0d717fe64b
commit 3a16eee5f7
6 changed files with 26 additions and 11 deletions

View file

@ -7,8 +7,11 @@ update-dependencies:
docker pull python:3
docker pull rancher/socat-docker:latest
docker pull appropriate/curl:latest
docker pull docker:1.7
docker pull docker:1.9.1
test:
docker build -t jwilder/nginx-proxy:bats .
docker build -t dmp1ce/nginx-proxy-letsencrypt:bats .
bats test
test-clean:
./test/cleanup_test_containers.sh

View file

@ -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.
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
----------------------
Make sure you have Bats installed, then run:
docker build -t jwilder/nginx-proxy:bats .
bats test/
docker build -t jwilder/nginx-proxy-letsencrypt:bats .
bats test/

View file

@ -0,0 +1,8 @@
#!/bin/bash
# Remove "bats-*" containers
function teardown {
docker rm -f $(docker ps -aq -f name=bats-*)
}
teardown

View file

@ -62,7 +62,7 @@ load test_helpers
-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 --rm appropriate/curl --silent --fail --head http://$(docker_ip bats-nginx)/
assert_output -l 0 $'HTTP/1.1 200 OK\r'
# 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
assert_output -l 0 $'HTTP/1.1 503 Service Temporarily Unavailable\r'
}

View file

@ -56,5 +56,10 @@ function docker_tcp {
--expose 2375 \
-v /var/run/docker.sock:/var/run/docker.sock \
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-*)
#}

View file

@ -5,7 +5,7 @@
# 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)
@ -66,7 +66,7 @@ function curl_container {
local -r container=$1
local -r path=$2
shift 2
docker run appropriate/curl --silent \
docker run --rm appropriate/curl --silent \
--connect-timeout 5 \
--max-time 20 \
"$@" \
@ -128,7 +128,7 @@ function prepare_web_container {
# THEN querying directly port works
IFS=$' \t\n' # See https://github.com/sstephenson/bats/issues/89
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"
done
}