diff --git a/seaweed-block/core/frontend/durable/provider_chunk_detach_abort_test.go b/seaweed-block/core/frontend/durable/provider_chunk_detach_abort_test.go index 297bd7715b..c6c9c6636c 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk_detach_abort_test.go +++ b/seaweed-block/core/frontend/durable/provider_chunk_detach_abort_test.go @@ -303,8 +303,11 @@ func TestWALStoreChunk_DetachFreezeIsBoundedThenResumes(t *testing.T) { if !held.entered { t.Fatal("the detach CAS was never held") } - if !held.hasDeadline || !held.deadline.Equal(cut) { - t.Fatalf("held detach CAS deadline %v (set %v); want the cut deadline %v", held.deadline, held.hasDeadline, cut) + // The cut may bound the CAS by a context deadline or by a timer that + // cancels it: a deadline, when there is one, must be the cut's exactly; + // either way the CAS must end no earlier than the cut deadline. + if held.hasDeadline && !held.deadline.Equal(cut) { + t.Fatalf("held detach CAS deadline %v; want the cut deadline %v", held.deadline, cut) } if held.ended.Before(cut) { t.Fatalf("held detach CAS ended %v before its deadline", cut.Sub(held.ended)) diff --git a/seaweed-block/core/host/master/workspace_binding_review_test.go b/seaweed-block/core/host/master/workspace_binding_review_test.go index ce77965901..bae394f195 100644 --- a/seaweed-block/core/host/master/workspace_binding_review_test.go +++ b/seaweed-block/core/host/master/workspace_binding_review_test.go @@ -266,11 +266,20 @@ func TestWorkspaceBindingRemoteReadDoesNotBlockAck(t *testing.T) { var releaseOnce sync.Once releaseHeld := func() { releaseOnce.Do(func() { close(release) }) } // Registered before either worker launches: every exit releases the - // held call and joins its worker under its own bound, not under the - // fixture context a blocked ACK has already used up. + // held call, and a worker that was launched is joined under its own + // bound, not under the fixture context a blocked ACK has already + // used up. A setup failure before the launch joins nothing. + launched := false + launch := func(worker func() error) { + launched = true + go func() { done <- worker() }() + } var joinOnce sync.Once var joined error join := func() error { + if !launched { + return nil + } joinOnce.Do(func() { select { case joined = <-done: @@ -288,10 +297,10 @@ func TestWorkspaceBindingRemoteReadDoesNotBlockAck(t *testing.T) { }) if mode == "head" { reviewLegacyBind(t, h, c, ctx, "probe") - go func() { + launch(func() error { _, e := client.MoveWorkspace(ctx, &control.WorkspaceMove{RequestId: "held", VolumeId: "probe", ExpectedReplicaId: "r1", ExpectedEpoch: 1, TargetReplicaId: "r1", TargetServerId: "node-b", TargetDataAddr: "127.0.0.1:9200", TargetCtrlAddr: "127.0.0.1:9100", Kind: "clean"}) - done <- e - }() + return e + }) } else { if _, e := h.Lifecycle().Volumes.CreateVolume(lifecycle.VolumeSpec{VolumeID: "vol-rf3", SizeBytes: 1 << 20, ReplicationFactor: 3}); e != nil { t.Fatal(e) @@ -304,7 +313,7 @@ func TestWorkspaceBindingRemoteReadDoesNotBlockAck(t *testing.T) { waitAuthorityLine(t, h.Publisher(), "vol-rf3") ingestRF3Observation(t, h, false, true, true) h.SetPromotionEvidenceProvider(reviewHeldPromotion{arrived, release}) - go func() { _, e := h.RunLifecycleProductTick(); done <- e }() + launch(func() error { _, e := h.RunLifecycleProductTick(); return e }) } select { case <-arrived: