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.
This commit is contained in:
parent
34eec57262
commit
d2d99a91a0
|
@ -30,6 +30,9 @@ use OCP\Share\IShare;
|
||||||
use OCP\Share\IManager;
|
use OCP\Share\IManager;
|
||||||
use OCP\Files\Mount\IMountPoint;
|
use OCP\Files\Mount\IMountPoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DB
|
||||||
|
*/
|
||||||
class MountProviderTest extends \Test\TestCase {
|
class MountProviderTest extends \Test\TestCase {
|
||||||
|
|
||||||
/** @var MountProvider */
|
/** @var MountProvider */
|
||||||
|
|
|
@ -1980,7 +1980,7 @@ class View {
|
||||||
$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
|
$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
|
||||||
if ($mount) {
|
if ($mount) {
|
||||||
$storage = $mount->getStorage();
|
$storage = $mount->getStorage();
|
||||||
if ($storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
|
if ($storage && $storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
|
||||||
$storage->releaseLock(
|
$storage->releaseLock(
|
||||||
$mount->getInternalPath($absolutePath),
|
$mount->getInternalPath($absolutePath),
|
||||||
$type,
|
$type,
|
||||||
|
|
|
@ -30,6 +30,7 @@ thisFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
# create readiness notification socket
|
# create readiness notification socket
|
||||||
notify_sock=$(readlink -f "$thisFolder"/dockerContainerCeph.$EXECUTOR_NUMBER.swift.sock)
|
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"
|
mkfifo "$notify_sock"
|
||||||
|
|
||||||
port=5034
|
port=5034
|
||||||
|
@ -67,7 +68,13 @@ if [[ $ready != 'READY=1' ]]; then
|
||||||
docker logs $container
|
docker logs $container
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
cat > $thisFolder/swift.config.php <<DELIM
|
||||||
<?php
|
<?php
|
||||||
|
@ -101,5 +108,7 @@ if [ -n "$DEBUG" ]; then
|
||||||
cat $thisFolder/swift.config.php
|
cat $thisFolder/swift.config.php
|
||||||
echo "### contents of $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift"
|
echo "### contents of $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift"
|
||||||
cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
|
cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
|
||||||
|
echo "### docker logs"
|
||||||
|
docker logs $container
|
||||||
echo "############## DEBUG info end ###########"
|
echo "############## DEBUG info end ###########"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -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);
|
Loading…
Reference in New Issue