From a654ff248e0ce913cef18b94feff404f2f238a3e Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 14 Sep 2026 09:58:01 +0100 Subject: [PATCH] test: retry console team fixtures on organization lock contention Console organization creation is serialized behind the console:organizations:create distributed lock with a 3 second acquire timeout. The e2e suites run under ParaTest --functional, so many test processes create their console organization fixture at the same time, and a request that cannot take the lock in time answers 409 general_resource_locked. createTeamFixture treated anything other than 201 as the self-hosted refusal and failed on assertSame(403, 409), most recently in Teams / testTeamMembershipPerms on an unrelated PR. A 409 says nothing about whether the organization was allowed, only that the request should be retried, which is what the error message asks callers to do. Retry the create while it reports lock contention before deciding between the public API result and direct seeding. Co-Authored-By: Claude --- tests/e2e/Scopes/Scope.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/e2e/Scopes/Scope.php b/tests/e2e/Scopes/Scope.php index 7b15867cea..8e1c86e968 100644 --- a/tests/e2e/Scopes/Scope.php +++ b/tests/e2e/Scopes/Scope.php @@ -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']);