From 8fb26969d3c9b2e50a85a1693a4e3780a41656eb Mon Sep 17 00:00:00 2001 From: pingqiu Date: Thu, 26 Nov 2026 13:28:03 -0800 Subject: [PATCH 1/4] Layout move test: run the product loop; use the gate's prebuilt binary A line is issued for the process at its endpoints, and a holder refuses a line that names another process. The test minted the initial line from a hand-ingested observation before the source started, so it named no process and the source refused it ("issued for process "; source did not serve). The test now runs the lifecycle product loop as blockmaster does, which re-issues a line once the process reports itself (the initial line, and a move's target). LAYOUT_MOVE_NO_PRODUCT_LOOP=1 leaves the loop off and reproduces the refusal (the control). With SWBLOCK_TEST_BINS set (a gate run) the test uses that prebuilt blockvolume instead of building a race-enabled one, so the binary it runs is the one the gate hashed. Co-Authored-By: Claude Opus 5.5 --- .../workspace_layout_move_integration_test.go | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/workspace_layout_move_integration_test.go b/seaweed-block/cmd/blockvolume/workspace_layout_move_integration_test.go index 18bc5d3c11..f9a7685e0a 100644 --- a/seaweed-block/cmd/blockvolume/workspace_layout_move_integration_test.go +++ b/seaweed-block/cmd/blockvolume/workspace_layout_move_integration_test.go @@ -134,9 +134,16 @@ func TestIntegrationWorkspaceLayoutMove(t *testing.T) { if os.Getenv("CHUNKSTORE_WEED") == "" { t.Skip("CHUNKSTORE_WEED not set") } - exe := filepath.Join(t.TempDir(), "blockvolume") - if out, err := exec.Command("go", "build", "-race", "-p", "4", "-o", exe, ".").CombinedOutput(); err != nil { - t.Fatalf("build: %v %s", err, out) + // A gate run supplies its prebuilt, hashed binaries (SWBLOCK_TEST_BINS); + // a local run builds a race-enabled one. + exe := filepath.Join(os.Getenv("SWBLOCK_TEST_BINS"), "blockvolume") + if os.Getenv("SWBLOCK_TEST_BINS") == "" { + exe = filepath.Join(t.TempDir(), "blockvolume") + if out, err := exec.Command("go", "build", "-race", "-p", "4", "-o", exe, ".").CombinedOutput(); err != nil { + t.Fatalf("build: %v %s", err, out) + } + } else if _, err := os.Stat(exe); err != nil { + t.Fatalf("SWBLOCK_TEST_BINS has no blockvolume: %v", err) } cluster := startWorkspaceWeed(t) for _, kind := range []string{"clean", "forced"} { @@ -170,6 +177,29 @@ func layoutMove(t *testing.T, exe string, cluster *w4WeedCluster, kind string) { defer c() _ = h.Close(ctx) }) + // The lifecycle product loop runs as blockmaster runs it + // (--lifecycle-product-loop-interval): a line is issued for the process + // at its endpoints, and a line minted before a process reported itself + // (the initial one below, a move's target) is re-issued once it does. + // LAYOUT_MOVE_NO_PRODUCT_LOOP=1 leaves it off: the source then refuses + // the line that names no process and never serves (the control). + if os.Getenv("LAYOUT_MOVE_NO_PRODUCT_LOOP") != "1" { + stop, done := make(chan struct{}), make(chan struct{}) + go func() { + defer close(done) + tick := time.NewTicker(100 * time.Millisecond) + defer tick.Stop() + for { + select { + case <-stop: + return + case <-tick.C: + _, _ = h.RunLifecycleProductTick() + } + } + }() + t.Cleanup(func() { close(stop); <-done }) + } src, dst := newMoveHost(t, "node-a", "nqn.2026-11.test:move-src-"+kind), newMoveHost(t, "node-b", "nqn.2026-11.test:move-dst-"+kind) // The master's create writes VOLUME and the unclaimed HEAD, then marks // the record store-ready; only a store-ready volume gets a placement. From c2ee18cdcc9f1842ae0963ec71b08f966f1e11da Mon Sep 17 00:00:00 2001 From: pingqiu Date: Thu, 26 Nov 2026 13:34:31 -0800 Subject: [PATCH 2/4] Lease binary test: the same product loop and prebuilt binary TestBinaryWorkspaceLeaseOptInOwnsCLEANShutdown minted its line from a hand-ingested observation before the holder started, like the layout move test, so the holder refused the line that named no process. Both tests now share runProductLoop (the lifecycle product loop every 100 ms, as blockmaster runs it) and blockvolumeUnderTest (the gate's prebuilt binary when SWBLOCK_TEST_BINS is set). The control is now SWBLOCK_TEST_NO_PRODUCT_LOOP=1, for both tests. Co-Authored-By: Claude Opus 5.5 --- .../workspace_layout_move_integration_test.go | 36 +------------ .../workspace_lease_binary_test.go | 54 +++++++++++++++++-- 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/workspace_layout_move_integration_test.go b/seaweed-block/cmd/blockvolume/workspace_layout_move_integration_test.go index f9a7685e0a..8ddc11a747 100644 --- a/seaweed-block/cmd/blockvolume/workspace_layout_move_integration_test.go +++ b/seaweed-block/cmd/blockvolume/workspace_layout_move_integration_test.go @@ -134,17 +134,7 @@ func TestIntegrationWorkspaceLayoutMove(t *testing.T) { if os.Getenv("CHUNKSTORE_WEED") == "" { t.Skip("CHUNKSTORE_WEED not set") } - // A gate run supplies its prebuilt, hashed binaries (SWBLOCK_TEST_BINS); - // a local run builds a race-enabled one. - exe := filepath.Join(os.Getenv("SWBLOCK_TEST_BINS"), "blockvolume") - if os.Getenv("SWBLOCK_TEST_BINS") == "" { - exe = filepath.Join(t.TempDir(), "blockvolume") - if out, err := exec.Command("go", "build", "-race", "-p", "4", "-o", exe, ".").CombinedOutput(); err != nil { - t.Fatalf("build: %v %s", err, out) - } - } else if _, err := os.Stat(exe); err != nil { - t.Fatalf("SWBLOCK_TEST_BINS has no blockvolume: %v", err) - } + exe := blockvolumeUnderTest(t) cluster := startWorkspaceWeed(t) for _, kind := range []string{"clean", "forced"} { t.Run(kind, func(t *testing.T) { layoutMove(t, exe, cluster, kind) }) @@ -177,29 +167,7 @@ func layoutMove(t *testing.T, exe string, cluster *w4WeedCluster, kind string) { defer c() _ = h.Close(ctx) }) - // The lifecycle product loop runs as blockmaster runs it - // (--lifecycle-product-loop-interval): a line is issued for the process - // at its endpoints, and a line minted before a process reported itself - // (the initial one below, a move's target) is re-issued once it does. - // LAYOUT_MOVE_NO_PRODUCT_LOOP=1 leaves it off: the source then refuses - // the line that names no process and never serves (the control). - if os.Getenv("LAYOUT_MOVE_NO_PRODUCT_LOOP") != "1" { - stop, done := make(chan struct{}), make(chan struct{}) - go func() { - defer close(done) - tick := time.NewTicker(100 * time.Millisecond) - defer tick.Stop() - for { - select { - case <-stop: - return - case <-tick.C: - _, _ = h.RunLifecycleProductTick() - } - } - }() - t.Cleanup(func() { close(stop); <-done }) - } + runProductLoop(t, h) src, dst := newMoveHost(t, "node-a", "nqn.2026-11.test:move-src-"+kind), newMoveHost(t, "node-b", "nqn.2026-11.test:move-dst-"+kind) // The master's create writes VOLUME and the unclaimed HEAD, then marks // the record store-ready; only a store-ready volume gets a placement. diff --git a/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go b/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go index fd1fa67583..de7b8edd26 100644 --- a/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go +++ b/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go @@ -57,15 +57,58 @@ func leaseBinaryPost(addr, op string) (int, []byte, error) { return resp.StatusCode, b, err } +// blockvolumeUnderTest is the blockvolume a test starts: a gate run's +// prebuilt, hashed binary (SWBLOCK_TEST_BINS), or a race-enabled build for a +// local run. +func blockvolumeUnderTest(t *testing.T) string { + t.Helper() + if d := os.Getenv("SWBLOCK_TEST_BINS"); d != "" { + exe := filepath.Join(d, "blockvolume") + if _, err := os.Stat(exe); err != nil { + t.Fatalf("SWBLOCK_TEST_BINS has no blockvolume: %v", err) + } + return exe + } + exe := filepath.Join(t.TempDir(), "blockvolume") + if out, err := exec.Command("go", "build", "-race", "-p", "4", "-o", exe, ".").CombinedOutput(); err != nil { + t.Fatalf("build: %v %s", err, out) + } + return exe +} + +// runProductLoop runs h's lifecycle product loop for the rest of the test, +// as blockmaster runs it (--lifecycle-product-loop-interval): a line is +// issued for the process at its endpoints, and a line minted before a +// process reported itself (a hand-published initial line, a move's target) +// is re-issued once it does. SWBLOCK_TEST_NO_PRODUCT_LOOP=1 leaves it off: +// the holder then refuses a line that names no process (the control). +func runProductLoop(t *testing.T, h *master.Host) { + t.Helper() + if os.Getenv("SWBLOCK_TEST_NO_PRODUCT_LOOP") == "1" { + return + } + stop, done := make(chan struct{}), make(chan struct{}) + go func() { + defer close(done) + tick := time.NewTicker(100 * time.Millisecond) + defer tick.Stop() + for { + select { + case <-stop: + return + case <-tick.C: + _, _ = h.RunLifecycleProductTick() + } + } + }() + t.Cleanup(func() { close(stop); <-done }) +} + func TestBinaryWorkspaceLeaseOptInOwnsCLEANShutdown(t *testing.T) { if os.Getenv("CHUNKSTORE_WEED") == "" { t.Skip("CHUNKSTORE_WEED not set") } - exe := filepath.Join(t.TempDir(), "blockvolume") - build := exec.Command("go", "build", "-race", "-p", "4", "-o", exe, ".") - if out, err := build.CombinedOutput(); err != nil { - t.Fatalf("build: %v %s", err, out) - } + exe := blockvolumeUnderTest(t) cluster := startWorkspaceWeed(t) for _, enabled := range []bool{false, true} { t.Run(fmt.Sprintf("workspace-rpc-%v", enabled), func(t *testing.T) { @@ -93,6 +136,7 @@ func TestBinaryWorkspaceLeaseOptInOwnsCLEANShutdown(t *testing.T) { defer c() _ = h.Close(ctx) }) + runProductLoop(t, h) dataAddr, ctrlAddr, statusAddr, nvmeAddr := leaseBinaryAddress(t), leaseBinaryAddress(t), leaseBinaryAddress(t), leaseBinaryAddress(t) // The master's create writes VOLUME and the unclaimed HEAD, then // marks the record store-ready; only a store-ready volume gets a placement. From 903626f0e9eb1df6e11ffce336bb35b943c15e57 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Thu, 26 Nov 2026 13:56:29 -0800 Subject: [PATCH 3/4] Layout move and lease tests mint the first line after the holder reports A primary line is issued for the process at its endpoints and blockvolume refuses a line that names no process. For a workspace-bound RF1 volume the product loop's direct path never re-issues a line whose addresses already match, so a line minted from a hand-ingested observation before the holder started was never replaced, loop or not. Both tests now start the holder, wait until blockmaster observes its slot with its process incarnation, and only then run the product tick that binds, as production orders it. SWBLOCK_TEST_EARLY_LINE=1 is the control: the line is minted from a hand-ingested observation before the holder starts, with no product loop, as before. Native: lease PASS, control FAIL at "unleased host did not adopt assignment"; move control FAIL at "source did not serve" with the empty-process refusal. Co-Authored-By: Claude Opus 5.5 --- .../workspace_layout_move_integration_test.go | 16 ++--- .../workspace_lease_binary_test.go | 59 ++++++++++++++----- 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/workspace_layout_move_integration_test.go b/seaweed-block/cmd/blockvolume/workspace_layout_move_integration_test.go index 8ddc11a747..890ba9caa0 100644 --- a/seaweed-block/cmd/blockvolume/workspace_layout_move_integration_test.go +++ b/seaweed-block/cmd/blockvolume/workspace_layout_move_integration_test.go @@ -15,7 +15,6 @@ import ( "testing" "time" - "github.com/seaweedfs/seaweed-block/core/authority" "github.com/seaweedfs/seaweed-block/core/frontend" "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore" "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout" @@ -182,19 +181,14 @@ func layoutMove(t *testing.T, exe string, cluster *w4WeedCluster, kind string) { {VolumeID: "vol-a", ServerID: src.server, ReplicaID: "r1", Source: lifecycle.PlacementSourceExistingReplica}}}); err != nil { t.Fatal(err) } - if err = h.ObservationHost().Ingest(authority.Observation{ServerID: src.server, ObservedAt: time.Now().UTC(), - Slots: []authority.SlotFact{{VolumeID: "vol-a", ReplicaID: "r1", DataAddr: src.data, CtrlAddr: src.ctrl}}}); err != nil { - t.Fatal(err) - } - if _, err = h.RunLifecycleProductTick(); err != nil { - t.Fatal(err) - } - leaseBinaryPoll(t, "no initial authority", func() bool { line, ok := h.Publisher().VolumeAuthorityLine("vol-a"); return ok && line.Epoch > 0 }) - line, _ := h.Publisher().VolumeAuthorityLine("vol-a") + earlyLineControl(t, h, src.server, "vol-a", "r1", src.data, src.ctrl) remote := cluster.remote(t, base, ref) - // The source serves, takes acknowledged writes, cuts. + // The source starts, reports its process, gets its line, serves, takes + // acknowledged writes, cuts. src.start(t, exe, h.Addr(), cluster.filerGRPC, base, layoutID) + tickAfterProcessReports(t, h, src.server, "vol-a", "r1") + line, _ := h.Publisher().VolumeAuthorityLine("vol-a") leaseBinaryPoll(t, "source did not serve", func() bool { p, ok := src.projection(); return ok && p.Healthy && p.Epoch == line.Epoch }) want, late := bytes.Repeat([]byte{0xD7}, 4096), bytes.Repeat([]byte{0x5A}, 4096) nv := gap1ConnectNVMe(t, src.nvme, src.nqn) diff --git a/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go b/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go index de7b8edd26..39f34fe369 100644 --- a/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go +++ b/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go @@ -77,14 +77,12 @@ func blockvolumeUnderTest(t *testing.T) string { } // runProductLoop runs h's lifecycle product loop for the rest of the test, -// as blockmaster runs it (--lifecycle-product-loop-interval): a line is -// issued for the process at its endpoints, and a line minted before a -// process reported itself (a hand-published initial line, a move's target) -// is re-issued once it does. SWBLOCK_TEST_NO_PRODUCT_LOOP=1 leaves it off: -// the holder then refuses a line that names no process (the control). +// as blockmaster runs it (--lifecycle-product-loop-interval). The early-line +// control (SWBLOCK_TEST_EARLY_LINE=1) runs without it, as the fixture did +// before: a running loop could bind after the holder reported and mask it. func runProductLoop(t *testing.T, h *master.Host) { t.Helper() - if os.Getenv("SWBLOCK_TEST_NO_PRODUCT_LOOP") == "1" { + if os.Getenv("SWBLOCK_TEST_EARLY_LINE") == "1" { return } stop, done := make(chan struct{}), make(chan struct{}) @@ -104,6 +102,44 @@ func runProductLoop(t *testing.T, h *master.Host) { t.Cleanup(func() { close(stop); <-done }) } +// A primary line is issued for the process at its endpoints: the bind +// records the process the holder reports, and the holder (blockvolume sets +// LinesNameTheirProcess) refuses a line that names no process. So, as in +// production, the first line is minted only after the holder process has +// reported its slot: tickAfterProcessReports waits for that report, then +// runs the product tick that binds. +// +// SWBLOCK_TEST_EARLY_LINE=1 is the control: earlyLineControl mints the line +// from a hand-ingested observation before the holder starts, so the line +// names no process, the holder refuses it and never serves. +func earlyLineControl(t *testing.T, h *master.Host, server, volume, replica, data, ctrl string) { + t.Helper() + if os.Getenv("SWBLOCK_TEST_EARLY_LINE") != "1" { + return + } + if err := h.ObservationHost().Ingest(authority.Observation{ServerID: server, ObservedAt: time.Now().UTC(), + Slots: []authority.SlotFact{{VolumeID: volume, ReplicaID: replica, DataAddr: data, CtrlAddr: ctrl}}}); err != nil { + t.Fatal(err) + } + if _, err := h.RunLifecycleProductTick(); err != nil { + t.Fatal(err) + } +} + +func tickAfterProcessReports(t *testing.T, h *master.Host, server, volume, replica string) { + t.Helper() + if os.Getenv("SWBLOCK_TEST_EARLY_LINE") != "1" { + leaseBinaryPoll(t, "the holder never reported its process", func() bool { + s, ok := h.ObservationHost().Store().SlotFactOnServer(server, volume, replica) + return ok && s.Incarnation != "" + }) + } + if _, err := h.RunLifecycleProductTick(); err != nil { + t.Fatal(err) + } + leaseBinaryPoll(t, "no initial authority", func() bool { line, ok := h.Publisher().VolumeAuthorityLine(volume); return ok && line.Epoch > 0 }) +} + func TestBinaryWorkspaceLeaseOptInOwnsCLEANShutdown(t *testing.T) { if os.Getenv("CHUNKSTORE_WEED") == "" { t.Skip("CHUNKSTORE_WEED not set") @@ -147,14 +183,7 @@ func TestBinaryWorkspaceLeaseOptInOwnsCLEANShutdown(t *testing.T) { if _, err = h.Lifecycle().Placements.ApplyPlan(lifecycle.PlacementPlan{VolumeID: "vol-a", DesiredRF: 1, Candidates: []lifecycle.PlacementCandidate{{VolumeID: "vol-a", ServerID: "node-a", ReplicaID: "r1", Source: lifecycle.PlacementSourceExistingReplica}}}); err != nil { t.Fatal(err) } - if err = h.ObservationHost().Ingest(authority.Observation{ServerID: "node-a", ObservedAt: time.Now().UTC(), Slots: []authority.SlotFact{{VolumeID: "vol-a", ReplicaID: "r1", DataAddr: dataAddr, CtrlAddr: ctrlAddr}}}); err != nil { - t.Fatal(err) - } - if _, err = h.RunLifecycleProductTick(); err != nil { - t.Fatal(err) - } - leaseBinaryPoll(t, "no initial authority", func() bool { line, ok := h.Publisher().VolumeAuthorityLine("vol-a"); return ok && line.Epoch > 0 }) - line, _ := h.Publisher().VolumeAuthorityLine("vol-a") + earlyLineControl(t, h, "node-a", "vol-a", "r1", dataAddr, ctrlAddr) logPath := filepath.Join(t.TempDir(), "volume.log") log, err := os.Create(logPath) if err != nil { @@ -187,6 +216,8 @@ func TestBinaryWorkspaceLeaseOptInOwnsCLEANShutdown(t *testing.T) { t.Logf("volume log: %s", b) } }) + tickAfterProcessReports(t, h, "node-a", "vol-a", "r1") + line, _ := h.Publisher().VolumeAuthorityLine("vol-a") client := &http.Client{Timeout: time.Second} projection := func() (frontend.Projection, bool) { resp, e := client.Get("http://" + statusAddr + "/status?volume=vol-a") From 4a2ef23581c3408ab8affdaf11540208a3e3a294 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Thu, 26 Nov 2026 14:31:32 -0800 Subject: [PATCH 4/4] test: early-line control runs no tick after the holder starts The control minted its line before the holder started, then ran one product tick after the start. When the holder had already reported its process by that tick, the unbound placement went through the controller, which re-issued the line for that process, and the control passed. The control now waits for the early line, checks that it names no process, and runs no tick after the holder starts (the order the fixture used before), so the holder refuses the line on every run. Co-Authored-By: Claude Opus 5.5 --- .../workspace_lease_binary_test.go | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go b/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go index 39f34fe369..a6f1342904 100644 --- a/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go +++ b/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go @@ -109,9 +109,13 @@ func runProductLoop(t *testing.T, h *master.Host) { // reported its slot: tickAfterProcessReports waits for that report, then // runs the product tick that binds. // -// SWBLOCK_TEST_EARLY_LINE=1 is the control: earlyLineControl mints the line -// from a hand-ingested observation before the holder starts, so the line -// names no process, the holder refuses it and never serves. +// SWBLOCK_TEST_EARLY_LINE=1 is the control, the order the fixture used +// before: earlyLineControl mints the line from a hand-ingested observation +// before the holder starts, and no product tick runs after the holder +// starts. The line names no process, the holder refuses it and never +// serves. A tick after the holder reported would re-issue the line for its +// process (an unbound placement goes through the controller, which +// refreshes on a process change), so the control runs none. func earlyLineControl(t *testing.T, h *master.Host, server, volume, replica, data, ctrl string) { t.Helper() if os.Getenv("SWBLOCK_TEST_EARLY_LINE") != "1" { @@ -124,16 +128,21 @@ func earlyLineControl(t *testing.T, h *master.Host, server, volume, replica, dat if _, err := h.RunLifecycleProductTick(); err != nil { t.Fatal(err) } + leaseBinaryPoll(t, "control: no early line", func() bool { line, ok := h.Publisher().VolumeAuthorityLine(volume); return ok && line.Epoch > 0 }) + if line, _ := h.Publisher().VolumeAuthorityLine(volume); line.Incarnation != "" { + t.Fatalf("control: want an early line that names no process, have %+v", line) + } } func tickAfterProcessReports(t *testing.T, h *master.Host, server, volume, replica string) { t.Helper() - if os.Getenv("SWBLOCK_TEST_EARLY_LINE") != "1" { - leaseBinaryPoll(t, "the holder never reported its process", func() bool { - s, ok := h.ObservationHost().Store().SlotFactOnServer(server, volume, replica) - return ok && s.Incarnation != "" - }) + if os.Getenv("SWBLOCK_TEST_EARLY_LINE") == "1" { + return } + leaseBinaryPoll(t, "the holder never reported its process", func() bool { + s, ok := h.ObservationHost().Store().SlotFactOnServer(server, volume, replica) + return ok && s.Incarnation != "" + }) if _, err := h.RunLifecycleProductTick(); err != nil { t.Fatal(err) }