diff --git a/test/config.sh b/test/config.sh index fcdeb8cc7959e..b69f878c995d1 100644 --- a/test/config.sh +++ b/test/config.sh @@ -103,6 +103,15 @@ imageTests+=( julia-hello-world julia-downloads ' + [joomla]=' + joomla-cli-mariadb + ' + [joomla:apache]=' + joomla-apache-run + ' + [joomla:fpm]=' + joomla-fpm-run + ' [logstash]=' logstash-basics ' diff --git a/test/tests/joomla-apache-run/run.sh b/test/tests/joomla-apache-run/run.sh new file mode 100755 index 0000000000000..133764db222f5 --- /dev/null +++ b/test/tests/joomla-apache-run/run.sh @@ -0,0 +1,57 @@ +#!/bin/bash +set -Eeo pipefail + +dir="$(dirname "$(readlink -f "$BASH_SOURCE")")" + +dbImage='mariadb:10.11' +# ensure the dbImage is ready and available +if ! docker image inspect "$dbImage" &> /dev/null; then + docker pull "$dbImage" > /dev/null +fi +serverImage="$1" +dbPass="test-$RANDOM-password-$RANDOM-$$" +dbName="test-$RANDOM-db" +dbUsr="test-$RANDOM-db" + +# 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 +dbCid="$(docker run -d \ + -e MYSQL_RANDOM_ROOT_PASSWORD=yes \ + -e MYSQL_USER="$dbUsr" \ + -e MYSQL_PASSWORD="$dbPass" \ + -e MYSQL_DATABASE="$dbName" \ + "$dbImage")" +trap "docker rm -vf $dbCid > /dev/null" EXIT +cid="$(docker run -d \ + --link "$dbCid":db \ + -e JOOMLA_DB_HOST="db:3306" \ + -e JOOMLA_DB_NAME="$dbName" \ + -e JOOMLA_DB_USER="$dbUsr" \ + -e JOOMLA_DB_PASSWORD="$dbPass" \ + "$serverImage")" +trap "docker rm -vf $cid $dbCid > /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 5 --sleep 10 '_request GET / --output /dev/null' + +# Check that we can request / and that it contains the pattern 'Joomla Installer' somewhere +_request GET '/' | grep -i 'Joomla Installer' diff --git a/test/tests/joomla-cli-mariadb/run.sh b/test/tests/joomla-cli-mariadb/run.sh new file mode 100755 index 0000000000000..342a5f32d5824 --- /dev/null +++ b/test/tests/joomla-cli-mariadb/run.sh @@ -0,0 +1,52 @@ +#!/bin/bash +set -Eeo pipefail + +dir="$(dirname "$(readlink -f "$BASH_SOURCE")")" + +dbImage='mariadb:10.11' +# ensure the dbImage is ready and available +if ! docker image inspect "$dbImage" &> /dev/null; then + docker pull "$dbImage" > /dev/null +fi +serverImage="$1" +dbPass="test-$RANDOM-password-$RANDOM-$$" +dbName="test-$RANDOM-db" +dbUsr="test-$RANDOM-db" + +# Create an instance of the container-under-test +dbCid="$(docker run -d \ + -e MYSQL_RANDOM_ROOT_PASSWORD=yes \ + -e MYSQL_USER="$dbUsr" \ + -e MYSQL_PASSWORD="$dbPass" \ + -e MYSQL_DATABASE="$dbName" \ + "$dbImage")" +trap "docker rm -vf $dbCid > /dev/null" EXIT +cid="$(docker run -d \ + --link "$dbCid":db \ + -e JOOMLA_DB_HOST="db:3306" \ + -e JOOMLA_DB_NAME="$dbName" \ + -e JOOMLA_DB_USER="$dbUsr" \ + -e JOOMLA_DB_PASSWORD="$dbPass" \ + "$serverImage")" +trap "docker rm -vf $cid $dbCid > /dev/null" EXIT + +_cli() { + docker exec -u www-data "$cid" php installation/joomla.php install -n \ + --site-name="test-$RANDOM" \ + --admin-user="test-$RANDOM" \ + --admin-username="test-$RANDOM" \ + --admin-password="test-$RANDOM-password" \ + --admin-email="test@test.test" \ + --db-type="mysql" \ + --db-host="db" \ + --db-user="$dbUsr" \ + --db-pass="$dbPass" \ + --db-name="$dbName" +} + +# Give some time to install +. "$dir/../../retry.sh" --tries 20 --sleep 5 'docker exec "$cid" ls installation/joomla.php' + +# Check if Joomla is installed +_cli +docker exec -u www-data "$cid" php cli/joomla.php list | grep -i 'Joomla!' diff --git a/test/tests/joomla-fpm-run/run.sh b/test/tests/joomla-fpm-run/run.sh new file mode 100755 index 0000000000000..f016c8d56b3b4 --- /dev/null +++ b/test/tests/joomla-fpm-run/run.sh @@ -0,0 +1,67 @@ +#!/bin/bash +set -Eeo pipefail + +dir="$(dirname "$(readlink -f "$BASH_SOURCE")")" + +dbImage='mariadb:10.11' +# ensure the dbImage is ready and available +if ! docker image inspect "$dbImage" &> /dev/null; then + docker pull "$dbImage" > /dev/null +fi +serverImage="$1" +dbPass="test-$RANDOM-password-$RANDOM-$$" +dbName="test-$RANDOM-db" +dbUsr="test-$RANDOM-db" + +# Build a client image with cgi-fcgi for testing +clientImage='librarytest/joomla-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 +dbCid="$(docker run -d \ + -e MYSQL_RANDOM_ROOT_PASSWORD=yes \ + -e MYSQL_USER="$dbUsr" \ + -e MYSQL_PASSWORD="$dbPass" \ + -e MYSQL_DATABASE="$dbName" \ + "$dbImage")" +trap "docker rm -vf $dbCid > /dev/null" EXIT +cid="$(docker run -d \ + --link "$dbCid":db \ + -e JOOMLA_DB_HOST="db:3306" \ + -e JOOMLA_DB_NAME="$dbName" \ + -e JOOMLA_DB_USER="$dbUsr" \ + -e JOOMLA_DB_PASSWORD="$dbPass" \ + "$serverImage")" +trap "docker rm -vf $cid $dbCid > /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 5 --sleep 10 'fcgi-request GET /index.php' > /dev/null 2>&1 + +# Check that we can request / and that it contains the pattern 'Joomla Installer' somewhere +fcgi-request GET '/installation/index.php' #| grep -qi 'Joomla Installer'