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:
Chirag Aggarwal authored and GitHub committed 2026-09-14 02:32:13 -07:00
commit e29d567c9e
1 file changed
+13 -2
+13 -2
View File
@@ -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']);