From b201bbb74dd7cc28f858429091c2555269f4d3bc Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 25 Nov 2026 21:40:26 -0800 Subject: [PATCH] test(master): fixtures record the first ready answer where the primary served; the restart gap is still creating Co-Authored-By: Claude Opus 5.5 --- .../core/host/master/creating_primary_gate_test.go | 7 ++++--- seaweed-block/core/host/master/creation_phase_test.go | 11 +++++++++++ seaweed-block/core/host/master/product_loop_test.go | 1 + .../host/master/promotion_adoption_regression_test.go | 1 + .../core/host/master/store_attestation_test.go | 1 + 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/seaweed-block/core/host/master/creating_primary_gate_test.go b/seaweed-block/core/host/master/creating_primary_gate_test.go index 9697a23dd6..b3379fdf40 100644 --- a/seaweed-block/core/host/master/creating_primary_gate_test.go +++ b/seaweed-block/core/host/master/creating_primary_gate_test.go @@ -50,8 +50,9 @@ func TestPrimaryAwaitingReplicaStoresIsNotReplacedForNotReady(t *testing.T) { // The real-path schedule: the master has recorded every store (its wait is // over) but the primary has not received the re-sent assignment yet, so it // still answers "awaiting replica stores"; the master restarts in that gap. -// The excuse is the primary's own answer, so nothing the master forgets on a -// restart reopens the gap: the line stays. +// Creation ends only at the primary's first ready answer, recorded durably, +// so the restarted master still holds the volume: no decision, the line +// stays. func TestMasterRestartInTheGapDoesNotReassign(t *testing.T) { cfg := Config{AuthorityStoreDir: t.TempDir(), LifecycleStoreDir: t.TempDir(), ControllerConfig: authority.TopologyControllerConfig{PrimaryBootGrace: 200 * time.Millisecond}} @@ -74,7 +75,7 @@ func TestMasterRestartInTheGapDoesNotReassign(t *testing.T) { t.Fatal("fixture: the restarted master still waits for stores") } time.Sleep(250 * time.Millisecond) // past the boot grace - unsupportedTick(t, h2, readySlot("r1-a")) + creatingTick(t, h2, readySlot("r1-a")) expectLineStaysR1(t, h2, "restarted master, primary still awaiting the re-sent stores") } diff --git a/seaweed-block/core/host/master/creation_phase_test.go b/seaweed-block/core/host/master/creation_phase_test.go index a929e4101b..91d5a263e4 100644 --- a/seaweed-block/core/host/master/creation_phase_test.go +++ b/seaweed-block/core/host/master/creation_phase_test.go @@ -239,3 +239,14 @@ func TestCreationEndsAtThePrimarysFirstReadyAnswer(t *testing.T) { t.Fatalf("creation reopened after it ended (%s)", why) } } + +// recordFirstReady records that the volume's primary answered ready at its +// first line (after its stores were attested): fixtures whose primary was +// healthy before the scenario's failure. +func recordFirstReady(t *testing.T, h *Host, volumeID string) { + t.Helper() + h.attest.awaited(volumeID, h.replicaSlotsFor(volumeID)) + if err := h.attest.noteFirstReady(volumeID); err != nil { + t.Fatal(err) + } +} diff --git a/seaweed-block/core/host/master/product_loop_test.go b/seaweed-block/core/host/master/product_loop_test.go index d811603c93..7a4218ca18 100644 --- a/seaweed-block/core/host/master/product_loop_test.go +++ b/seaweed-block/core/host/master/product_loop_test.go @@ -460,6 +460,7 @@ func TestMountedFailover_ProductLoopRF3PromotesWhenCurrentProbeIsDownDespiteStal t.Fatalf("initial line=%+v want r1", initial) } attestAllStores(t, h) // an established volume, out of its creation wait + recordFirstReady(t, h, "vol-rf3") // Heartbeat state still says r1 is acceptable. The on-demand // current-primary probe is the fresher failure signal and must diff --git a/seaweed-block/core/host/master/promotion_adoption_regression_test.go b/seaweed-block/core/host/master/promotion_adoption_regression_test.go index f9b38531a9..a4a3b22283 100644 --- a/seaweed-block/core/host/master/promotion_adoption_regression_test.go +++ b/seaweed-block/core/host/master/promotion_adoption_regression_test.go @@ -77,6 +77,7 @@ func TestPromotionRefusesReplicaMissingAcknowledgedWrite(t *testing.T) { if err := h.ingestStoreAttestation("node-a", attestation("vol-rf3", "r1", initial.Epoch, attested)); err != nil { t.Fatal(err) } + recordFirstReady(t, h, "vol-rf3") // the primary served before it failed if err := cluster.Primary().RepVol.Close(); err != nil { t.Fatal(err) } diff --git a/seaweed-block/core/host/master/store_attestation_test.go b/seaweed-block/core/host/master/store_attestation_test.go index ba127ef571..671af17a96 100644 --- a/seaweed-block/core/host/master/store_attestation_test.go +++ b/seaweed-block/core/host/master/store_attestation_test.go @@ -139,6 +139,7 @@ func TestPromotionRefusesAReplacedStoreThePrimaryNeverAttested(t *testing.T) { if err := h.ingestStoreAttestation("node-a", attestation("vol-rf3", "r1", line.Epoch, map[string]storage.StoreID{"r1": storeID(1), "r2": s1, "r3": t1})); err != nil { t.Fatal(err) } + recordFirstReady(t, h, "vol-rf3") // the primary served before it failed // r2's node reports its new store: never the reference. if err := h.ingestStoreAttestation("node-b", attestation("vol-rf3", "r2", line.Epoch, map[string]storage.StoreID{"r2": s2})); err != nil { t.Fatal(err)