summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-11-20 13:57:54 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-11-20 13:57:54 +0100
commit308aaf89cd916a0c26c219650e09b8612a50fc47 (patch)
tree55cb9155e4e96a848330af516f80cddab7a807b7 /apps
parent129ec4fb4054f2f145285772b94d7d5e1cd56286 (diff)
parentd49fc9a5fcb993307ff7ef188fff3da8a3d03c69 (diff)
downloadnextcloud-server-308aaf89cd916a0c26c219650e09b8612a50fc47.tar.gz
nextcloud-server-308aaf89cd916a0c26c219650e09b8612a50fc47.zip
Merge pull request #14077 from owncloud/autotest-external-swift
[files_external] swift tests
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/tests/backends/swift.php31
-rwxr-xr-xapps/files_external/tests/env/start-amazons3-ceph.sh18
-rwxr-xr-xapps/files_external/tests/env/start-ftp-morrisjobke.sh19
-rwxr-xr-xapps/files_external/tests/env/start-sftp-atmoz.sh20
-rwxr-xr-xapps/files_external/tests/env/start-smb-silvershell.sh19
-rwxr-xr-xapps/files_external/tests/env/start-smb-windows.sh6
-rwxr-xr-xapps/files_external/tests/env/start-swift-ceph.sh94
-rwxr-xr-xapps/files_external/tests/env/start-webdav-ownCloud.sh26
-rwxr-xr-xapps/files_external/tests/env/stop-swift-ceph.sh36
9 files changed, 236 insertions, 33 deletions
diff --git a/apps/files_external/tests/backends/swift.php b/apps/files_external/tests/backends/swift.php
index 2e6670f84f8..07ee36043b1 100644
--- a/apps/files_external/tests/backends/swift.php
+++ b/apps/files_external/tests/backends/swift.php
@@ -32,28 +32,35 @@ class Swift extends Storage {
protected function setUp() {
parent::setUp();
- $this->config = include('files_external/tests/config.php');
- if (!is_array($this->config) or !isset($this->config['swift'])
- or !$this->config['swift']['run']) {
+ $this->config = include('files_external/tests/config.swift.php');
+ if (!is_array($this->config) or !$this->config['run']) {
$this->markTestSkipped('OpenStack Object Storage backend not configured');
}
- $this->instance = new \OC\Files\Storage\Swift($this->config['swift']);
+ $this->instance = new \OC\Files\Storage\Swift($this->config);
}
protected function tearDown() {
if ($this->instance) {
- $connection = $this->instance->getConnection();
- $container = $connection->getContainer($this->config['swift']['bucket']);
+ try {
+ $connection = $this->instance->getConnection();
+ $container = $connection->getContainer($this->config['bucket']);
- $objects = $container->objectList();
- while($object = $objects->next()) {
- $object->setName(str_replace('#','%23',$object->getName()));
- $object->delete();
- }
+ $objects = $container->objectList();
+ while($object = $objects->next()) {
+ $object->setName(str_replace('#','%23',$object->getName()));
+ $object->delete();
+ }
- $container->delete();
+ $container->delete();
+ } catch (\Guzzle\Http\Exception\ClientErrorResponseException $e) {
+ // container didn't exist, so we don't need to delete it
+ }
}
parent::tearDown();
}
+
+ public function testStat() {
+ $this->markTestSkipped('Swift doesn\'t update the parents folder mtime');
+ }
}
diff --git a/apps/files_external/tests/env/start-amazons3-ceph.sh b/apps/files_external/tests/env/start-amazons3-ceph.sh
index 3b4a15da92a..b40d28f1ec6 100755
--- a/apps/files_external/tests/env/start-amazons3-ceph.sh
+++ b/apps/files_external/tests/env/start-amazons3-ceph.sh
@@ -49,9 +49,21 @@ echo "${docker_image} 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/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3
-# TODO find a way to determine the successful initialization inside the docker container
-echo "Waiting 20 seconds for ceph initialization ... "
-sleep 20
+echo -n "Waiting for ceph initialization"
+starttime=$(date +%s)
+# support for GNU netcat and BSD netcat
+while ! (nc -c -w 1 ${host} ${port} </dev/null >&/dev/null \
+ || nc -w 1 ${host} ${port} </dev/null >&/dev/null); do
+ sleep 1
+ echo -n '.'
+ if (( $(date +%s) > starttime + 60 )); then
+ echo
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+ fi
+done
+echo
+sleep 1
echo "Create ceph user"
docker exec $container radosgw-admin user create \
diff --git a/apps/files_external/tests/env/start-ftp-morrisjobke.sh b/apps/files_external/tests/env/start-ftp-morrisjobke.sh
index f1ab7f69952..3c6cc62bce8 100755
--- a/apps/files_external/tests/env/start-ftp-morrisjobke.sh
+++ b/apps/files_external/tests/env/start-ftp-morrisjobke.sh
@@ -54,12 +54,25 @@ echo "ftp 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/dockerContainerMorrisJobke.$EXECUTOR_NUMBER.ftp
+echo -n "Waiting for ftp initialization"
+starttime=$(date +%s)
+# support for GNU netcat and BSD netcat
+while ! (nc -c -w 1 ${host} 21 </dev/null >&/dev/null \
+ || nc -w 1 ${host} 21 </dev/null >&/dev/null); do
+ sleep 1
+ echo -n '.'
+ if (( $(date +%s) > starttime + 60 )); then
+ echo
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+ fi
+done
+echo
+sleep 1
+
if [ -n "$DEBUG" ]; then
cat $thisFolder/config.ftp.php
cat $thisFolder/dockerContainerMorrisJobke.$EXECUTOR_NUMBER.ftp
fi
-# TODO find a way to determine the successful initialization inside the docker container
-echo "Waiting 5 seconds for ftp initialization ... "
-sleep 5
diff --git a/apps/files_external/tests/env/start-sftp-atmoz.sh b/apps/files_external/tests/env/start-sftp-atmoz.sh
index bebc7289250..3e0616f03d2 100755
--- a/apps/files_external/tests/env/start-sftp-atmoz.sh
+++ b/apps/files_external/tests/env/start-sftp-atmoz.sh
@@ -54,15 +54,27 @@ echo "sftp 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/dockerContainerAtmoz.$EXECUTOR_NUMBER.sftp
+echo -n "Waiting for sftp initialization"
+starttime=$(date +%s)
+# support for GNU netcat and BSD netcat
+while ! (nc -c -w 1 ${host} 22 </dev/null >&/dev/null \
+ || nc -w 1 ${host} 22 </dev/null >&/dev/null); do
+ sleep 1
+ echo -n '.'
+ if (( $(date +%s) > starttime + 60 )); then
+ echo
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+ fi
+done
+echo
+sleep 1
+
if [ -n "$DEBUG" ]; then
cat $thisFolder/config.sftp.php
cat $thisFolder/dockerContainerAtmoz.$EXECUTOR_NUMBER.sftp
fi
-# TODO find a way to determine the successful initialization inside the docker container
-echo "Waiting 5 seconds for sftp initialization ... "
-sleep 5
-
# create folder "upload" with correct permissions
docker exec $container bash -c "mkdir /home/$user/upload && chown $user:users /home/$user/upload"
diff --git a/apps/files_external/tests/env/start-smb-silvershell.sh b/apps/files_external/tests/env/start-smb-silvershell.sh
index 41ba3b11a70..31e3da44646 100755
--- a/apps/files_external/tests/env/start-smb-silvershell.sh
+++ b/apps/files_external/tests/env/start-smb-silvershell.sh
@@ -52,12 +52,25 @@ echo "samba 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/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb
+echo -n "Waiting for samba initialization"
+starttime=$(date +%s)
+# support for GNU netcat and BSD netcat
+while ! (nc -c -w 1 ${host} 445 </dev/null >&/dev/null \
+ || nc -w 1 ${host} 445 </dev/null >&/dev/null); do
+ sleep 1
+ echo -n '.'
+ if (( $(date +%s) > starttime + 60 )); then
+ echo
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+ fi
+done
+echo
+sleep 1
+
if [ -n "$DEBUG" ]; then
cat $thisFolder/config.smb.php
cat $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb
fi
-# TODO find a way to determine the successful initialization inside the docker container
-echo "Waiting 5 seconds for smbd initialization ... "
-sleep 5
diff --git a/apps/files_external/tests/env/start-smb-windows.sh b/apps/files_external/tests/env/start-smb-windows.sh
index 2143d7e7499..6779cdb2d56 100755
--- a/apps/files_external/tests/env/start-smb-windows.sh
+++ b/apps/files_external/tests/env/start-smb-windows.sh
@@ -19,6 +19,12 @@ user=smb-test
password=!owncloud123
host=WIN-9GTFAS08C15
+if ! (nc -c -w 1 ${host} 445 </dev/null >&/dev/null \
+ || nc -w 1 ${host} 445 </dev/null >&/dev/null); then
+ echo "[ERROR] Server not reachable" >&2
+ exit 1
+fi
+
cat > $thisFolder/config.smb.php <<DELIM
<?php
diff --git a/apps/files_external/tests/env/start-swift-ceph.sh b/apps/files_external/tests/env/start-swift-ceph.sh
new file mode 100755
index 00000000000..ea16e167af9
--- /dev/null
+++ b/apps/files_external/tests/env/start-swift-ceph.sh
@@ -0,0 +1,94 @@
+#!/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.W
+#
+# Set environment variable DEBUG to print config file
+#
+# @author Morris Jobke
+# @author Robin McCorkell
+# @copyright 2015 ownCloud
+
+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"
+
+docker_image=xenopathic/ceph-keystone
+
+echo "Fetch recent ${docker_image} docker image"
+docker pull ${docker_image}
+
+# retrieve current folder to place the config in the parent folder
+thisFolder=`echo $0 | replace "env/start-swift-ceph.sh" ""`
+
+if [ -z "$thisFolder" ]; then
+ thisFolder="."
+fi;
+
+port=5001
+
+user=test
+pass=testing
+tenant=testenant
+region=testregion
+service=testceph
+
+container=`docker run -d \
+ -e KEYSTONE_PUBLIC_PORT=${port} \
+ -e KEYSTONE_ADMIN_USER=${user} \
+ -e KEYSTONE_ADMIN_PASS=${pass} \
+ -e KEYSTONE_ADMIN_TENANT=${tenant} \
+ -e KEYSTONE_ENDPOINT_REGION=${region} \
+ -e KEYSTONE_SERVICE=${service} \
+ ${docker_image}`
+
+host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
+
+
+echo "${docker_image} 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/dockerContainerCeph.$EXECUTOR_NUMBER.swift
+
+echo -n "Waiting for ceph initialization"
+starttime=$(date +%s)
+# support for GNU netcat and BSD netcat
+while ! (nc -c -w 1 ${host} 80 </dev/null >&/dev/null \
+ || nc -w 1 ${host} 80 </dev/null >&/dev/null); do
+ sleep 1
+ echo -n '.'
+ if (( $(date +%s) > starttime + 60 )); then
+ echo
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+ fi
+done
+echo
+sleep 1
+
+cat > $thisFolder/config.swift.php <<DELIM
+<?php
+
+return array(
+ 'run'=>true,
+ 'url'=>'http://$host:$port/v2.0',
+ 'user'=>'$user',
+ 'tenant'=>'$tenant',
+ 'password'=>'$pass',
+ 'service_name'=>'$service',
+ 'bucket'=>'swift',
+ 'region' => '$region',
+);
+
+DELIM
+
+if [ -n "$DEBUG" ]; then
+ cat $thisFolder/config.swift.php
+ cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
+fi
diff --git a/apps/files_external/tests/env/start-webdav-ownCloud.sh b/apps/files_external/tests/env/start-webdav-ownCloud.sh
index 6bf9142ee53..6e3904f2bad 100755
--- a/apps/files_external/tests/env/start-webdav-ownCloud.sh
+++ b/apps/files_external/tests/env/start-webdav-ownCloud.sh
@@ -46,20 +46,30 @@ 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 :`
-
+host=`docker inspect $container | grep IPAddress | cut -d '"' -f 4`
+
+echo -n "Waiting for ownCloud initialization"
+starttime=$(date +%s)
+# support for GNU netcat and BSD netcat
+while ! (nc -c -w 1 ${host} 80 </dev/null >&/dev/null \
+ || nc -w 1 ${host} 80 </dev/null >&/dev/null); do
+ sleep 1
+ echo -n '.'
+ if (( $(date +%s) > starttime + 60 )); then
+ echo
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+ fi
+done
+echo
+sleep 1
cat > $thisFolder/config.webdav.php <<DELIM
<?php
return array(
'run'=>true,
- 'host'=>'localhost:$port/owncloud/remote.php/webdav/',
+ 'host'=>'${host}:80/owncloud/remote.php/webdav/',
'user'=>'test',
'password'=>'test',
'root'=>'',
diff --git a/apps/files_external/tests/env/stop-swift-ceph.sh b/apps/files_external/tests/env/stop-swift-ceph.sh
new file mode 100755
index 00000000000..edac1389a78
--- /dev/null
+++ b/apps/files_external/tests/env/stop-swift-ceph.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
+# @author Robin McCorkell
+# @copyright 2015 ownCloud
+
+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-swift-ceph.sh" ""`
+
+if [ -z "$thisFolder" ]; then
+ thisFolder="."
+fi;
+
+# stopping and removing docker containers
+for container in `cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift`; do
+ echo "Stopping and removing docker container $container"
+ # kills running container and removes it
+ docker rm -f $container
+done;
+
+# cleanup
+rm $thisFolder/config.swift.php
+rm $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
+