From da8b29cd47e46ceb18c71eb3105d447373729900 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Fri, 20 Nov 2026 08:57:52 -0800 Subject: [PATCH] test: join only a launched ACK worker; composable held-CAS witness The revocation ACK test records whether its worker was launched: every exit still releases the held call, but only a launched worker is joined, so a setup failure before the launch no longer waits 10 s for a sender that does not exist or reports a join failure that did not happen. The detach-freeze witness checks the held CAS's context deadline only when the context carries one, and in every case that the CAS ended no earlier than the cut deadline, so it also holds if the cut bounds the CAS by a cancelling timer instead of a deadline. Refs #300 Co-Authored-By: Claude Opus 5.5 --- .../provider_chunk_detach_abort_test.go | 7 +++++-- .../master/workspace_binding_review_test.go | 21 +++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) 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: