Fix webdav test env scripts to also work on CI

This commit is contained in:
Vincent Petry 2016-05-03 12:19:16 +02:00
parent 5d7f37d570
commit d201ffe13d
No known key found for this signature in database
GPG Key ID: AF8F9EFC56562186
2 changed files with 24 additions and 7 deletions

View File

@ -13,6 +13,7 @@
# #
# @author Morris Jobke # @author Morris Jobke
# @copyright 2014 Morris Jobke <hey@morrisjobke.de> # @copyright 2014 Morris Jobke <hey@morrisjobke.de>
# @copyright 2016 Vincent Petry <pvince81@owncloud.com>
# #
if ! command -v docker >/dev/null 2>&1; then if ! command -v docker >/dev/null 2>&1; then
@ -32,21 +33,36 @@ if [ -z "$thisFolder" ]; then
thisFolder="." thisFolder="."
fi; 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 "Setup MySQL ..."
echo "Waiting 30 seconds for Webdav initialization ... " # user/password will be read by ENV variables in owncloud container (they are generated by docker)
sleep 30 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' parameter="--link $containerName:db"
port=`docker port $container 80 | cut -f 2 -d :` 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 <<DELIM cat > $thisFolder/config.webdav.php <<DELIM
<?php <?php
return array( return array(
'run'=>true, 'run'=>true,
'host'=>'localhost:$port/webdav/', 'host'=>'${host}:80/webdav/',
'user'=>'test', 'user'=>'test',
'password'=>'test', 'password'=>'test',
'root'=>'', 'root'=>'',

View File

@ -7,6 +7,7 @@
# #
# @author Morris Jobke # @author Morris Jobke
# @copyright 2014 Morris Jobke <hey@morrisjobke.de> # @copyright 2014 Morris Jobke <hey@morrisjobke.de>
# @copyright 2016 Vincent Petry <pvince81@owncloud.com>
# #
if ! command -v docker >/dev/null 2>&1; then if ! command -v docker >/dev/null 2>&1; then