diff --git a/.drone.star b/.drone.star index 84fca6d7e93..a629a29d290 100644 --- a/.drone.star +++ b/.drone.star @@ -23,7 +23,7 @@ OC_CI_GOLANG = "owncloudci/golang:1.22" OC_CI_NODEJS = "owncloudci/nodejs:%s" OC_CI_PHP = "owncloudci/php:%s" OC_CI_WAIT_FOR = "owncloudci/wait-for:latest" -OC_CS3_API_VALIDATOR = "owncloud/cs3api-validator:0.2.1" +OC_CS3_API_VALIDATOR = "owncloud/cs3api-validator:0.3.0" OC_LITMUS = "owncloudci/litmus:latest" OC_UBUNTU = "owncloud/ubuntu:20.04" ONLYOFFICE_DOCUMENT_SERVER = "onlyoffice/documentserver:7.5.1" @@ -1029,6 +1029,8 @@ def localApiTests(ctx, name, suites, storage = "ocis", extra_environment = {}, w "UPLOAD_DELETE_WAIT_TIME": "1" if storage == "owncloud" else 0, "OCIS_WRAPPER_URL": "http://%s:5200" % OCIS_SERVER_NAME, "WITH_REMOTE_PHP": with_remote_php, + "ASYNC_PROPAGATION": "true", + "ASYNC_PROPAGATION_DELAY_MS": "100", } for item in extra_environment: @@ -1063,7 +1065,7 @@ def cs3ApiTests(ctx, storage, accounts_hash_difficulty = 4): "image": OC_CS3_API_VALIDATOR, "environment": {}, "commands": [ - "/usr/bin/cs3api-validator /var/lib/cs3api-validator --endpoint=%s:9142" % OCIS_SERVER_NAME, + "/usr/bin/cs3api-validator /var/lib/cs3api-validator --async-propagation=true --endpoint=%s:9142" % OCIS_SERVER_NAME, ], }, ], @@ -1228,6 +1230,8 @@ def coreApiTests(ctx, part_number = 1, number_of_parts = 1, with_remote_php = Fa "UPLOAD_DELETE_WAIT_TIME": "1" if storage == "owncloud" else 0, "OCIS_WRAPPER_URL": "http://%s:5200" % OCIS_SERVER_NAME, "WITH_REMOTE_PHP": with_remote_php, + "ASYNC_PROPAGATION": "true", + "ASYNC_PROPAGATION_DELAY_MS": "100", }, "commands": [ # merge the expected failures @@ -2322,6 +2326,8 @@ def ocisServer(storage = "ocis", accounts_hash_difficulty = 4, volumes = [], dep "OCIS_JWT_SECRET": "some-ocis-jwt-secret", "EVENTHISTORY_STORE": "memory", "OCIS_TRANSLATION_PATH": "%s/tests/config/translations" % dirs["base"], + "OCIS_DECOMPOSEDFS_PROPAGATOR": "async", + "STORAGE_USERS_ASYNC_PROPAGATOR_PROPAGATION_DELAY": "100ms", } if deploy_type == "": diff --git a/tests/acceptance/TestHelpers/GraphHelper.php b/tests/acceptance/TestHelpers/GraphHelper.php index c0f8df597db..0a4a7c7bab4 100644 --- a/tests/acceptance/TestHelpers/GraphHelper.php +++ b/tests/acceptance/TestHelpers/GraphHelper.php @@ -54,6 +54,15 @@ private static function getRequestHeaders(): array { ]; } + /** + * @param string $url + * + * @return bool + */ + public static function isShareRequest(string $url): bool { + return \str_ends_with($url, '/invite'); + } + /** * * @return string diff --git a/tests/acceptance/TestHelpers/HttpRequestHelper.php b/tests/acceptance/TestHelpers/HttpRequestHelper.php index 21fa4f3024f..2e38a122569 100644 --- a/tests/acceptance/TestHelpers/HttpRequestHelper.php +++ b/tests/acceptance/TestHelpers/HttpRequestHelper.php @@ -159,6 +159,11 @@ public static function sendRequestOnce( } HttpLogger::logResponse($response); + + if (WebdavHelper::asyncPropagation()) { + WebdavHelper::waitAsyncPropagationAfterRequest($url, $method, $response->getStatusCode()); + } + return $response; } diff --git a/tests/acceptance/TestHelpers/WebDavHelper.php b/tests/acceptance/TestHelpers/WebDavHelper.php index 77bd99b47f3..2142750ed88 100644 --- a/tests/acceptance/TestHelpers/WebDavHelper.php +++ b/tests/acceptance/TestHelpers/WebDavHelper.php @@ -28,6 +28,7 @@ use PHPUnit\Framework\Assert; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; +use Symfony\Component\HttpFoundation\Response as HttpResponse; use DateTime; /** @@ -54,6 +55,27 @@ public static function withRemotePhp(): bool { return \getenv("WITH_REMOTE_PHP") !== "false"; } + /** + * @return bool + */ + public static function asyncPropagation(): bool { + return \getenv("ASYNC_PROPAGATION") === "true"; + } + + /** + * async propagation delay in milliseconds + * + * @return int + */ + public static function asyncPropagationDelay(): int { + $delay = (int) \getenv("ASYNC_PROPAGATION_DELAY_MS"); + if ($delay === 0) { + // default delay: 100ms + $delay = 100; + } + return $delay; + } + /** * @param string $urlPath * @@ -76,6 +98,46 @@ public static function isDAVRequest(string $url): bool { return (bool)$found; } + /** + * @param int $extraWait + * + * @return void + */ + public static function waitForAsyncPropagation(int $extraWait): void { + $delay = self::asyncPropagationDelay() + $extraWait; + usleep($delay * 1000); + } + + /** + * wait for async propagation after a request + * if the request is a DAV request and is successful + * + * @param string $url + * @param string $method + * @param int $statusCode + * + * @return void + */ + public static function waitAsyncPropagationAfterRequest(string $url, string $method, int $statusCode): void { + $longerWaitMethods = ["MKCOL", "MOVE", "COPY", "DELETE"]; + $methods = \array_merge($longerWaitMethods, ["POST", "PUT"]); + + if ((WebdavHelper::isDAVRequest($url) || GraphHelper::isShareRequest($url)) + && \str_starts_with($url, OcisHelper::getServerUrl()) + && \in_array($method, $methods) + && $statusCode < 300 + ) { + $extraWait = 0; + if (\in_array($method, $longerWaitMethods)) { + // folder related requests require more time + // wait longer for these methods + // increase wait by 300ms + $extraWait = 300; + } + self::waitForAsyncPropagation($extraWait); + } + } + /** * clear space id reference for user *