浏览代码

Add jetty-hello-web test

Mike Dillon 10 年之前
父节点
当前提交
6b8b319362
共有 3 个文件被更改,包括 39 次插入0 次删除
  1. 3 0
      test/config.sh
  2. 1 0
      test/tests/jetty-hello-web/index.jsp
  3. 35 0
      test/tests/jetty-hello-web/run.sh

+ 3 - 0
test/config.sh

@@ -54,6 +54,9 @@ declare -A imageTests=(
 	'
 	'
 	[java]='
 	[java]='
 	'
 	'
+	[jetty]='
+		jetty-hello-web
+	'
 	[julia]='
 	[julia]='
 	'
 	'
 	[memcached]='
 	[memcached]='

+ 1 - 0
test/tests/jetty-hello-web/index.jsp

@@ -0,0 +1 @@
+<%= request.getParameter("hello") %>

+ 35 - 0
test/tests/jetty-hello-web/run.sh

@@ -0,0 +1,35 @@
+#!/bin/bash
+
+set -eo pipefail
+
+dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
+
+image="$1"
+
+# Pull a client image with curl for testing
+clientImage='appropriate/curl'
+docker pull "$clientImage"
+
+# Create an instance of the container-under-test
+cid="$(docker run -d -v "$dir/index.jsp":/var/lib/jetty/webapps/ROOT/index.jsp:ro "$image")"
+trap "docker rm -vf $cid > /dev/null" EXIT
+
+# RACY TESTS ARE RACY
+sleep 1
+# TODO find a cleaner solution to this, similar to what we do in mysql-basics
+
+_request() {
+	local method="$1"
+
+	local url="${2#/}"
+
+	docker run --rm -i --link "$cid":jetty \
+		"$clientImage" -fsSL -X"$method" "http://jetty:8080/$url"
+}
+
+# Check that we can request /index.jsp with no params
+[ "$(_request GET "/" | tail -1)" = "null" ]
+
+# Check that our index.jsp echoes the value of the "hello" param
+hello="world-$RANDOM-$RANDOM"
+[ "$(_request GET "/?hello=$hello" | tail -1)" = "$hello" ]