Commit 4cdee851 authored by Christian Kuhn's avatar Christian Kuhn Committed by Richard Haeser
Browse files

[TASK] runTests.sh: Proper validation of -a option

Plus: No variable fallback magick in docker-compose.yml,
this belongs to runTests.sh

Change-Id: I9ec8d1ecba695061155807fd44d0a3cb3f342cfd
Resolves: #93514
Releases: master, 10.4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67919


Tested-by: Simon Gilli's avatarSimon Gilli <typo3@gilbertsoft.org>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Richard Haeser's avatarRichard Haeser <richard@richardhaeser.com>
Reviewed-by: Simon Gilli's avatarSimon Gilli <typo3@gilbertsoft.org>
Reviewed-by: Richard Haeser's avatarRichard Haeser <richard@richardhaeser.com>
parent 768285b3
......@@ -30,15 +30,51 @@ setUpDockerComposeDotEnv() {
echo "SCRIPT_VERBOSE=${SCRIPT_VERBOSE}" >> .env
echo "PHPUNIT_RANDOM=${PHPUNIT_RANDOM}" >> .env
echo "CGLCHECK_DRY_RUN=${CGLCHECK_DRY_RUN}" >> .env
echo "DATABASE_DRIVER=${DATABASE_DRIVER}" >> .env
echo "MARIADB_VERSION=${MARIADB_VERSION}" >> .env
echo "MYSQL_VERSION=${MYSQL_VERSION}" >> .env
echo "POSTGRES_VERSION=${POSTGRES_VERSION}" >> .env
echo "PHP_VERSION=${PHP_VERSION}" >> .env
echo "CHUNKS=${CHUNKS}" >> .env
echo "THISCHUNK=${THISCHUNK}" >> .env
}
# Set a custom database driver provided by option: -a
[[ ! -z "$DATABASE_DRIVER" ]] && echo "DATABASE_DRIVER=${DATABASE_DRIVER}" >> .env
# Options -a and -d depend on each other. The function
# validates input combinations and sets defaults.
handleDbmsAndDriverOptions() {
case ${DBMS} in
mariadb)
;&
mysql)
[ -z ${DATABASE_DRIVER} ] && DATABASE_DRIVER="mysqli"
if [ "${DATABASE_DRIVER}" != "mysqli" ] && [ "${DATABASE_DRIVER}" != "pdo_mysql" ]; then
echo "Invalid option -a ${DATABASE_DRIVER} with -d ${DBMS}" >&2
echo >&2
echo "call \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
exit 1
fi
;;
mssql)
[ -z ${DATABASE_DRIVER} ] && DATABASE_DRIVER="sqlsrv"
if [ "${DATABASE_DRIVER}" != "sqlsrv" ] && [ "${DATABASE_DRIVER}" != "pdo_sqlsrv" ]; then
echo "Invalid option -a ${DATABASE_DRIVER} with -d ${DBMS}" >&2
echo >&2
echo "call \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
exit 1
fi
;;
postgres)
;&
sqlite)
if ! [ -z ${DATABASE_DRIVER} ]; then
echo "Invalid option -a ${DATABASE_DRIVER} with -d ${DBMS}" >&2
echo >&2
echo "call \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
exit 1
fi
DATABASE_DRIVER=""
;;
esac
}
# Load help text into $HELP
......@@ -367,19 +403,20 @@ fi
# Suite execution
case ${TEST_SUITE} in
acceptance)
handleDbmsAndDriverOptions
setUpDockerComposeDotEnv
if [ ${CHUNKS} -gt 1 ]; then
docker-compose run acceptance_split
fi
case ${DBMS} in
mysql)
[[ ! -z "$DATABASE_DRIVER" ]] && echo "Using driver: ${DATABASE_DRIVER}"
echo "Using driver: ${DATABASE_DRIVER}"
docker-compose run prepare_acceptance_backend_mysql
docker-compose run acceptance_backend_mysql
SUITE_EXIT_CODE=$?
;;
mariadb)
[[ ! -z "$DATABASE_DRIVER" ]] && echo "Using driver: ${DATABASE_DRIVER}"
echo "Using driver: ${DATABASE_DRIVER}"
docker-compose run prepare_acceptance_backend_mariadb
docker-compose run acceptance_backend_mariadb
SUITE_EXIT_CODE=$?
......@@ -548,25 +585,26 @@ case ${TEST_SUITE} in
docker-compose down
;;
functional)
handleDbmsAndDriverOptions
setUpDockerComposeDotEnv
if [ ${CHUNKS} -gt 1 ]; then
docker-compose run functional_split
fi
case ${DBMS} in
mariadb)
[[ ! -z "$DATABASE_DRIVER" ]] && echo "Using driver: ${DATABASE_DRIVER}"
echo "Using driver: ${DATABASE_DRIVER}"
docker-compose run prepare_functional_mariadb
docker-compose run functional_mariadb
SUITE_EXIT_CODE=$?
;;
mysql)
[[ ! -z "$DATABASE_DRIVER" ]] && echo "Using driver: ${DATABASE_DRIVER}"
echo "Using driver: ${DATABASE_DRIVER}"
docker-compose run prepare_functional_mysql
docker-compose run functional_mysql
SUITE_EXIT_CODE=$?
;;
mssql)
[[ ! -z "$DATABASE_DRIVER" ]] && echo "Using driver: ${DATABASE_DRIVER}"
echo "Using driver: ${DATABASE_DRIVER}"
docker-compose run prepare_functional_mssql2019latest
docker-compose run functional_mssql2019latest
SUITE_EXIT_CODE=$?
......@@ -590,16 +628,17 @@ case ${TEST_SUITE} in
docker-compose down
;;
install)
handleDbmsAndDriverOptions
setUpDockerComposeDotEnv
case ${DBMS} in
mysql)
[[ ! -z "$DATABASE_DRIVER" ]] && echo "Using driver: ${DATABASE_DRIVER}"
echo "Using driver: ${DATABASE_DRIVER}"
docker-compose run prepare_acceptance_install_mysql
docker-compose run acceptance_install_mysql
SUITE_EXIT_CODE=$?
;;
mariadb)
[[ ! -z "$DATABASE_DRIVER" ]] && echo "Using driver: ${DATABASE_DRIVER}"
echo "Using driver: ${DATABASE_DRIVER}"
docker-compose run prepare_acceptance_install_mariadb
docker-compose run acceptance_install_mariadb
SUITE_EXIT_CODE=$?
......@@ -691,13 +730,13 @@ esac
case ${DBMS} in
mariadb)
DBMS_OUTPUT="DBMS: ${DBMS} version ${MARIADB_VERSION} driver ${DATABASE_DRIVER:-mysqli}"
DBMS_OUTPUT="DBMS: ${DBMS} version ${MARIADB_VERSION} driver ${DATABASE_DRIVER}"
;;
mysql)
DBMS_OUTPUT="DBMS: ${DBMS} version ${MYSQL_VERSION} driver ${DATABASE_DRIVER:-mysqli}"
DBMS_OUTPUT="DBMS: ${DBMS} version ${MYSQL_VERSION} driver ${DATABASE_DRIVER}"
;;
mssql)
DBMS_OUTPUT="DBMS: ${DBMS} driver ${DATABASE_DRIVER:-sqlsrv}"
DBMS_OUTPUT="DBMS: ${DBMS} driver ${DATABASE_DRIVER}"
;;
postgres)
DBMS_OUTPUT="DBMS: ${DBMS} version ${POSTGRES_VERSION}"
......
......@@ -845,7 +845,7 @@ services:
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
environment:
typo3DatabaseDriver: "${DATABASE_DRIVER:-mysqli}"
typo3DatabaseDriver: "${DATABASE_DRIVER}"
typo3DatabaseName: func_test
typo3DatabaseUsername: root
typo3DatabasePassword: funcp
......@@ -899,7 +899,7 @@ services:
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
environment:
typo3DatabaseDriver: "${DATABASE_DRIVER:-mysqli}"
typo3DatabaseDriver: "${DATABASE_DRIVER}"
typo3DatabaseName: func_test
typo3DatabaseUsername: root
typo3DatabasePassword: funcp
......@@ -954,7 +954,7 @@ services:
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
environment:
typo3DatabaseDriver: "${DATABASE_DRIVER:-sqlsrv}"
typo3DatabaseDriver: "${DATABASE_DRIVER}"
typo3DatabaseName: func
typo3DatabasePassword: "Test1234!"
typo3DatabaseUsername: SA
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment