-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Testsuite for Joomla #14630
Open
J0WI
wants to merge
1
commit into
docker-library:master
Choose a base branch
from
J0WI:joomla-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Testsuite for Joomla #14630
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="[email protected]" \ | ||
--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!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically I advise against using random variables in unit tests - you want them to be perfectly replicable on each run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In these tests, we encourage random variance because it usually increases the chances that the test is actually testing something meaningful instead of just hitting the happy path every time (for example, putting a "default" value in the test that just happens to work because it matches the default of the image when the image wouldn't handle a non-default value, for example).