diff --git a/.test/config.sh b/.test/config.sh index e371f4043..7d92300f1 100755 --- a/.test/config.sh +++ b/.test/config.sh @@ -2,9 +2,10 @@ imageTests+=( [nginx]=' ipv6 static - templates + templates-http templates-resolver templates-resolver-ipv6 + templates-stream workers modules ' diff --git a/.test/tests/templates/run.sh b/.test/tests/templates-http/run.sh similarity index 100% rename from .test/tests/templates/run.sh rename to .test/tests/templates-http/run.sh diff --git a/.test/tests/templates/server.conf.template b/.test/tests/templates-http/server.conf.template similarity index 100% rename from .test/tests/templates/server.conf.template rename to .test/tests/templates-http/server.conf.template diff --git a/.test/tests/templates-stream/expected-std-out.txt b/.test/tests/templates-stream/expected-std-out.txt new file mode 100644 index 000000000..38bfee851 --- /dev/null +++ b/.test/tests/templates-stream/expected-std-out.txt @@ -0,0 +1 @@ +example.com - OK diff --git a/.test/tests/templates-stream/run.sh b/.test/tests/templates-stream/run.sh new file mode 100755 index 000000000..af4540824 --- /dev/null +++ b/.test/tests/templates-stream/run.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +[ "$DEBUG" ] && set -x + +set -eo pipefail + +dir="$(dirname "$(readlink -f "$BASH_SOURCE")")" + +image="$1" + +clientImage='alpine:latest' +# ensure the clientImage is ready and available +if ! docker image inspect "$clientImage" &> /dev/null; then + docker pull "$clientImage" > /dev/null +fi + +# Create an instance of the container-under-test +serverImage="$("$HOME/oi/test/tests/image-name.sh" librarytest/nginx-template "$image")" +"$HOME/oi/test/tests/docker-build.sh" "$dir" "$serverImage" < /dev/null" EXIT + +_request() { + if [ "$(docker inspect -f '{{.State.Running}}' "$cid" 2>/dev/null)" != 'true' ]; then + echo >&2 "$image stopped unexpectedly!" + ( set -x && docker logs "$cid" ) >&2 || true + false + fi + + docker run --rm \ + --link "$cid":nginx \ + "$clientImage" \ + nc -w 1 nginx 80 +} + +. "$HOME/oi/test/retry.sh" '[ "$(_request GET / --output /dev/null || echo $?)" != 7 ]' + +# Check that we can request / +_request | grep 'example.com - OK' diff --git a/.test/tests/templates-stream/server.conf.template b/.test/tests/templates-stream/server.conf.template new file mode 100644 index 000000000..729ba7810 --- /dev/null +++ b/.test/tests/templates-stream/server.conf.template @@ -0,0 +1,4 @@ +server { + listen 80; + return "${NGINX_MY_SERVER_NAME} - OK\n"; +}