aboutsummaryrefslogtreecommitdiffstats
path: root/autotest.sh
diff options
context:
space:
mode:
Diffstat (limited to 'autotest.sh')
-rwxr-xr-xautotest.sh222
1 files changed, 171 insertions, 51 deletions
diff --git a/autotest.sh b/autotest.sh
index 33c4ad50de8..32a844a670d 100755
--- a/autotest.sh
+++ b/autotest.sh
@@ -1,36 +1,35 @@
#!/usr/bin/env bash
#
-# ownCloud
-#
-# @author Vincent Petry
-# @author Morris Jobke
-# @author Robin McCorkell
-# @author Thomas Müller
-# @author Andreas Fischer
-# @author Joas Schilling
-# @author Lukas Reschke
-# @author Jörn Friedrich Dreyer
-# @copyright 2012-2015 Thomas Müller thomas.mueller@tmit.eu
+# SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+# SPDX-FileCopyrightText: 2012-2016 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
-#$EXECUTOR_NUMBER is set by Jenkins and allows us to run autotest in parallel
-DATABASENAME=oc_autotest$EXECUTOR_NUMBER
-DATABASEUSER=oc_autotest$EXECUTOR_NUMBER
+DATABASENAME=oc_autotest
+DATABASEUSER=oc_autotest
DATABASEHOST=localhost
-ADMINLOGIN=admin$EXECUTOR_NUMBER
+ADMINLOGIN=admin
BASEDIR=$PWD
PRIMARY_STORAGE_CONFIGS="local swift"
-DBCONFIGS="sqlite mysql mariadb pgsql oci"
+DBCONFIGS="sqlite mysql mariadb pgsql oci mysqlmb4"
-# $PHP_EXE is run through 'which' and as such e.g. 'php' or 'hhvm' is usually
+# $PHP_EXE is run through 'which' and as such e.g. 'php' is usually
# sufficient. Due to the behaviour of 'which', $PHP_EXE may also be a path
# (absolute or not) to an executable, e.g. ./code/projects/php-src/sapi/cli/php.
if [ -z "$PHP_EXE" ]; then
PHP_EXE=php
fi
PHP=$(which "$PHP_EXE")
-PHPUNIT=$(which phpunit)
+if [ -z "$PHPUNIT_EXE" ]; then
+ if [ -f lib/composer/bin/phpunit ]; then
+ PHPUNIT_EXE="./lib/composer/bin/phpunit"
+ PHPUNIT=$(readlink -f "$PHPUNIT_EXE")
+ else
+ PHPUNIT_EXE=phpunit
+ PHPUNIT=$(which "$PHPUNIT_EXE")
+ fi
+fi
set -e
@@ -54,7 +53,8 @@ else
fi
if ! [ -x "$PHPUNIT" ]; then
- echo "phpunit executable not found, please install phpunit version >= 3.7" >&2
+ echo "phpunit executable not found, please install phpunit version >= 10.5 manually or via:" >&2
+ echo " composer install" >&2
exit 3
fi
@@ -69,8 +69,8 @@ PHPUNIT_VERSION=$($PHPUNIT --version | cut -d" " -f2)
PHPUNIT_MAJOR_VERSION=$(echo "$PHPUNIT_VERSION" | cut -d"." -f1)
PHPUNIT_MINOR_VERSION=$(echo "$PHPUNIT_VERSION" | cut -d"." -f2)
-if ! [ "$PHPUNIT_MAJOR_VERSION" -gt 4 -o \( "$PHPUNIT_MAJOR_VERSION" -eq 4 -a "$PHPUNIT_MINOR_VERSION" -ge 4 \) ]; then
- echo "phpunit version >= 4.4 required. Version found: $PHPUNIT_VERSION" >&2
+if ! [ "$PHPUNIT_MAJOR_VERSION" -gt 10 -o \( "$PHPUNIT_MAJOR_VERSION" -eq 10 -a "$PHPUNIT_MINOR_VERSION" -ge 5 \) ]; then
+ echo "phpunit version >= 10.5 required. Version found: $PHPUNIT_VERSION" >&2
exit 4
fi
@@ -110,9 +110,6 @@ else
PRIMARY_STORAGE_CONFIG="local"
fi
-# check for the presence of @since in all OCP methods
-$PHP build/OCPSinceChecker.php
-
# Back up existing (dev) config if one exists and backup not already there
if [ -f config/config.php ] && [ ! -f config/config-autotest-backup.php ]; then
mv config/config.php config/config-autotest-backup.php
@@ -143,6 +140,15 @@ function cleanup_config {
if [ -f config/autotest-storage-swift.config.php ]; then
rm config/autotest-storage-swift.config.php
fi
+ # Remove autotest redis config
+ if [ -f config/redis.config.php ]; then
+ rm config/redis.config.php
+ fi
+ # Remove mysqlmb4.config.php
+ rm -f config/mysqlmb4.config.php
+
+ # restore .htaccess
+ git restore .htaccess
}
# restore config on exit
@@ -176,11 +182,86 @@ function execute_tests {
fi
cp tests/preseed-config.php config/config.php
+ if [ "$ENABLE_REDIS" == "true" ] ; then
+ cp tests/redis.config.php config/redis.config.php
+ elif [ "$ENABLE_REDIS_CLUSTER" == "true" ] ; then
+ cp tests/redis-cluster.config.php config/redis.config.php
+ fi
+
_DB=$DB
# drop database
if [ "$DB" == "mysql" ] ; then
- mysql -u "$DATABASEUSER" -powncloud -e "DROP DATABASE IF EXISTS $DATABASENAME" -h $DATABASEHOST || true
+ if [ ! -z "$USEDOCKER" ] ; then
+ echo "Fire up the mysql docker"
+ DOCKER_CONTAINER_ID=$(docker run \
+ -v $BASEDIR/tests/docker/mariadb:/etc/mysql/conf.d \
+ -e MYSQL_ROOT_PASSWORD=owncloud \
+ -e MYSQL_USER="$DATABASEUSER" \
+ -e MYSQL_PASSWORD=owncloud \
+ -e MYSQL_DATABASE="$DATABASENAME" \
+ -d mysql)
+ DATABASEHOST=$(docker inspect --format="{{.NetworkSettings.IPAddress}}" "$DOCKER_CONTAINER_ID")
+
+ else
+ if [ -z "$DRONE" ] ; then # no need to drop the DB when we are on CI
+ if [ "mysql" != "$(mysql --version | grep -o mysql)" ] ; then
+ echo "Your mysql binary is not provided by mysql"
+ echo "To use the docker container set the USEDOCKER environment variable"
+ exit -1
+ fi
+ mysql -u "$DATABASEUSER" -powncloud -e "DROP DATABASE IF EXISTS $DATABASENAME" -h $DATABASEHOST || true
+ else
+ DATABASEHOST=mysql
+ fi
+ fi
+ echo "Waiting for MySQL initialisation ..."
+ if ! apps/files_external/tests/env/wait-for-connection $DATABASEHOST 3306 300; then
+ echo "[ERROR] Waited 300 seconds, no response" >&2
+ exit 1
+ fi
+ fi
+ if [ "$DB" == "mysqlmb4" ] ; then
+ if [ ! -z "$USEDOCKER" ] ; then
+ echo "Fire up the mysql docker"
+ DOCKER_CONTAINER_ID=$(docker run \
+ -v $BASEDIR/tests/docker/mysqlmb4:/etc/mysql/conf.d \
+ -e MYSQL_ROOT_PASSWORD=owncloud \
+ -e MYSQL_USER="$DATABASEUSER" \
+ -e MYSQL_PASSWORD=owncloud \
+ -e MYSQL_DATABASE="$DATABASENAME" \
+ -d mysql:5.7 \
+ --innodb_large_prefix=true \
+ --innodb_file_format=barracuda \
+ --innodb_file_per_table=true)
+
+ DATABASEHOST=$(docker inspect --format="{{.NetworkSettings.IPAddress}}" "$DOCKER_CONTAINER_ID")
+
+ else
+ if [ -z "$DRONE" ] ; then # no need to drop the DB when we are on CI
+ if [ "mysql" != "$(mysql --version | grep -o mysql)" ] ; then
+ echo "Your mysql binary is not provided by mysql"
+ echo "To use the docker container set the USEDOCKER environment variable"
+ exit -1
+ fi
+ mysql -u "$DATABASEUSER" -powncloud -e "DROP DATABASE IF EXISTS $DATABASENAME" -h $DATABASEHOST || true
+ else
+ DATABASEHOST=mysqlmb4
+ fi
+ fi
+
+ echo "Waiting for MySQL(utf8mb4) initialisation ..."
+
+ if ! apps/files_external/tests/env/wait-for-connection $DATABASEHOST 3306 300; then
+ echo "[ERROR] Waited 300 seconds, no response" >&2
+ exit 1
+ fi
+ sleep 1
+
+ echo "MySQL(utf8mb4) is up."
+ _DB="mysql"
+
+ cp tests/docker/mysqlmb4.config.php config
fi
if [ "$DB" == "mariadb" ] ; then
if [ ! -z "$USEDOCKER" ] ; then
@@ -195,20 +276,30 @@ function execute_tests {
DATABASEHOST=$(docker inspect --format="{{.NetworkSettings.IPAddress}}" "$DOCKER_CONTAINER_ID")
echo "Waiting for MariaDB initialisation ..."
- if ! apps/files_external/tests/env/wait-for-connection $DATABASEHOST 3306 60; then
- echo "[ERROR] Waited 60 seconds, no response" >&2
+ if ! apps/files_external/tests/env/wait-for-connection $DATABASEHOST 3306 300; then
+ echo "[ERROR] Waited 300 seconds, no response" >&2
exit 1
fi
echo "MariaDB is up."
else
- if [ "MariaDB" != "$(mysql --version | grep -o MariaDB)" ] ; then
- echo "Your mysql binary is not provided by MariaDB"
- echo "To use the docker container set the USEDOCKER environment variable"
- exit -1
+ if [ -z "$DRONE" ] ; then # no need to drop the DB when we are on CI
+ if [ "MariaDB" != "$(mysql --version | grep -o MariaDB)" ] ; then
+ echo "Your mysql binary is not provided by MariaDB"
+ echo "To use the docker container set the USEDOCKER environment variable"
+ exit -1
+ fi
+ mysql -u "$DATABASEUSER" -powncloud -e "DROP DATABASE IF EXISTS $DATABASENAME" -h $DATABASEHOST || true
+ else
+ DATABASEHOST=mariadb
fi
- mysql -u "$DATABASEUSER" -powncloud -e "DROP DATABASE IF EXISTS $DATABASENAME" -h $DATABASEHOST || true
+ fi
+
+ echo "Waiting for MariaDB initialisation ..."
+ if ! apps/files_external/tests/env/wait-for-connection $DATABASEHOST 3306 300; then
+ echo "[ERROR] Waited 300 seconds, no response" >&2
+ exit 1
fi
#Reset _DB to mysql since that is what we use internally
@@ -217,17 +308,32 @@ function execute_tests {
if [ "$DB" == "pgsql" ] ; then
if [ ! -z "$USEDOCKER" ] ; then
echo "Fire up the postgres docker"
- DOCKER_CONTAINER_ID=$(docker run -e POSTGRES_USER="$DATABASEUSER" -e POSTGRES_PASSWORD=owncloud -d postgres)
+ DOCKER_CONTAINER_ID=$(docker run -e POSTGRES_DB="$DATABASENAME" -e POSTGRES_USER="$DATABASEUSER" -e POSTGRES_PASSWORD=owncloud -d postgres)
DATABASEHOST=$(docker inspect --format="{{.NetworkSettings.IPAddress}}" "$DOCKER_CONTAINER_ID")
echo "Waiting for Postgres initialisation ..."
- # grep exits on the first match and then the script continues
- docker logs -f "$DOCKER_CONTAINER_ID" 2>&1 | grep -q "database system is ready to accept connections"
+ if ! apps/files_external/tests/env/wait-for-connection $DATABASEHOST 5432 60; then
+ echo "[ERROR] Waited 60 seconds for $DATABASEHOST, no response" >&2
+ exit 1
+ fi
echo "Postgres is up."
else
- dropdb -U "$DATABASEUSER" "$DATABASENAME" || true
+ if [ ! -z "$DRONE" ] ; then
+ DATABASEHOST="postgres-$POSTGRES"
+ fi
+ echo "Waiting for Postgres to be available ..."
+ if ! apps/files_external/tests/env/wait-for-connection $DATABASEHOST 5432 60; then
+ echo "[ERROR] Waited 60 seconds for $DATABASEHOST, no response" >&2
+ exit 1
+ fi
+ echo "Give it 10 additional seconds ..."
+ sleep 10
+
+ if [ -z "$DRONE" ] ; then # no need to drop the DB when we are on CI
+ dropdb -U "$DATABASEUSER" "$DATABASENAME" || true
+ fi
fi
fi
if [ "$DB" == "oci" ] ; then
@@ -238,13 +344,13 @@ function execute_tests {
echo "Waiting for Oracle initialization ... "
# Try to connect to the OCI host via sqlplus to ensure that the connection is already running
- for i in {1..48}
- do
- if sqlplus "system/oracle@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=$DATABASEHOST)(Port=1521))(CONNECT_DATA=(SID=XE)))" < /dev/null | grep 'Connected to'; then
- break;
- fi
- sleep 5
- done
+ for i in {1..48}
+ do
+ if sqlplus "autotest/owncloud@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=$DATABASEHOST)(Port=1521))(CONNECT_DATA=(SID=XE)))" < /dev/null | grep 'Connected to'; then
+ break;
+ fi
+ sleep 5
+ done
DATABASEUSER=autotest
DATABASENAME='XE'
@@ -252,7 +358,7 @@ function execute_tests {
# trigger installation
echo "Installing ...."
- "$PHP" ./occ maintenance:install -vvv --database="$_DB" --database-name="$DATABASENAME" --database-host="$DATABASEHOST" --database-user="$DATABASEUSER" --database-pass=owncloud --database-table-prefix=oc_ --admin-user="$ADMINLOGIN" --admin-pass=admin --data-dir="$DATADIR"
+ "$PHP" ./occ maintenance:install -vvv --database="$_DB" --database-name="$DATABASENAME" --database-host="$DATABASEHOST" --database-user="$DATABASEUSER" --database-pass=owncloud --admin-user="$ADMINLOGIN" --admin-pass=admin --data-dir="$DATADIR"
#test execution
echo "Testing with $DB ..."
@@ -264,11 +370,23 @@ function execute_tests {
export XDEBUG_CONFIG=$_XDEBUG_CONFIG
fi
GROUP=''
+ if [ "$TEST_SELECTION" == "QUICKDB" ]; then
+ GROUP='--group DB --exclude-group=SLOWDB'
+ fi
if [ "$TEST_SELECTION" == "DB" ]; then
- GROUP='--group DB'
+ GROUP='--group DB,SLOWDB'
fi
if [ "$TEST_SELECTION" == "NODB" ]; then
- GROUP='--exclude-group DB'
+ GROUP='--exclude-group DB,SLOWDB'
+ fi
+ if [ "$TEST_SELECTION" == "PRIMARY-s3" ]; then
+ GROUP='--group PRIMARY-s3'
+ fi
+ if [ "$TEST_SELECTION" == "PRIMARY-azure" ]; then
+ GROUP='--group PRIMARY-azure'
+ fi
+ if [ "$TEST_SELECTION" == "PRIMARY-swift" ]; then
+ GROUP='--group PRIMARY-swift'
fi
COVER=''
@@ -277,9 +395,10 @@ function execute_tests {
else
echo "No coverage"
fi
- echo "${PHPUNIT[@]}" --configuration phpunit-autotest.xml $GROUP $COVER --log-junit "autotest-results-$DB.xml" "$2" "$3"
- "${PHPUNIT[@]}" --configuration phpunit-autotest.xml $GROUP $COVER --log-junit "autotest-results-$DB.xml" "$2" "$3"
- RESULT=$?
+
+ echo "$PHPUNIT" --colors=always --configuration phpunit-autotest.xml $GROUP $COVER --log-junit "autotest-results-$DB.xml" "$2" "$3"
+ "$PHPUNIT" --colors=always --configuration phpunit-autotest.xml $GROUP $COVER --log-junit "autotest-results-$DB.xml" "$2" "$3"
+ RESULT=$?
if [ "$PRIMARY_STORAGE_CONFIG" == "swift" ] ; then
cd ..
@@ -306,7 +425,7 @@ if [ -z "$1" ]
done
else
FILENAME="$2"
- if [ ! -z "$2" ] && [ ! -f "tests/$FILENAME" ]; then
+ if [ ! -z "$2" ] && [ ! -f "tests/$FILENAME" ] && [ "${FILENAME:0:2}" != "--" ]; then
FILENAME="../$FILENAME"
fi
execute_tests "$1" "$FILENAME" "$3"
@@ -326,7 +445,8 @@ fi
# NOTES on pgsql:
# - su - postgres
# - createuser -P oc_autotest (enter password and enable superuser)
-# - to enable dropdb I decided to add following line to pg_hba.conf (this is not the safest way but I don't care for the testing machine):
+# - to enable dropdb I decided to add following line to pg_hba.conf
+# (this is not the safest way but I don't care for the testing machine):
# local all all trust
#
# - for parallel executor support with EXECUTOR_NUMBER=0: