diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-04-13 17:08:50 +0300 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-07-06 09:36:07 +0300 |
commit | 5133a738e1e0246b5c5291268726a2afb21935e2 (patch) | |
tree | 1b3e40310c3fb2356a8197754ba153fa76f4a297 | |
parent | 7959605e4e389ee26705094656f636f23b9cfb8d (diff) |
autotest.sh with docker support for postgres
* waits until the docker container is started
* export USEDOCKER=1 to run the docker version of postgres
-rwxr-xr-x | autotest.sh | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/autotest.sh b/autotest.sh index 46c55edef19..4fa51e2d071 100755 --- a/autotest.sh +++ b/autotest.sh @@ -145,7 +145,20 @@ function execute_tests { mysql -u "$DATABASEUSER" -powncloud -e "DROP DATABASE IF EXISTS $DATABASENAME" -h $DATABASEHOST || true fi if [ "$1" == "pgsql" ] ; then - dropdb -U "$DATABASEUSER" "$DATABASENAME" || true + 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) + DATABASEHOST=$(docker inspect "$DOCKER_CONTAINER_ID" | grep IPAddress | cut -d '"' -f 4) + + 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" + + echo "Postgres is up." + else + dropdb -U "$DATABASEUSER" "$DATABASENAME" || true + fi fi if [ "$1" == "oci" ] ; then echo "Fire up the oracle docker" @@ -177,6 +190,12 @@ function execute_tests { "${PHPUNIT[@]}" --configuration phpunit-autotest.xml --log-junit "autotest-results-$1.xml" "$2" "$3" RESULT=$? fi + + if [ ! -z "$DOCKER_CONTAINER_ID" ] ; then + echo "Kill the docker $DOCKER_CONTAINER_ID" + docker rm -f $DOCKER_CONTAINER_ID + unset DOCKER_CONTAINER_ID + fi } # |