summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-05-31 09:55:06 +0200
committerVincent Petry <pvince81@owncloud.com>2016-05-31 09:55:06 +0200
commit3361cdf0cc697fc3c96def63ee762360a69db783 (patch)
tree3cae0eab6ebd7975fa747a2eb65207501596f31c /apps/files_external
parentb2e524b9367511e0496f22d45c87ecc974dda2ed (diff)
parentd201ffe13d74b326e0bf971674d2b162dc60baa0 (diff)
downloadnextcloud-server-3361cdf0cc697fc3c96def63ee762360a69db783.tar.gz
nextcloud-server-3361cdf0cc697fc3c96def63ee762360a69db783.zip
Merge pull request #16688 from owncloud/tests-dockerapachewebdav
Add morrisjobke/webdav docker container for external storage tests
Diffstat (limited to 'apps/files_external')
-rwxr-xr-xapps/files_external/tests/env/start-webdav-apache.sh90
-rwxr-xr-xapps/files_external/tests/env/stop-webdav-apache.sh37
2 files changed, 127 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..48acb8572d6
--- /dev/null
+++ b/apps/files_external/tests/env/start-webdav-apache.sh
@@ -0,0 +1,90 @@
+#!/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>
+# @copyright 2016 Vincent Petry <pvince81@owncloud.com>
+#
+
+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;
+
+if [ -n "$RUN_DOCKER_MYSQL" ]; then
+ echo "Fetch recent mysql docker image"
+ docker pull mysql
+
+ 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`
+
+ 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 <<DELIM
+<?php
+
+return array(
+ 'run'=>true,
+ 'host'=>'${host}:80/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..e898a65cc36
--- /dev/null
+++ b/apps/files_external/tests/env/stop-webdav-apache.sh
@@ -0,0 +1,37 @@
+#!/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>
+# @copyright 2016 Vincent Petry <pvince81@owncloud.com>
+#
+
+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
+