From 88a03a40bb0a8956e5bf058b2f7f9e539ecbf2a8 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 25 Nov 2026 07:09:38 -0800 Subject: [PATCH] component: the apply-failure recovery test follows deferred priming The test waited for its registry adapter to probe the new peer right after the add, which is the adapter acting on a healthy peer the volume's live session owns. It now checks the adapter has issued nothing at the add and wires the probe loop as the binary does (priming on the first dispatch for a degraded peer); its degrade, recover and replay assertions are unchanged. Co-Authored-By: Claude Opus 5.5 --- .../replica_apply_failure_recovery_test.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/seaweed-block/core/replication/component/replica_apply_failure_recovery_test.go b/seaweed-block/core/replication/component/replica_apply_failure_recovery_test.go index f8f142cb92..c37f545648 100644 --- a/seaweed-block/core/replication/component/replica_apply_failure_recovery_test.go +++ b/seaweed-block/core/replication/component/replica_apply_failure_recovery_test.go @@ -112,7 +112,7 @@ func TestReplicaApplyFailure_PrimaryDegradesRecoversAndReplaysFailedLSN(t *testi if err := c.primary.RepVol.ConfigurePeerLifecycleHook(registry.OnPeerAdded, registry.OnPeerRemoved); err != nil { t.Fatalf("ConfigurePeerLifecycleHook: %v", err) } - waitAdmitted(t, registry) + waitRegisteredIdle(t, registry) ctx := context.Background() for i := 0; i < 2; i++ { @@ -153,7 +153,7 @@ func TestReplicaApplyFailure_PrimaryDegradesRecoversAndReplaysFailedLSN(t *testi t.Fatalf("WAL replay fixture retired failed LSN %d (retained=%d)", failedLSN, retained) } cfg := replication.ProbeLoopConfig{Interval: 30 * time.Millisecond, MaxConcurrent: 1, CooldownBase: 20 * time.Millisecond, CooldownCap: 200 * time.Millisecond} - if err := c.primary.RepVol.ConfigureProbeLoop(cfg, volume.ProductionProbeFn(registry.AdapterFor), time.Now); err != nil { + if err := c.primary.RepVol.ConfigureProbeLoop(cfg, volume.ProductionProbeFnWithPrime(registry.AdapterFor, registry.PrimePending), time.Now); err != nil { t.Fatalf("ConfigureProbeLoop: %v", err) } if err := c.primary.RepVol.StartProbeLoop(); err != nil { @@ -207,20 +207,23 @@ func TestReplicaApplyFailure_PrimaryDegradesRecoversAndReplaysFailedLSN(t *testi } // waitAdmitted waits for the registry adapter's assignment probe to succeed. -func waitAdmitted(t *testing.T, registry *volume.PeerAdapterRegistry) { +// waitRegisteredIdle waits for replica-0's registry adapter and checks it has +// issued nothing: a healthy peer belongs to the volume's live session, and +// its adapter is primed only when the probe loop first dispatches for it +// (once it is degraded). +func waitRegisteredIdle(t *testing.T, registry *volume.PeerAdapterRegistry) { t.Helper() deadline := time.Now().Add(2 * time.Second) for time.Now().Before(deadline) { if a := registry.AdapterFor("replica-0"); a != nil { - for _, entry := range a.Trace() { - if entry.Step == "event" && entry.Detail == "ProbeSucceeded" { - return - } + if cmds := a.CommandLog(); len(cmds) != 0 { + t.Fatalf("replica-0's adapter acted on a healthy peer: %v", cmds) } + return } time.Sleep(10 * time.Millisecond) } - t.Fatal("replica-0 was not admitted: no ProbeSucceeded on its registry adapter") + t.Fatal("replica-0 has no registry adapter") } func firstByte(b []byte) byte {