瀏覽代碼

Merge pull request #2208 from rapidoid/master

Add an official image for Rapidoid
yosifkit 8 年之前
父節點
當前提交
9dc0afe7b0

+ 5 - 0
library/rapidoid

@@ -0,0 +1,5 @@
+Maintainers: Nikolche Mihajlovski <[email protected]> (@nmihajlovski)
+GitRepo: https://github.com/rapidoid/docker-rapidoid.git
+
+Tags: 5.2.6, 5.2, 5, latest
+GitCommit: 4552df257bda6f2f62921e776484c5df3d10553c

+ 4 - 0
test/config.sh

@@ -158,6 +158,10 @@ imageTests+=(
 	'
 	[rails]='
 	'
+	[rapidoid]='
+		rapidoid-hello-world
+		rapidoid-load-balancer
+	'
 	[redis]='
 		redis-basics
 		redis-basics-config

+ 1 - 0
test/tests/rapidoid-hello-world/index.html

@@ -0,0 +1 @@
+Hello world!

+ 46 - 0
test/tests/rapidoid-hello-world/run.sh

@@ -0,0 +1,46 @@
+#!/bin/bash
+
+[ "$DEBUG" ] && set -x
+
+set -eo pipefail
+
+dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
+
+image="$1"
+
+# Use a client image with curl for testing
+clientImage="buildpack-deps:curl"
+
+# Create an instance of the container-under-test
+serverImage="$("$dir/../image-name.sh" librarytest/rapidoid-hello-web "$image")"
+
+"$dir/../docker-build.sh" "$dir" "$serverImage" <<EOD
+FROM $image
+RUN mkdir -p /app/public
+COPY dir/index.html /app/public/
+EOD
+
+cid="$(docker run -d "$serverImage" app.services=ping)"
+
+trap "docker rm -vf $cid > /dev/null" EXIT
+
+_request() {
+	local method="$1"
+	shift
+
+	local url="${1#/}"
+	shift
+
+	docker run --rm --link "$cid":rapidoid "$clientImage" \
+		curl -fs -X"$method" "$@" "http://rapidoid:8888/$url"
+}
+
+# Make sure that Rapidoid is listening on port 8888
+. "$dir/../../retry.sh" --tries 40 --sleep 0.25 '[ "$(_request GET / --output /dev/null || echo $?)" != 7 ]'
+
+# Make sure that Rapidoid serves the static page index.html
+[ "$(_request GET "/")" = "Hello world!" ]
+[ "$(_request GET "/index.html")" = "Hello world!" ]
+
+# Make sure that Rapidoid's built-in Ping service works correctly
+[ "$(_request GET "/_ping")" = "OK" ]

+ 45 - 0
test/tests/rapidoid-load-balancer/run.sh

@@ -0,0 +1,45 @@
+#!/bin/bash
+
+[ "$DEBUG" ] && set -x
+
+set -eo pipefail
+
+dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
+
+image="$1"
+
+# Use a client image with curl for testing
+clientImage="buildpack-deps:curl"
+
+app1id="$(docker run -d "$image" on.port=80 id=app1 app.services=ping,status)"
+app2id="$(docker run -d "$image" on.port=80 id=app2 app.services=ping,status)"
+
+proxyid="$(docker run -d --link "$app1id":app1 --link "$app2id":app2 "$image" on.port=80 '/ -> http://app1, http://app2' app.services=ping)"
+
+trap "docker rm -vf $proxyid $app1id $app2id > /dev/null" EXIT
+
+_request() {
+    local cid="$1"
+	shift
+
+	local method="$1"
+	shift
+
+	local url="${1#/}"
+	shift
+
+	docker run --rm --link "$cid":rapidoid "$clientImage" \
+		curl -fs -X"$method" "$@" "http://rapidoid/$url"
+}
+
+# Make sure all Rapidoid servers are listening on port 80
+for cid in $app1id $app2id $proxyid; do
+    . "$dir/../../retry.sh" --tries 40 --sleep 0.25 '[ "$(_request '$cid' GET /_ping --output /dev/null || echo $?)" != 7 ]'
+done
+
+# Make sure that the round-robin load balancing works properly
+for n in `seq 1 5`; do
+    for i in 1 2; do
+        [[ "$(_request $cid GET "/_status")" == *"\"app$i\""* ]]
+    done
+done