Skip to content
Snippets Groups Projects
Commit ea9eabae authored by Roeland Jago Douma's avatar Roeland Jago Douma
Browse files

Add possible use of docker instance for MariaDB

parent 4edfadac
Branches
No related tags found
No related merge requests found
...@@ -21,7 +21,7 @@ DATABASEHOST=localhost ...@@ -21,7 +21,7 @@ DATABASEHOST=localhost
ADMINLOGIN=admin$EXECUTOR_NUMBER ADMINLOGIN=admin$EXECUTOR_NUMBER
BASEDIR=$PWD BASEDIR=$PWD
DBCONFIGS="sqlite mysql pgsql oci" DBCONFIGS="sqlite mysql mariadb pgsql oci"
# $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' or 'hhvm' is usually
# sufficient. Due to the behaviour of 'which', $PHP_EXE may also be a path # sufficient. Due to the behaviour of 'which', $PHP_EXE may also be a path
...@@ -127,7 +127,8 @@ fi ...@@ -127,7 +127,8 @@ fi
echo "Using database $DATABASENAME" echo "Using database $DATABASENAME"
function execute_tests { function execute_tests {
echo "Setup environment for $1 testing ..." DB=$1
echo "Setup environment for $DB testing ..."
# back to root folder # back to root folder
cd "$BASEDIR" cd "$BASEDIR"
...@@ -140,11 +141,43 @@ function execute_tests { ...@@ -140,11 +141,43 @@ function execute_tests {
cp tests/preseed-config.php config/config.php cp tests/preseed-config.php config/config.php
_DB=$DB
# drop database # drop database
if [ "$1" == "mysql" ] ; then if [ "$DB" == "mysql" ] ; then
mysql -u "$DATABASEUSER" -powncloud -e "DROP DATABASE IF EXISTS $DATABASENAME" -h $DATABASEHOST || true
fi
if [ "$DB" == "mariadb" ] ; then
if [ ! -z "$USEDOCKER" ] ; then
echo "Fire up the mariadb docker"
DOCKER_CONTAINER_ID=$(docker run \
-e MYSQL_ROOT_PASSWORD=owncloud \
-e MYSQL_USER="$DATABASEUSER" \
-e MYSQL_PASSWORD=owncloud \
-e MYSQL_DATABASE="$DATABASENAME" \
-d rullzer/mariadb-owncloud)
DATABASEHOST=$(docker inspect "$DOCKER_CONTAINER_ID" | grep IPAddress | cut -d '"' -f 4)
echo "Waiting for MariaDB initialisation ..."
# grep exits on the first match and then the script continues
timeout 30 docker logs -f $DOCKER_CONTAINER_ID 2>&1 | grep -q "mysqld: ready for connections."
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 enviroment variable"
exit -1
fi
mysql -u "$DATABASEUSER" -powncloud -e "DROP DATABASE IF EXISTS $DATABASENAME" -h $DATABASEHOST || true mysql -u "$DATABASEUSER" -powncloud -e "DROP DATABASE IF EXISTS $DATABASENAME" -h $DATABASEHOST || true
fi fi
if [ "$1" == "pgsql" ] ; then
#Reset _DB to mysql since that is what we use internally
_DB="mysql"
fi
if [ "$DB" == "pgsql" ] ; then
if [ ! -z "$USEDOCKER" ] ; then if [ ! -z "$USEDOCKER" ] ; then
echo "Fire up the postgres docker" 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_USER="$DATABASEUSER" -e POSTGRES_PASSWORD=owncloud -d postgres)
...@@ -160,7 +193,7 @@ function execute_tests { ...@@ -160,7 +193,7 @@ function execute_tests {
dropdb -U "$DATABASEUSER" "$DATABASENAME" || true dropdb -U "$DATABASEUSER" "$DATABASENAME" || true
fi fi
fi fi
if [ "$1" == "oci" ] ; then if [ "$DB" == "oci" ] ; then
echo "Fire up the oracle docker" echo "Fire up the oracle docker"
DOCKER_CONTAINER_ID=$(docker run -d deepdiver/docker-oracle-xe-11g) DOCKER_CONTAINER_ID=$(docker run -d deepdiver/docker-oracle-xe-11g)
DATABASEHOST=$(docker inspect "$DOCKER_CONTAINER_ID" | grep IPAddress | cut -d '"' -f 4) DATABASEHOST=$(docker inspect "$DOCKER_CONTAINER_ID" | grep IPAddress | cut -d '"' -f 4)
...@@ -176,20 +209,20 @@ function execute_tests { ...@@ -176,20 +209,20 @@ function execute_tests {
# trigger installation # trigger installation
echo "Installing ...." echo "Installing ...."
"$PHP" ./occ maintenance:install --database="$1" --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 --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"
#test execution #test execution
echo "Testing with $1 ..." echo "Testing with $DB ..."
cd tests cd tests
rm -rf "coverage-html-$1" rm -rf "coverage-html-$DB"
mkdir "coverage-html-$1" mkdir "coverage-html-$DB"
"$PHP" -f enable_all.php | grep -i -C9999 error && echo "Error during setup" && exit 101 "$PHP" -f enable_all.php | grep -i -C9999 error && echo "Error during setup" && exit 101
if [ -z "$NOCOVERAGE" ]; then if [ -z "$NOCOVERAGE" ]; then
"${PHPUNIT[@]}" --configuration phpunit-autotest.xml --log-junit "autotest-results-$1.xml" --coverage-clover "autotest-clover-$1.xml" --coverage-html "coverage-html-$1" "$2" "$3" "${PHPUNIT[@]}" --configuration phpunit-autotest.xml --log-junit "autotest-results-$DB.xml" --coverage-clover "autotest-clover-$DB.xml" --coverage-html "coverage-html-$DB" "$2" "$3"
RESULT=$? RESULT=$?
else else
echo "No coverage" echo "No coverage"
"${PHPUNIT[@]}" --configuration phpunit-autotest.xml --log-junit "autotest-results-$1.xml" "$2" "$3" "${PHPUNIT[@]}" --configuration phpunit-autotest.xml --log-junit "autotest-results-$DB.xml" "$2" "$3"
RESULT=$? RESULT=$?
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment