aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-11-14 11:06:59 +0100
committerMorris Jobke <hey@morrisjobke.de>2014-12-17 21:50:35 +0100
commit7c1b9aedd528f70eeacbd846666e2f663198d808 (patch)
tree6f6ea77d95addd8d9418348e5ca51a11e08649aa /apps
parentc20be2455995536e09bffca82bc37b41d5260cfe (diff)
downloadnextcloud-server-7c1b9aedd528f70eeacbd846666e2f663198d808.tar.gz
nextcloud-server-7c1b9aedd528f70eeacbd846666e2f663198d808.zip
Setup a docker container that holds a webdav instance to test files_external
document docker parameter and use random host port fix typo copy autotest.sh to autotest-external.sh adds ability to add start* and stop* scripts in env in external tests run files_external WebDAV tests against ownCloud instance introduce executor number to be able to shut down the correct docker container fetch docker images in advance - this also fetches latest versions of the docker images add second argument to autotest-external.sh which can specify a single test to run print out the explicit test run change naming schema of files_external setup scripts
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/tests/backends/amazons3.php (renamed from apps/files_external/tests/amazons3.php)0
-rw-r--r--apps/files_external/tests/backends/dropbox.php (renamed from apps/files_external/tests/dropbox.php)0
-rw-r--r--apps/files_external/tests/backends/ftp.php (renamed from apps/files_external/tests/ftp.php)0
-rw-r--r--apps/files_external/tests/backends/google.php (renamed from apps/files_external/tests/google.php)0
-rw-r--r--apps/files_external/tests/backends/owncloud.php (renamed from apps/files_external/tests/owncloud.php)0
-rw-r--r--apps/files_external/tests/backends/sftp.php (renamed from apps/files_external/tests/sftp.php)0
-rw-r--r--apps/files_external/tests/backends/smb.php (renamed from apps/files_external/tests/smb.php)0
-rw-r--r--apps/files_external/tests/backends/swift.php (renamed from apps/files_external/tests/swift.php)0
-rw-r--r--apps/files_external/tests/backends/webdav.php (renamed from apps/files_external/tests/webdav.php)12
-rwxr-xr-xapps/files_external/tests/env/start-webdav-ownCloud.sh82
-rwxr-xr-xapps/files_external/tests/env/stop-webdav-ownCloud.sh41
11 files changed, 129 insertions, 6 deletions
diff --git a/apps/files_external/tests/amazons3.php b/apps/files_external/tests/backends/amazons3.php
index fbb8744bd8d..fbb8744bd8d 100644
--- a/apps/files_external/tests/amazons3.php
+++ b/apps/files_external/tests/backends/amazons3.php
diff --git a/apps/files_external/tests/dropbox.php b/apps/files_external/tests/backends/dropbox.php
index 3f25d5a31e8..3f25d5a31e8 100644
--- a/apps/files_external/tests/dropbox.php
+++ b/apps/files_external/tests/backends/dropbox.php
diff --git a/apps/files_external/tests/ftp.php b/apps/files_external/tests/backends/ftp.php
index 842b7f43fa8..842b7f43fa8 100644
--- a/apps/files_external/tests/ftp.php
+++ b/apps/files_external/tests/backends/ftp.php
diff --git a/apps/files_external/tests/google.php b/apps/files_external/tests/backends/google.php
index 79023fac9e1..79023fac9e1 100644
--- a/apps/files_external/tests/google.php
+++ b/apps/files_external/tests/backends/google.php
diff --git a/apps/files_external/tests/owncloud.php b/apps/files_external/tests/backends/owncloud.php
index ab9101cfe5f..ab9101cfe5f 100644
--- a/apps/files_external/tests/owncloud.php
+++ b/apps/files_external/tests/backends/owncloud.php
diff --git a/apps/files_external/tests/sftp.php b/apps/files_external/tests/backends/sftp.php
index 703b37d93f1..703b37d93f1 100644
--- a/apps/files_external/tests/sftp.php
+++ b/apps/files_external/tests/backends/sftp.php
diff --git a/apps/files_external/tests/smb.php b/apps/files_external/tests/backends/smb.php
index 9e5ab2b331f..9e5ab2b331f 100644
--- a/apps/files_external/tests/smb.php
+++ b/apps/files_external/tests/backends/smb.php
diff --git a/apps/files_external/tests/swift.php b/apps/files_external/tests/backends/swift.php
index d2c884a8b4c..d2c884a8b4c 100644
--- a/apps/files_external/tests/swift.php
+++ b/apps/files_external/tests/backends/swift.php
diff --git a/apps/files_external/tests/webdav.php b/apps/files_external/tests/backends/webdav.php
index 5f53568b91a..c390612810d 100644
--- a/apps/files_external/tests/webdav.php
+++ b/apps/files_external/tests/backends/webdav.php
@@ -16,15 +16,15 @@ class DAV extends Storage {
parent::setUp();
$id = $this->getUniqueID();
- $this->config = include('files_external/tests/config.php');
- if ( ! is_array($this->config) or ! isset($this->config['webdav']) or ! $this->config['webdav']['run']) {
+ $config = include('files_external/tests/config.webdav.php');
+ if ( ! is_array($config) or !$config['run']) {
$this->markTestSkipped('WebDAV backend not configured');
}
- if (isset($this->config['webdav']['wait'])) {
- $this->waitDelay = $this->config['webdav']['wait'];
+ if (isset($config['wait'])) {
+ $this->waitDelay = $config['wait'];
}
- $this->config['webdav']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
- $this->instance = new \OC\Files\Storage\DAV($this->config['webdav']);
+ $config['root'] .= '/' . $id; //make sure we have an new empty folder to work in
+ $this->instance = new \OC\Files\Storage\DAV($config);
$this->instance->mkdir('/');
}
diff --git a/apps/files_external/tests/env/start-webdav-ownCloud.sh b/apps/files_external/tests/env/start-webdav-ownCloud.sh
new file mode 100755
index 00000000000..c7267cff341
--- /dev/null
+++ b/apps/files_external/tests/env/start-webdav-ownCloud.sh
@@ -0,0 +1,82 @@
+#!/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/owncloud docker image"
+docker pull morrisjobke/owncloud
+
+# retrieve current folder to place the config in the parent folder
+thisFolder=`echo $0 | replace "env/start-webdav-ownCloud.sh" ""`
+
+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 ADMINLOGIN=test -e ADMINPWD=test morrisjobke/owncloud`
+
+# TODO find a way to determine the successful initialization inside the docker container
+echo "Waiting 30 seconds for ownCloud 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/owncloud/remote.php/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/dockerContainerOwnCloud.$EXECUTOR_NUMBER.webdav
+
+if [ -n "$databaseContainer" ]; then
+ echo "Database container: $databaseContainer"
+ echo $databaseContainer >> $thisFolder/dockerContainerOwnCloud.$EXECUTOR_NUMBER.webdav
+fi
+
+if [ -n "$DEBUG" ]; then
+ echo $thisFolder/config.webdav.php
+fi
diff --git a/apps/files_external/tests/env/stop-webdav-ownCloud.sh b/apps/files_external/tests/env/stop-webdav-ownCloud.sh
new file mode 100755
index 00000000000..2f06eadcf7c
--- /dev/null
+++ b/apps/files_external/tests/env/stop-webdav-ownCloud.sh
@@ -0,0 +1,41 @@
+#!/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 | replace "env/stop-webdav-ownCloud.sh" ""`
+
+echo "DEBUG"
+
+netstat -tlpen
+
+echo "CONFIG:"
+
+cat $thisFolder/config.webdav.php
+cat $thisFolder/dockerContainerOwnCloud.$EXECUTOR_NUMBER.webdav
+
+# stopping and removing docker containers
+for container in `cat $thisFolder/dockerContainerOwnCloud.$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/dockerContainerOwnCloud.$EXECUTOR_NUMBER.webdav
+