From 92470e1528ca115ef59ede437d3af8cf2b9f9c8f Mon Sep 17 00:00:00 2001 From: Matthew Meszaros Date: Wed, 9 Sep 2026 05:44:25 -0700 Subject: [PATCH] feat: drop the racy liveness re-read from the placement live test, which re-queried whichever worker placement chose and so raced with the email package's live tests creating and deleting their own worker in a parallel package; that placement only ever picks a live worker is already covered by the unit tests, which need no database --- internal/app/fleet/rotation_live_test.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/internal/app/fleet/rotation_live_test.go b/internal/app/fleet/rotation_live_test.go index f021068d..d3c41f17 100644 --- a/internal/app/fleet/rotation_live_test.go +++ b/internal/app/fleet/rotation_live_test.go @@ -96,23 +96,19 @@ func TestLivePlacementAndRotation(t *testing.T) { t.Fatal(err) } - // 1. Every mailbox places on SOME live worker, and is stamped so rotation - // can enforce residency. Which worker is not asserted: the database may - // already hold a fleet, and any live worker is a legitimate answer. + // 1. Every mailbox places, and is stamped so rotation can enforce residency. + // + // Which worker it lands on is deliberately NOT asserted. The database + // may already hold a fleet, any live worker is a legitimate answer, and + // live tests in other packages create and delete their own workers + // concurrently - re-reading the chosen worker here raced with one of + // those deletes. That placement only ever picks a live worker is + // covered by the placement unit tests, which need no database. for i, mb := range mailboxes { got, err := svc.AssignWorkerToEmail(ctx, mb, orgID) if err != nil || got == nil { t.Fatalf("mailbox %d did not place: %v", i, err) } - var live bool - if err := pool.QueryRow(ctx, ` - SELECT active AND last_seen_at > now() - interval '5 minutes' - FROM fleet_nodes WHERE id = $1`, *got).Scan(&live); err != nil { - t.Fatalf("mailbox %d landed on %s, which has no node row: %v", i, *got, err) - } - if !live { - t.Fatalf("mailbox %d placed on %s, which is not live", i, *got) - } var assigned *string if err := pool.QueryRow(ctx,