diff options
Diffstat (limited to 'tests/objectstore')
-rwxr-xr-x | tests/objectstore/start-swift-ceph.sh | 16 | ||||
-rwxr-xr-x | tests/objectstore/stop-swift-ceph.sh | 3 | ||||
-rwxr-xr-x | tests/objectstore/wait-for-connection | 48 |
3 files changed, 63 insertions, 4 deletions
diff --git a/tests/objectstore/start-swift-ceph.sh b/tests/objectstore/start-swift-ceph.sh index 089aab6a648..125d215c542 100755 --- a/tests/objectstore/start-swift-ceph.sh +++ b/tests/objectstore/start-swift-ceph.sh @@ -1,6 +1,7 @@ #!/bin/bash # -# ownCloud +# SPDX-FileCopyrightText: 2016 ownCloud, Inc. +# SPDX-License-Identifier: AGPL-3.0-only # # 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 @@ -10,7 +11,6 @@ # # @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" @@ -30,6 +30,7 @@ thisFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # create readiness notification socket notify_sock=$(readlink -f "$thisFolder"/dockerContainerCeph.$EXECUTOR_NUMBER.swift.sock) +rm -f "$notify_sock" # in case an unfinished test left one behind mkfifo "$notify_sock" port=5034 @@ -67,7 +68,13 @@ if [[ $ready != 'READY=1' ]]; then docker logs $container exit 1 fi -sleep 1 +if ! "$thisFolder"/wait-for-connection ${host} 80 600; then + echo "[ERROR] Waited 600 seconds, no response" >&2 + docker logs $container + exit 1 +fi +echo "Waiting another 15 seconds" +sleep 15 cat > $thisFolder/swift.config.php <<DELIM <?php @@ -78,6 +85,7 @@ cat > $thisFolder/swift.config.php <<DELIM 'username' => '$user', 'password' => '$pass', 'container' => 'owncloud-autotest$EXECUTOR_NUMBER', + 'objectPrefix' => 'autotest$EXECUTOR_NUMBER:oid:urn:', 'autocreate' => true, 'region' => '$region', 'url' => 'http://$host:$port/v2.0', @@ -101,5 +109,7 @@ if [ -n "$DEBUG" ]; then cat $thisFolder/swift.config.php echo "### contents of $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift" cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift + echo "### docker logs" + docker logs $container echo "############## DEBUG info end ###########" fi diff --git a/tests/objectstore/stop-swift-ceph.sh b/tests/objectstore/stop-swift-ceph.sh index afc5f712ab4..9673270f6d8 100755 --- a/tests/objectstore/stop-swift-ceph.sh +++ b/tests/objectstore/stop-swift-ceph.sh @@ -1,6 +1,7 @@ #!/bin/bash # -# ownCloud +# SPDX-FileCopyrightText: 2016 ownCloud, Inc. +# SPDX-License-Identifier: AGPL-3.0-only # # This script stops the docker container the files_external tests were run # against. It will also revert the config changes done in start step. diff --git a/tests/objectstore/wait-for-connection b/tests/objectstore/wait-for-connection new file mode 100755 index 00000000000..c6a3ed270f1 --- /dev/null +++ b/tests/objectstore/wait-for-connection @@ -0,0 +1,48 @@ +#!/usr/bin/php +<?php +/** + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only + */ +$timeout = 60; + +switch ($argc) { +case 4: + $timeout = (float)$argv[3]; +case 3: + $host = $argv[1]; + $port = (int)$argv[2]; + break; +default: + fwrite(STDERR, 'Usage: '.$argv[0].' host port [timeout]'."\n"); + exit(2); +} + +if ($timeout < 0) { + fwrite(STDERR, 'Timeout must be greater than zero'."\n"); + exit(2); +} +if ($port < 1) { + fwrite(STDERR, 'Port must be an integer greater than zero'."\n"); + exit(2); +} + +$socketTimeout = (float)ini_get('default_socket_timeout'); +if ($socketTimeout > $timeout) { + $socketTimeout = $timeout; +} + +$stopTime = time() + $timeout; +do { + $sock = @fsockopen($host, $port, $errno, $errstr, $socketTimeout); + if ($sock !== false) { + fclose($sock); + fwrite(STDOUT, "\n"); + exit(0); + } + sleep(1); + fwrite(STDOUT, '.'); +} while (time() < $stopTime); + +fwrite(STDOUT, "\n"); +exit(1); |