mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge pull request #13656 from appwrite/fix/team-fixture-lock-retry
test: retry console team fixtures on organization lock contention
This commit is contained in:
1 file changed
+13
-2
@@ -72,8 +72,19 @@ abstract class Scope extends TestCase
|
||||
|
||||
// The first organization of a self-hosted instance, and every organization on an
|
||||
// edition without the instance limit, comes from the public API. Only a refusal
|
||||
// falls through to seeding the rows directly.
|
||||
$team = $this->client->call(Client::METHOD_POST, '/teams', $headers, $params);
|
||||
// falls through to seeding the rows directly. Creation is serialized behind an
|
||||
// instance-wide lock, and parallel test processes contend for it, so a 409 asks
|
||||
// for a retry rather than answering whether the organization was allowed.
|
||||
$deadline = \microtime(true) + 10.0;
|
||||
do {
|
||||
$team = $this->client->call(Client::METHOD_POST, '/teams', $headers, $params);
|
||||
$locked = $team['headers']['status-code'] === 409
|
||||
&& ($team['body']['type'] ?? '') === 'general_resource_locked';
|
||||
if ($locked) {
|
||||
\usleep(200_000);
|
||||
}
|
||||
} while ($locked && \microtime(true) < $deadline);
|
||||
|
||||
if ($team['headers']['status-code'] === 201) {
|
||||
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $team['body']['$id'], $headers);
|
||||
$this->assertSame(200, $response['headers']['status-code']);
|
||||
|
||||
Reference in new issue
Block a user