Selaa lähdekoodia

Add Matomo testsuite

J0WI 3 vuotta sitten
vanhempi
sitoutus
6a8ce340b2
3 muutettua tiedostoa jossa 87 lisäystä ja 0 poistoa
  1. 6 0
      test/config.sh
  2. 35 0
      test/tests/matomo-apache-run/run.sh
  3. 46 0
      test/tests/matomo-fpm-run/run.sh

+ 6 - 0
test/config.sh

@@ -106,6 +106,12 @@ imageTests+=(
 	[logstash]='
 		logstash-basics
 	'
+	[matomo:apache]='
+		matomo-apache-run
+	'
+	[matomo:fpm]='
+		matomo-fpm-run
+	'
 	[memcached]='
 		memcached-basics
 	'

+ 35 - 0
test/tests/matomo-apache-run/run.sh

@@ -0,0 +1,35 @@
+#!/bin/bash
+set -eo pipefail
+
+dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
+
+# Use a client image with curl for testing
+clientImage='buildpack-deps:buster-curl'
+# ensure the clientImage is ready and available
+if ! docker image inspect "$clientImage" &> /dev/null; then
+	docker pull "$clientImage" > /dev/null
+fi
+serverImage="$1"
+
+# Create an instance of the container-under-test
+cid="$(docker run -d "$serverImage")"
+trap "docker rm -vf $cid > /dev/null" EXIT
+
+_request() {
+	local method="$1"
+	shift
+
+	local url="${1#/}"
+	shift
+
+	docker run --rm \
+		--link "$cid":apache \
+		"$clientImage" \
+		curl -fsL -X"$method" "$@" "http://apache/$url"
+}
+
+# Make sure that Apache is listening and ready
+. "$dir/../../retry.sh" --tries 10 '_request GET / --output /dev/null'
+
+# Check that we can request / and that it contains the word "installation" somewhere
+_request GET '/' | grep -i installation > /dev/null

+ 46 - 0
test/tests/matomo-fpm-run/run.sh

@@ -0,0 +1,46 @@
+#!/bin/bash
+set -eo pipefail
+
+dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
+
+image="$1"
+
+# Build a client image with cgi-fcgi for testing
+clientImage='librarytest/matomo-fpm-run:fcgi-client'
+docker build -t "$clientImage" - > /dev/null <<'EOF'
+FROM debian:buster-slim
+
+RUN set -x && apt-get update && apt-get install -y --no-install-recommends libfcgi-bin && rm -rf /var/lib/apt/lists/*
+
+ENTRYPOINT ["cgi-fcgi"]
+EOF
+
+# Create an instance of the container-under-test
+cid="$(docker run -d "$image")"
+trap "docker rm -vf $cid > /dev/null" EXIT
+
+fcgi-request() {
+	local method="$1"
+
+	local url="$2"
+	local queryString=
+	if [[ "$url" == *\?* ]]; then
+		queryString="${url#*\?}"
+		url="${url%%\?*}"
+	fi
+
+	docker run --rm -i --link "$cid":fpm \
+		-e REQUEST_METHOD="$method" \
+		-e SCRIPT_NAME="$url" \
+		-e SCRIPT_FILENAME=/var/www/html/"${url#/}" \
+		-e QUERY_STRING="$queryString" \
+		-e HTTP_HOST='localhost' \
+		"$clientImage" \
+		-bind -connect fpm:9000
+}
+
+# Make sure that PHP-FPM is listening and ready
+. "$dir/../../retry.sh" --tries 10 'fcgi-request GET /index.php' > /dev/null 2>&1
+
+# check that it contains the word "installation" somewhere
+fcgi-request GET '/index.php' | grep -i installation > /dev/null