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

This commit is contained in:
Matthew Meszaros
2026-09-09 05:44:25 -07:00
parent 65fe82c472
commit 92470e1528
+8 -12
View File
@@ -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,