diff --git a/seaweed-block/core/host/master/line_change_wake_test.go b/seaweed-block/core/host/master/line_change_wake_test.go index 3e9d47fef5..44fbc9c9f4 100644 --- a/seaweed-block/core/host/master/line_change_wake_test.go +++ b/seaweed-block/core/host/master/line_change_wake_test.go @@ -42,12 +42,12 @@ func TestMasterRebuildsObservationOnAPublishedLine(t *testing.T) { // buffered and no deadline timer fires within the test (the one-hour // expiry timer stays armed), all read under the host's lock; it returns // the builds done. - settle := func(what string) uint64 { + settle := func(what string, atLeast uint64) uint64 { t.Helper() deadline := time.Now().Add(5 * time.Second) for time.Now().Before(deadline) { started, done, buffered, timerAt := h.obs.BuildsForTest() - if started == done && done > 0 && !buffered && (timerAt.IsZero() || timerAt.After(time.Now().Add(time.Minute))) { + if started == done && done >= atLeast && !buffered && (timerAt.IsZero() || timerAt.After(time.Now().Add(time.Minute))) { return done } time.Sleep(10 * time.Millisecond) @@ -78,8 +78,10 @@ func TestMasterRebuildsObservationOnAPublishedLine(t *testing.T) { return false } } - // The initial build and the 1 ms grace's rebuild, finished. - n := settle("startup") + // The initial build (#1) and the 1 ms grace's rebuild (#2, with nothing + // ingested yet) both finished: the grace's deadline is consumed, so no + // timer can arm after this point and see the heartbeat. + n := settle("startup", 2) if err := h.obs.IngestHeartbeat(authority.HeartbeatMessage{ ServerID: "node-a", SentAt: time.Now().UTC(), Reachable: true, Eligible: true, Slots: []authority.HeartbeatSlot{{VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:9201", CtrlAddr: "127.0.0.1:9101", Reachable: true, ReadyForPrimary: true, Eligible: true}},