Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .test/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ imageTests+=(
[nginx]='
ipv6
static
templates
templates-http
templates-resolver
templates-resolver-ipv6
templates-stream
workers
modules
'
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions .test/tests/templates-stream/expected-std-out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example.com - OK
45 changes: 45 additions & 0 deletions .test/tests/templates-stream/run.sh
Original file line number Diff line number Diff line change
@@ -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" <<EOD
FROM $image

RUN rm -f /etc/nginx/conf.d/default.conf

COPY dir/server.conf.template /etc/nginx/templates/server.conf.stream-template
EOD
cid="$(docker run -d -e NGINX_MY_SERVER_NAME=example.com "$serverImage")"
trap "docker rm -vf $cid > /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 ]'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GET / should be removed here now?


# Check that we can request /
_request | grep 'example.com - OK'
4 changes: 4 additions & 0 deletions .test/tests/templates-stream/server.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
server {
listen 80;
return "${NGINX_MY_SERVER_NAME} - OK\n";
}
Loading