diff --git a/internal/server/http/pending_drain_test.go b/internal/server/http/pending_drain_test.go index a216c25..0cec822 100644 --- a/internal/server/http/pending_drain_test.go +++ b/internal/server/http/pending_drain_test.go @@ -145,7 +145,12 @@ func TestDrainPendingDispatchesOnReconnect(t *testing.T) { t.Errorf("backup tag: %q", got.Tag) } - // Pending row should be gone. + // Pending row should be gone. Poll briefly: the drain goroutine + // sends command.run via conn.Send and only then calls + // DeletePendingRun. Reading the envelope off the wire above proves + // the send happened, but the delete runs after that on the drain + // goroutine — small window where the count is still 1. + waitForPendingCount(t, st, hostID, 0, 2*time.Second) if n := countPendingForHost(t, st, hostID); n != 0 { t.Errorf("pending rows after drain: got %d, want 0", n) }