From d29e906a2f4a9c93455b2963f9a4b36d0c919aa8 Mon Sep 17 00:00:00 2001 From: Alex Ellis Date: Thu, 13 Apr 2017 22:19:35 +0100 Subject: [PATCH] Example DIND tests --- contrib/dind/Dockerfile | 14 +++++++++ contrib/dind/entry.sh | 11 +++++++ contrib/dind/start.sh | 11 +++++++ contrib/dind/test.sh | 69 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 contrib/dind/Dockerfile create mode 100644 contrib/dind/entry.sh create mode 100755 contrib/dind/start.sh create mode 100755 contrib/dind/test.sh diff --git a/contrib/dind/Dockerfile b/contrib/dind/Dockerfile new file mode 100644 index 00000000..51e46295 --- /dev/null +++ b/contrib/dind/Dockerfile @@ -0,0 +1,14 @@ +FROM docker:dind +WORKDIR /root/ +RUN apk --no-cache add git && \ + git clone https://github.com/alexellis/faas +WORKDIR /root/faas/ + + +EXPOSE 8080 +EXPOSE 9090 + +COPY entry.sh . +RUN chmod +x ./entry.sh + +CMD ["./entry.sh"] diff --git a/contrib/dind/entry.sh b/contrib/dind/entry.sh new file mode 100644 index 00000000..d49c2c54 --- /dev/null +++ b/contrib/dind/entry.sh @@ -0,0 +1,11 @@ +#/bin/sh + +dockerd & + +while [ ! -e /var/run/docker.sock ] ; do sleep 0.25 && echo "Waiting for Docker socket" ; done + +docker swarm init + +./deploy_stack.sh + +tail -f /dev/null diff --git a/contrib/dind/start.sh b/contrib/dind/start.sh new file mode 100755 index 00000000..0a8bbee9 --- /dev/null +++ b/contrib/dind/start.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +docker rm -f faas +docker run --name faas --privileged -p 8080:8080 -p 9090:9090 -d faas:dind + +./test.sh + +echo "Quitting after 120 seconds." +sleep 120 + +docker rmi -f faas diff --git a/contrib/dind/test.sh b/contrib/dind/test.sh new file mode 100755 index 00000000..69f5ec1f --- /dev/null +++ b/contrib/dind/test.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +function test_gateway { +while [ true ] +do + + curl -s localhost:8080 |grep "angular" + if [ ! 0 -eq $? ] + then + echo "Gateway not ready" + sleep 5 + else + break + fi +done + +echo + +} + +function test_function_output { +while [ true ] +do + out=$(curl -s localhost:8080/function/$1 -d "$2") + echo $out + if [ "$out" == "$3" ] + then + echo "Service $1 is ready" + break + else + echo "Service $1 not ready" + sleep 1 + fi +done + +echo + +} + + +function test_function { +while [ true ] +do + curl localhost:8080/function/$1 -d "$2" + if [ ! 0 -eq $? ] + then + echo "Service $1 not ready" + sleep 1 + else + echo "Service $1 is ready" + break + fi +done + +echo + +} + + +test_gateway + +test_function func_echoit hi +test_function func_webhookstash hi +test_function func_base64 hi +test_function func_markdown "*salut*" + +curl localhost:8080/system/functions -d '{"service": "stronghash", "image": "functions/alpine", "envProcess": "sha512sum", "network": "func_functions"}' + +test_function_output stronghash "hi" "150a14ed5bea6cc731cf86c41566ac427a8db48ef1b9fd626664b3bfbb99071fa4c922f33dde38719b8c8354e2b7ab9d77e0e67fc12843920a712e73d558e197 -"