1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2024-11-22 11:56:31 +00:00

Tweak test for reliability on Travis-CI

This commit is contained in:
Steve Kamerman 2017-01-12 10:52:56 -05:00
parent c219822cd8
commit dffc0c47cf

View File

@ -8,30 +8,28 @@ function setup {
} }
@test "[$TEST_FILE] test dhparam.pem is generated if missing (WARNING: this test is slow)" { @test "[$TEST_FILE] test dhparam.pem is generated if missing (WARNING: this test is slow)" {
SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}-1 SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}-1
# WHEN # WHEN
run docker_clean $SUT_CONTAINER \ run docker_clean $SUT_CONTAINER \
&& docker run -d \ && docker run -d \
--label bats-type="nginx-proxy" \ --label bats-type="nginx-proxy" \
--name $SUT_CONTAINER \ --name $SUT_CONTAINER \
-v /var/run/docker.sock:/tmp/docker.sock:ro \ -v /var/run/docker.sock:/tmp/docker.sock:ro \
$SUT_IMAGE \ $SUT_IMAGE \
&& wait_for_nginxproxy_container_to_start $SUT_CONTAINER \ && wait_for_nginxproxy_container_to_start $SUT_CONTAINER \
&& docker logs $SUT_CONTAINER && docker logs $SUT_CONTAINER
assert_success DEFAULT_HASH=$(docker exec $SUT_CONTAINER md5sum /etc/nginx/dhparam/dhparam.pem | cut -d" " -f1)
docker_wait_for_log $SUT_CONTAINER 9 "Watching docker events"
# THEN assert_success
run docker exec $SUT_CONTAINER ps aux docker_wait_for_log $SUT_CONTAINER 9 "Generating DH parameters"
assert_output -p "openssl"
DEFAULT_HASH=$(docker exec $SUT_CONTAINER md5sum /etc/nginx/dhparam/dhparam.pem | cut -d" " -f1) # THEN
docker_wait_for_log $SUT_CONTAINER 240 "dhparam generation complete, reloading nginx" docker_wait_for_log $SUT_CONTAINER 240 "dhparam generation complete, reloading nginx"
run docker exec $SUT_CONTAINER md5sum /etc/nginx/dhparam/dhparam.pem run docker exec $SUT_CONTAINER md5sum /etc/nginx/dhparam/dhparam.pem
refute_output -p $DEFAULT_HASH refute_output -p $DEFAULT_HASH
} }
@test "[$TEST_FILE] test dhparam.pem is generated if default one is present" { @test "[$TEST_FILE] test dhparam.pem is generated if default one is present" {
@ -42,6 +40,13 @@ function setup {
if [ ! -d $TMP_DIR ]; then if [ ! -d $TMP_DIR ]; then
mkdir $TMP_DIR mkdir $TMP_DIR
fi fi
# If the previous test crashed, a dhparam is left that only root can delete, so we
# delete it from within a container as root
if [ -f $TMP_DIR/dhparam.pem ]; then
docker run --rm -v $TMP_DIR:/opt busybox rm /opt/dhparam.pem
fi
cp $DIR/../dhparam.pem.default $TMP_DIR/dhparam.pem cp $DIR/../dhparam.pem.default $TMP_DIR/dhparam.pem
# WHEN # WHEN
@ -55,14 +60,9 @@ function setup {
&& wait_for_nginxproxy_container_to_start $SUT_CONTAINER \ && wait_for_nginxproxy_container_to_start $SUT_CONTAINER \
&& docker logs $SUT_CONTAINER && docker logs $SUT_CONTAINER
docker logs $SUT_CONTAINER
assert_success
docker_wait_for_log $SUT_CONTAINER 9 "Watching docker events"
# THEN # THEN
run docker exec $SUT_CONTAINER ps aux assert_success
assert_output -p "openssl" docker_wait_for_log $SUT_CONTAINER 9 "Generating DH parameters"
docker exec $SUT_CONTAINER rm -rf /etc/nginx/dhparam/* docker exec $SUT_CONTAINER rm -rf /etc/nginx/dhparam/*
} }