mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
5aab45c9dd
commit
da8b29cd47
2 files changed
+20
-8
No files matched your search
@@ -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))
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user