From d201ffe13d74b326e0bf971674d2b162dc60baa0 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 3 May 2016 12:19:16 +0200 Subject: [PATCH] Fix webdav test env scripts to also work on CI --- .../tests/env/start-webdav-apache.sh | 30 ++++++++++++++----- .../tests/env/stop-webdav-apache.sh | 1 + 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/apps/files_external/tests/env/start-webdav-apache.sh b/apps/files_external/tests/env/start-webdav-apache.sh index 8201424319..48acb8572d 100755 --- a/apps/files_external/tests/env/start-webdav-apache.sh +++ b/apps/files_external/tests/env/start-webdav-apache.sh @@ -13,6 +13,7 @@ # # @author Morris Jobke # @copyright 2014 Morris Jobke +# @copyright 2016 Vincent Petry # if ! command -v docker >/dev/null 2>&1; then @@ -32,21 +33,36 @@ if [ -z "$thisFolder" ]; then thisFolder="." fi; -container=`docker run -d -e USERNAME=test -e PASSWORD=test -p 8888:80 morrisjobke/webdav` +if [ -n "$RUN_DOCKER_MYSQL" ]; then + echo "Fetch recent mysql docker image" + docker pull mysql -# TODO find a way to determine the successful initialization inside the docker container -echo "Waiting 30 seconds for Webdav initialization ... " -sleep 30 + echo "Setup MySQL ..." + # user/password will be read by ENV variables in owncloud container (they are generated by docker) + databaseContainer=`docker run -e MYSQL_ROOT_PASSWORD=mysupersecretpassword -d mysql` + containerName=`docker inspect $databaseContainer | grep Name | grep _ | cut -d \" -f 4 | cut -d / -f 2` -# get mapped port on host for internal port 80 - output is IP:PORT - we need to extract the port with 'cut' -port=`docker port $container 80 | cut -f 2 -d :` + parameter="--link $containerName:db" +fi + +container=`docker run -P $parameter -d -e USERNAME=test -e PASSWORD=test morrisjobke/webdav` +host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container` + +echo -n "Waiting for Apache initialization on ${host}:${port}" +if ! "$thisFolder"/env/wait-for-connection ${host} 80 60; then + echo "[ERROR] Waited 60 seconds, no response" >&2 + exit 1 +fi + +# wait at least 5 more seconds - sometimes the webserver still needs some additional time +sleep 5 cat > $thisFolder/config.webdav.php <true, - 'host'=>'localhost:$port/webdav/', + 'host'=>'${host}:80/webdav/', 'user'=>'test', 'password'=>'test', 'root'=>'', diff --git a/apps/files_external/tests/env/stop-webdav-apache.sh b/apps/files_external/tests/env/stop-webdav-apache.sh index 9ebf96030a..e898a65cc3 100755 --- a/apps/files_external/tests/env/stop-webdav-apache.sh +++ b/apps/files_external/tests/env/stop-webdav-apache.sh @@ -7,6 +7,7 @@ # # @author Morris Jobke # @copyright 2014 Morris Jobke +# @copyright 2016 Vincent Petry # if ! command -v docker >/dev/null 2>&1; then