Skip to content
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 first functional tests #153

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ on:
jobs:
testsuite:
name: all tests
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
matrix:
php: ['8.0', '8.1', '8.2']
php: ['8.1', '8.2']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -31,3 +31,6 @@ jobs:

- name: Unit tests
run: mkdir -p .Build/Web/typo3conf/ && rm -rf .Build/Web/typo3conf/ext && ln -sfn ../../../../ .Build/Web/typo3conf/ext && Build/Scripts/runTests.sh -p ${{ matrix.php }} -s unit

- name: Functional tests
run: mkdir -p .Build/Web/typo3conf/ && rm -rf .Build/Web/typo3conf/ext && ln -sfn ../../../../ .Build/Web/typo3conf/ext && Build/Scripts/runTests.sh -p ${{ matrix.php }} -d sqlite -s functional
13 changes: 13 additions & 0 deletions Build/FunctionalTests.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" backupGlobals="true" bootstrap="FunctionalTestsBootstrap.php" cacheResult="false" colors="true" processIsolation="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" failOnWarning="true" cacheDirectory=".phpunit.cache" requireCoverageMetadata="false">
<testsuites>
<testsuite name="Functional tests">
<directory>../Tests/Functional/</directory>
</testsuite>
</testsuites>
<php>
<const name="TYPO3_MODE" value="BE"/>
<ini name="display_errors" value="1"/>
<env name="TYPO3_CONTEXT" value="Testing"/>
</php>
</phpunit>
30 changes: 30 additions & 0 deletions Build/FunctionalTestsBootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

/**
* Boilerplate for a functional test phpunit bootstrap file.
*
* This file is loosely maintained within TYPO3 testing-framework, extensions
* are encouraged to not use it directly, but to copy it to an own place,
* usually in parallel to a FunctionalTests.xml file.
*
* This file is defined in FunctionalTests.xml and called by phpunit
* before instantiating the test suites.
*/
(static function () {
$testbase = new \TYPO3\TestingFramework\Core\Testbase();
$testbase->defineOriginalRootPath();
$testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/tests');
$testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/transient');
})();
54 changes: 25 additions & 29 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
#

# Function to write a .env file in Build/testing-docker/local
# This is read by docker-compose and vars defined here are
# used in Build/testing-docker/local/docker-compose.yml
# This is read by docker compose and vars defined here are
# used in Build/testing-docker/local/docker compose.yml
setUpDockerComposeDotEnv() {
# Delete possibly existing local .env file if exists
[ -e .env ] && rm .env
# Set up a new .env file for docker-compose
# Set up a new .env file for docker compose
echo "COMPOSE_PROJECT_NAME=local" >> .env
# To prevent access rights of files created by the testing, the docker image later
# runs with the same user that is currently executing the script. docker-compose can't
# runs with the same user that is currently executing the script. docker compose can't
# use $UID directly itself since it is a shell variable and not an env variable, so
# we have to set it explicitly here.
echo "HOST_UID=`id -u`" >> .env
Expand Down Expand Up @@ -103,18 +103,12 @@ Examples:
./Build/Scripts/runTests.sh -p 7.3
EOF

# Test if docker-compose exists, else exit out with error
if ! type "docker-compose" > /dev/null; then
echo "This script relies on docker and docker-compose. Please install" >&2
exit 1
fi

# Go to the directory this script is located, so everything else is relative
# to this dir, no matter from where this script is called.
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
cd "$THIS_SCRIPT_DIR" || exit 1

# Go to directory that contains the local docker-compose.yml file
# Go to directory that contains the local docker compose.yml file
cd ../testing-docker || exit 1

# Option defaults
Expand Down Expand Up @@ -200,41 +194,41 @@ fi
case ${TEST_SUITE} in
composerInstall)
setUpDockerComposeDotEnv
docker-compose run composer_install
docker compose run composer_install
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
composerInstallMax)
setUpDockerComposeDotEnv
docker-compose run composer_install_max
docker compose run composer_install_max
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
composerInstallMin)
setUpDockerComposeDotEnv
docker-compose run composer_install_min
docker compose run composer_install_min
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
composerValidate)
setUpDockerComposeDotEnv
docker-compose run composer_validate
docker compose run composer_validate
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
functional)
setUpDockerComposeDotEnv
case ${DBMS} in
mariadb)
docker-compose run functional_mariadb10
docker compose run functional_mariadb10
SUITE_EXIT_CODE=$?
;;
mssql)
docker-compose run functional_mssql2019latest
docker compose run functional_mssql2019latest
SUITE_EXIT_CODE=$?
;;
postgres)
docker-compose run functional_postgres10
docker compose run functional_postgres10
SUITE_EXIT_CODE=$?
;;
sqlite)
Expand All @@ -243,7 +237,9 @@ case ${TEST_SUITE} in
# root if docker creates it. Thank you, docker. We create the path beforehand
# to avoid permission issues.
mkdir -p ${ROOT_DIR}/.Build/Web/typo3temp/var/tests/functional-sqlite-dbs/
docker-compose run functional_sqlite
rm -rf ${ROOT_DIR}/.Build/minio-data || true
cp -a ${ROOT_DIR}/Build/testing-docker/minio-data ${ROOT_DIR}/.Build/minio-data
docker compose run --rm functional_sqlite
SUITE_EXIT_CODE=$?
;;
*)
Expand All @@ -252,19 +248,19 @@ case ${TEST_SUITE} in
echo "${HELP}" >&2
exit 1
esac
docker-compose down
docker compose down
;;
lint)
setUpDockerComposeDotEnv
docker-compose run lint
docker compose run lint
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
unit)
setUpDockerComposeDotEnv
docker-compose run unit
docker compose run unit
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
update)
# pull typo3/core-testing-*:latest versions of those ones that exist locally
Expand All @@ -279,4 +275,4 @@ case ${TEST_SUITE} in
exit 1
esac

