Răsfoiți Sursa

Merge pull request #11801 from infosiftr/nextcloud-tests

Adjust nextcloud tests to avoid flakiness
yosifkit 3 ani în urmă
părinte
comite
9468970678

+ 19 - 19
library/nextcloud

@@ -1,49 +1,49 @@
-# This file is generated via https://github.com/nextcloud/docker/blob/e3c4b823e31c55dc7d908f591a51c947535cee78/generate-stackbrew-library.sh
+# This file is generated via https://github.com/nextcloud/docker/blob/961aeb147e3949b7687efb751bc3c49bf790c9c8/generate-stackbrew-library.sh
 
 Maintainers: Nextcloud <[email protected]> (@nextcloud)
 GitRepo: https://github.com/nextcloud/docker.git
 
-Tags: 21.0.7-apache, 21.0-apache, 21-apache, 21.0.7, 21.0, 21
+Tags: 21.0.8-apache, 21.0-apache, 21-apache, 21.0.8, 21.0, 21
 Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: 905972656ea10c399f8f971b96adbdcbd9460d1f
+GitCommit: dcf058fb559e7918cd77f5f1bb0dfdbcee813571
 Directory: 21/apache
 
-Tags: 21.0.7-fpm, 21.0-fpm, 21-fpm
+Tags: 21.0.8-fpm, 21.0-fpm, 21-fpm
 Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: 905972656ea10c399f8f971b96adbdcbd9460d1f
+GitCommit: dcf058fb559e7918cd77f5f1bb0dfdbcee813571
 Directory: 21/fpm
 
-Tags: 21.0.7-fpm-alpine, 21.0-fpm-alpine, 21-fpm-alpine
+Tags: 21.0.8-fpm-alpine, 21.0-fpm-alpine, 21-fpm-alpine
 Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
-GitCommit: 5a189c719de104a886994f95489e8524d71e36b2
+GitCommit: dcf058fb559e7918cd77f5f1bb0dfdbcee813571
 Directory: 21/fpm-alpine
 
-Tags: 22.2.3-apache, 22.2-apache, 22-apache, stable-apache, production-apache, 22.2.3, 22.2, 22, stable, production
+Tags: 22.2.4-apache, 22.2-apache, 22-apache, 22.2.4, 22.2, 22
 Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: 905972656ea10c399f8f971b96adbdcbd9460d1f
+GitCommit: dcf058fb559e7918cd77f5f1bb0dfdbcee813571
 Directory: 22/apache
 
-Tags: 22.2.3-fpm, 22.2-fpm, 22-fpm, stable-fpm, production-fpm
+Tags: 22.2.4-fpm, 22.2-fpm, 22-fpm
 Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: 905972656ea10c399f8f971b96adbdcbd9460d1f
+GitCommit: dcf058fb559e7918cd77f5f1bb0dfdbcee813571
 Directory: 22/fpm
 
-Tags: 22.2.3-fpm-alpine, 22.2-fpm-alpine, 22-fpm-alpine, stable-fpm-alpine, production-fpm-alpine
+Tags: 22.2.4-fpm-alpine, 22.2-fpm-alpine, 22-fpm-alpine
 Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
-GitCommit: 5a189c719de104a886994f95489e8524d71e36b2
+GitCommit: dcf058fb559e7918cd77f5f1bb0dfdbcee813571
 Directory: 22/fpm-alpine
 
-Tags: 23.0.0-apache, 23.0-apache, 23-apache, apache, 23.0.0, 23.0, 23, latest
+Tags: 23.0.1-apache, 23.0-apache, 23-apache, apache, 23.0.1, 23.0, 23, latest
 Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: e2dc98dea469ba67c3e6474aa4fc2cf902f8e9a4
+GitCommit: dcf058fb559e7918cd77f5f1bb0dfdbcee813571
 Directory: 23/apache
 
-Tags: 23.0.0-fpm, 23.0-fpm, 23-fpm, fpm
+Tags: 23.0.1-fpm, 23.0-fpm, 23-fpm, fpm
 Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: e2dc98dea469ba67c3e6474aa4fc2cf902f8e9a4
+GitCommit: dcf058fb559e7918cd77f5f1bb0dfdbcee813571
 Directory: 23/fpm
 
-Tags: 23.0.0-fpm-alpine, 23.0-fpm-alpine, 23-fpm-alpine, fpm-alpine
+Tags: 23.0.1-fpm-alpine, 23.0-fpm-alpine, 23-fpm-alpine, fpm-alpine
 Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
-GitCommit: 5a189c719de104a886994f95489e8524d71e36b2
+GitCommit: dcf058fb559e7918cd77f5f1bb0dfdbcee813571
 Directory: 23/fpm-alpine

+ 1 - 3
test/config.sh

@@ -143,9 +143,7 @@ imageTests+=(
 		mysql-log-bin
 	'
 	[nextcloud]='
-		nextcloud-cli-mysql
-		nextcloud-cli-postgres
-		nextcloud-cli-sqlite
+		nextcloud-cli
 	'
 	[nextcloud:apache]='
 		nextcloud-apache-run

+ 19 - 0
test/tests/cheeky-retries.sh

@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+
+# intended to be symlinked as "run.sh" next to "real-run.sh" such that we give "real-run.sh" a couple tries to succeed before we give up
+
+dir="$(dirname "$BASH_SOURCE")"
+
+tries=3
+while [ "$tries" -gt 0 ]; do
+	(( tries-- )) || :
+	if "$dir/real-run.sh" "$@"; then
+		exit 0
+	fi
+	if [ "$tries" -gt 0 ]; then
+		echo >&2 'warning: failed, retrying'
+	fi
+done
+
+exit 1

+ 39 - 0
test/tests/nextcloud-apache-run/real-run.sh

@@ -0,0 +1,39 @@
+#!/bin/bash
+set -Eeo pipefail
+
+dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
+
+serverImage="$1"
+
+# 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
+
+# Create an instance of the container-under-test
+cid="$(docker run -d "$serverImage")"
+trap "docker rm -vf $cid > /dev/null" EXIT
+#trap "docker logs $cid" ERR
+
+_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 30 '_request GET / --output /dev/null'
+
+# Check that we can request / and that it contains the pattern "Install" somewhere
+# <input type="submit" class="primary" value="Install" data-finishing="Installing …">
+_request GET '/' | grep -i '"Install"' > /dev/null
+# (https://github.com/nextcloud/server/blob/68b2463107774bed28ee9e77b44e7395d49dacee/core/templates/installation.php#L164)

+ 0 - 37
test/tests/nextcloud-apache-run/run.sh

@@ -1,37 +0,0 @@
-#!/bin/bash
-set -eo pipefail
-
-dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
-
-serverImage="$1"
-
-# 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
-
-# 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 30 '_request GET / --output /dev/null'
-
-# Check that we can request / and that it contains the pattern "Finish setup" somewhere
-# <input type="submit" class="primary" value="Finish setup" data-finishing="Finishing …">
-_request GET '/' | grep -i "Finish setup" > /dev/null

+ 1 - 0
test/tests/nextcloud-apache-run/run.sh

@@ -0,0 +1 @@
+../cheeky-retries.sh

+ 22 - 0
test/tests/nextcloud-cli/run.sh

@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+
+# the nextcloud tests are very flaky, so the intent of this test is to make sure at least *one* of them is succeeding
+
+dir="$(dirname "$BASH_SOURCE")"
+tests="$(dirname "$dir")"
+
+ret=1
+for t in \
+	nextcloud-cli-mysql \
+	nextcloud-cli-postgres \
+	nextcloud-cli-sqlite \
+; do
+	if "$tests/$t/run.sh" "$@"; then
+		ret=0
+	else
+		echo >&2 "note: '$t' failed (only fatal if all three do)"
+	fi
+done
+
+exit "$ret"

+ 49 - 0
test/tests/nextcloud-fpm-run/real-run.sh

@@ -0,0 +1,49 @@
+#!/bin/bash
+set -Eeo pipefail
+
+dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
+
+image="$1"
+
+# Build a client image with cgi-fcgi for testing
+clientImage='librarytest/nextcloud-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
+#trap "docker logs $cid" ERR
+
+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" \
+		"$clientImage" \
+		-bind -connect fpm:9000
+}
+
+# Make sure that PHP-FPM is listening and ready
+. "$dir/../../retry.sh" --tries 30 'fcgi-request GET /index.php' > /dev/null 2>&1
+
+# Check that we can request / and that it contains the pattern "Install" somewhere
+# <input type="submit" class="primary" value="Install" data-finishing="Installing …">
+fcgi-request GET '/index.php' | grep -i '"Install"' > /dev/null
+# (https://github.com/nextcloud/server/blob/68b2463107774bed28ee9e77b44e7395d49dacee/core/templates/installation.php#L164)

+ 0 - 47
test/tests/nextcloud-fpm-run/run.sh

@@ -1,47 +0,0 @@
-#!/bin/bash
-set -eo pipefail
-
-dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
-
-image="$1"
-
-# Build a client image with cgi-fcgi for testing
-clientImage='librarytest/nextcloud-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" \
-		"$clientImage" \
-		-bind -connect fpm:9000
-}
-
-# Make sure that PHP-FPM is listening and ready
-. "$dir/../../retry.sh" --tries 30 'fcgi-request GET /index.php' > /dev/null 2>&1
-
-# Check that we can request / and that it contains the pattern "Finish setup" somewhere
-# <input type="submit" class="primary" value="Finish setup" data-finishing="Finishing …">
-fcgi-request GET '/index.php' | grep -i "Finish setup" > /dev/null

+ 1 - 0
test/tests/nextcloud-fpm-run/run.sh

@@ -0,0 +1 @@
+../cheeky-retries.sh