From 3b3177722bc2ba5ab5b46493bfd655fa1ccf1f45 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 24 Feb 2026 20:06:20 +1300 Subject: [PATCH] fix: cache setup data before waiting to prevent 409 on retry When setupAttributes() or setupIndexes() timed out during waitForAllAttributes/waitForAllIndexes, the cache was never populated. Subsequent test methods calling setup again would find empty cache, reuse the same collection IDs (from collection cache), and attempt to re-create existing attributes/indexes, resulting in 409 Conflict errors. Fix: populate the static cache immediately after successful creation (202 assertions), before the wait calls. This ensures retries skip creation and go straight to waiting. Co-Authored-By: Claude Opus 4.6 --- tests/e2e/Services/Databases/DatabasesBase.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index ffbbd61a68..780653dc96 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -281,11 +281,14 @@ trait DatabasesBase $this->assertEquals(202, $bookTitle['headers']['status-code']); $this->assertEquals(202, $bookDescription['headers']['status-code']); + // Cache before waiting so that if waitForAllAttributes times out, + // subsequent calls don't try to re-create the same attributes (causing 409) + self::$attributesCache[$cacheKey] = $data; + // wait for database worker to create attributes $this->waitForAllAttributes($databaseId, $data['moviesId']); $this->waitForAllAttributes($databaseId, $data['booksId']); - self::$attributesCache[$cacheKey] = $data; return self::$attributesCache[$cacheKey]; } @@ -360,10 +363,13 @@ trait DatabasesBase $this->assertEquals(202, $releaseWithDate2['headers']['status-code']); $this->assertEquals(202, $booksFtsIndex['headers']['status-code']); + // Cache before waiting so that if waitForAllIndexes times out, + // subsequent calls don't try to re-create the same indexes (causing 409) + self::$indexesCache[$cacheKey] = $data; + $this->waitForAllIndexes($databaseId, $data['moviesId']); $this->waitForAllIndexes($databaseId, $data['booksId']); - self::$indexesCache[$cacheKey] = $data; return self::$indexesCache[$cacheKey]; }