diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-06-02 15:35:45 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-05-30 16:10:30 +0200 |
commit | a76498f24509700a34ae20fdf4ad67eb791a9298 (patch) | |
tree | 77730cf8e4c5cc314c893556441fbefd88571a42 /apps/files_external/tests/env | |
parent | 0e3a0e0fdb17938d473434d94e3c16c1c5dccf73 (diff) | |
download | nextcloud-server-a76498f24509700a34ae20fdf4ad67eb791a9298.tar.gz nextcloud-server-a76498f24509700a34ae20fdf4ad67eb791a9298.zip |
Add morrisjobke/webdav docker container for external storage tests
Diffstat (limited to 'apps/files_external/tests/env')
-rwxr-xr-x | apps/files_external/tests/env/start-webdav-apache.sh | 74 | ||||
-rwxr-xr-x | apps/files_external/tests/env/stop-webdav-apache.sh | 36 |
2 files changed, 110 insertions, 0 deletions
diff --git a/apps/files_external/tests/env/start-webdav-apache.sh b/apps/files_external/tests/env/start-webdav-apache.sh new file mode 100755 index 00000000000..82014243190 --- /dev/null +++ b/apps/files_external/tests/env/start-webdav-apache.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# +# ownCloud +# +# This script start a docker container to test the files_external tests +# against. It will also change the files_external config to use the docker +# container as testing environment. This is reverted in the stop step. +# +# If the environment variable RUN_DOCKER_MYSQL is set the ownCloud will +# be set up using MySQL instead of SQLite. +# +# Set environment variable DEBUG to print config file +# +# @author Morris Jobke +# @copyright 2014 Morris Jobke <hey@morrisjobke.de> +# + +if ! command -v docker >/dev/null 2>&1; then + echo "No docker executable found - skipped docker setup" + exit 0; +fi + +echo "Docker executable found - setup docker" + +echo "Fetch recent morrisjobke/webdav docker image" +docker pull morrisjobke/webdav + +# retrieve current folder to place the config in the parent folder +thisFolder=`echo $0 | sed 's#env/start-webdav-apache\.sh##'` + +if [ -z "$thisFolder" ]; then + thisFolder="." +fi; + +container=`docker run -d -e USERNAME=test -e PASSWORD=test -p 8888:80 morrisjobke/webdav` + +# TODO find a way to determine the successful initialization inside the docker container +echo "Waiting 30 seconds for Webdav initialization ... " +sleep 30 + +# 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 :` + +cat > $thisFolder/config.webdav.php <<DELIM +<?php + +return array( + 'run'=>true, + 'host'=>'localhost:$port/webdav/', + 'user'=>'test', + 'password'=>'test', + 'root'=>'', + // wait delay in seconds after write operations + // (only in tests) + // set to higher value for lighttpd webdav + 'wait'=> 0 +); + +DELIM + +echo "ownCloud container: $container" + +# put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host) +echo $container >> $thisFolder/dockerContainerWebdav.$EXECUTOR_NUMBER.webdav + +if [ -n "$databaseContainer" ]; then + echo "Database container: $databaseContainer" + echo $databaseContainer >> $thisFolder/dockerContainerWebdav.$EXECUTOR_NUMBER.webdav +fi + +if [ -n "$DEBUG" ]; then + cat $thisFolder/config.webdav.php + cat $thisFolder/dockerContainerWebdav.$EXECUTOR_NUMBER.webdav +fi diff --git a/apps/files_external/tests/env/stop-webdav-apache.sh b/apps/files_external/tests/env/stop-webdav-apache.sh new file mode 100755 index 00000000000..9ebf96030aa --- /dev/null +++ b/apps/files_external/tests/env/stop-webdav-apache.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# ownCloud +# +# This script stops the docker container the files_external tests were run +# against. It will also revert the config changes done in start step. +# +# @author Morris Jobke +# @copyright 2014 Morris Jobke <hey@morrisjobke.de> +# + +if ! command -v docker >/dev/null 2>&1; then + echo "No docker executable found - skipped docker stop" + exit 0; +fi + +echo "Docker executable found - stop and remove docker containers" + +# retrieve current folder to remove the config from the parent folder +thisFolder=`echo $0 | sed 's#env/stop-webdav-apache\.sh##'` + +if [ -z "$thisFolder" ]; then + thisFolder="." +fi; + +# stopping and removing docker containers +for container in `cat $thisFolder/dockerContainerWebdav.$EXECUTOR_NUMBER.webdav`; do + echo "Stopping and removing docker container $container" + # kills running container and removes it + docker rm -f $container +done; + +# cleanup +rm $thisFolder/config.webdav.php +rm $thisFolder/dockerContainerWebdav.$EXECUTOR_NUMBER.webdav + |