summaryrefslogtreecommitdiffstats
path: root/tests/objectstore/wait-for-connection
diff options
context:
space:
mode:
authorThomas Müller <DeepDiver1975@users.noreply.github.com>2016-07-05 08:54:51 +0200
committerGitHub <noreply@github.com>2016-07-05 08:54:51 +0200
commitd2d99a91a0bb47ab4f2116692f363b90a736711b (patch)
treea68250d1e2a7b2f25d2062504a741b8dbf0b1540 /tests/objectstore/wait-for-connection
parent34eec5726297d1720f5390a567609b07e2cbdd9f (diff)
downloadnextcloud-server-d2d99a91a0bb47ab4f2116692f363b90a736711b.tar.gz
nextcloud-server-d2d99a91a0bb47ab4f2116692f363b90a736711b.zip
fix swift primary object store test (#25281)
* Wait for socket to be open * Fix call on null * Allow DB access for MountProviderTest Makes unit tests pass when using object store, since their FS access is actually oc_filecache DB access. It is currently not possible to mock or bypass the logic from "SharedMount::verifyMountPoint()" triggered by this test.
Diffstat (limited to 'tests/objectstore/wait-for-connection')
-rwxr-xr-xtests/objectstore/wait-for-connection45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/objectstore/wait-for-connection b/tests/objectstore/wait-for-connection
new file mode 100755
index 00000000000..2c480fb733e
--- /dev/null
+++ b/tests/objectstore/wait-for-connection
@@ -0,0 +1,45 @@
+#!/usr/bin/php
+<?php
+
+$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);