Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
],
},
],
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 == "":
Expand Down
9 changes: 9 additions & 0 deletions tests/acceptance/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/acceptance/TestHelpers/HttpRequestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ public static function sendRequestOnce(
}

HttpLogger::logResponse($response);

if (WebdavHelper::asyncPropagation()) {
WebdavHelper::waitAsyncPropagationAfterRequest($url, $method, $response->getStatusCode());
}

return $response;
}

Expand Down
62 changes: 62 additions & 0 deletions tests/acceptance/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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
*
Expand All @@ -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
*
Expand Down