exit $SUITE_EXIT_CODE
exit $SUITE_EXIT_CODE
61 changes: 35 additions & 26 deletions Build/testing-docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ services:
tmpfs:
- /var/lib/postgresql/data:rw,noexec,nosuid

minio:
image: minio/minio
user: ${HOST_UID}
command: server /minio-data
volumes:
- ../../.Build/minio-data:/minio-data

composer_install:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
Expand Down Expand Up @@ -139,13 +146,13 @@ services:
echo Database is up;
php -v | grep '^PHP';
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
export XDEBUG_MODE=\"off\"
bin/phpunit -c Web/typo3conf/ext/aus_driver_amazon_s3/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
export DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
export XDEBUG_MODE=\"debug,develop\"
export XDEBUG_TRIGGER=\"foo\"
export XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\"
bin/phpunit -c Web/typo3conf/ext/aus_driver_amazon_s3/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
fi
"
Expand Down Expand Up @@ -182,13 +189,13 @@ services:
echo Database is up;
php -v | grep '^PHP';
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
export XDEBUG_MODE=\"off\"
bin/phpunit -c Web/typo3conf/ext/aus_driver_amazon_s3/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-mssql ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
export DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
export XDEBUG_MODE=\"debug,develop\"
export XDEBUG_TRIGGER=\"foo\"
export XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\"
bin/phpunit -c Web/typo3conf/ext/aus_driver_amazon_s3/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-mssql ${TEST_FILE};
fi
"
Expand Down Expand Up @@ -222,20 +229,22 @@ services:
echo Database is up;
php -v | grep '^PHP';
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
export XDEBUG_MODE=\"off\"
bin/phpunit -c Web/typo3conf/ext/aus_driver_amazon_s3/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-postgres ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
export DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
export XDEBUG_MODE=\"debug,develop\"
export XDEBUG_TRIGGER=\"foo\"
export XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\"
bin/phpunit -c Web/typo3conf/ext/aus_driver_amazon_s3/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-postgres ${TEST_FILE};
fi
"

functional_sqlite:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
links:
- minio
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
- ${HOST_HOME}:${HOST_HOME}
Expand All @@ -253,13 +262,13 @@ services:
fi
php -v | grep '^PHP';
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
export XDEBUG_MODE=\"off\"
bin/phpunit -c Web/typo3conf/ext/aus_driver_amazon_s3/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-sqlite ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
export DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
export XDEBUG_MODE=\"debug,develop\"
export XDEBUG_TRIGGER=\"foo\"
export XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\"
bin/phpunit -c Web/typo3conf/ext/aus_driver_amazon_s3/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-sqlite ${TEST_FILE};
fi
"
Expand Down Expand Up @@ -297,13 +306,13 @@ services:
fi
php -v | grep '^PHP'
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
export XDEBUG_MODE=\"off\"
bin/phpunit -c Web/typo3conf/ext/aus_driver_amazon_s3/Build/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
export DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
export XDEBUG_MODE=\"debug,develop\"
export XDEBUG_TRIGGER=\"foo\"
export XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\"
bin/phpunit -c Web/typo3conf/ext/aus_driver_amazon_s3/Build/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
fi
"
"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions Build/testing-docker/minio-data/.minio.sys/format.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"1","format":"xl-single","id":"c47cf73c-fb20-444e-bdab-048ef7dabead","xl":{"version":"3","this":"e985e316-adcb-48e4-85e5-702c21c608b7","sets":[["e985e316-adcb-48e4-85e5-702c21c608b7"]],"distributionAlgo":"SIPMOD+PARITY"}}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
27 changes: 27 additions & 0 deletions Build/testing-docker/prepare-minio-data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
#prepare the minio-data directory that is being used as test basis
set -ex

which mc >> /dev/null || (echo 'Minio client executable not found'; exit 1)

rm -r minio-data || true
rm -r ../../.Build/minio-data || true
mkdir ../../.Build/minio-data

docker stop minio-setup || true
docker-compose run -d --rm --name minio-setup -p 9000:9000 minio
# minio needs some time to start up
sleep 5

mc alias remove typo3s3test || true
mc alias set typo3s3test http://127.0.0.1:9000 minioadmin minioadmin
mc mb typo3s3test/test-bucket/
mc anonymous set download typo3s3test/test-bucket/
mc admin user add typo3s3test test-key test-secretkey
mc admin policy attach typo3s3test readwrite --user test-key

mc cp --recursive ../../Tests/Functional/Bucketfiles/* typo3s3test/test-bucket/

docker stop minio-setup
cp -a ../../.Build/minio-data .
rm -r minio-data/.minio.sys/tmp/.trash/*
1 change: 1 addition & 0 deletions Tests/Functional/Bucketfiles/23.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42
1 change: 1 addition & 0 deletions Tests/Functional/Bucketfiles/folder1/1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
1 change: 1 addition & 0 deletions Tests/Functional/Bucketfiles/folder1/2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
1 change: 1 addition & 0 deletions Tests/Functional/Bucketfiles/folder1/subfolder11/11.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11
1 change: 1 addition & 0 deletions Tests/Functional/Bucketfiles/folder1/subfolder12/12.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
1 change: 1 addition & 0 deletions Tests/Functional/Bucketfiles/folder2/2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
Binary file added Tests/Functional/Bucketfiles/images/bytes-1009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading