From 16c8f868647d3df5ea90c76f5ea390a59aa4727e Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 28 Nov 2026 10:05:22 -0800 Subject: [PATCH] test: bound each NVMe command, and give the review helper a hang guard, not a 10 s budget - The NVMe initiator renews its deadline (nvmeIODeadline, 60 s) before every I/O command, so it bounds each command instead of the connection's whole life: requireBlocks' 65,536 reads no longer race one dial-time deadline. - reviewBindingHostBeforeStart's context is a hang guard for the whole test (60 s, was 10 s), so a slow host's setup does not use up the time the later calls and the successor probe need. TestNVMeInitiatorDeadlineBoundsEachCommand and TestWorkspaceRPCSameHostForcedRecoveryOutlivesASlowSetup pass; test-only, no product change. Co-Authored-By: Claude Opus 5.5 --- .../cmd/blockvolume/planned_handoff_integration_test.go | 6 ++++-- .../core/host/master/workspace_binding_review_test.go | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go index 35b6afb632..ecb21f52c9 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go @@ -773,8 +773,9 @@ func poll(t *testing.T, timeout time.Duration, what string, fn func() bool) { // nvmeInitiator is the smallest NVMe/TCP host the test needs: one admin and // one IO queue, Write, Flush and Read of namespace 1. It runs in the test // process, so the test needs neither root nor the kernel's nvme_tcp. -// nvmeIODeadline bounds the NVMe initiator's connections. A var only so a -// test can shorten it. +// nvmeIODeadline bounds each NVMe command of the initiator: it is set at dial +// and renewed before every I/O command, so a long read loop on a slow host is +// not bounded as a whole. A var only so a test can shorten it. var nvmeIODeadline = 60 * time.Second type nvmeInitiator struct { @@ -844,6 +845,7 @@ func nvmeResponse(t *testing.T, r *nvme.Reader) nvme.CapsuleResponse { } func (c *nvmeInitiator) ioCmd(op uint8, lba uint64, blocks int) nvme.CapsuleCommand { + _ = c.io.SetDeadline(time.Now().Add(nvmeIODeadline)) c.cid++ cmd := nvme.CapsuleCommand{OpCode: op, CID: c.cid, NSID: 1} if blocks > 0 { 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 8bcdb786e6..d27f1b96b5 100644 --- a/seaweed-block/core/host/master/workspace_binding_review_test.go +++ b/seaweed-block/core/host/master/workspace_binding_review_test.go @@ -43,7 +43,9 @@ func reviewBindingHostBeforeStart(t *testing.T, reader func(context.Context, str t.Fatal(e) } t.Cleanup(func() { c.Close() }) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + // A hang guard for the whole test, not a performance bound: a slow host's + // setup must not use up the time its later calls need. + ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) t.Cleanup(cancel) for _, server := range []string{"node-a", "node-b"} { if _, e = h.Lifecycle().Nodes.RegisterNode(lifecycle.NodeRegistration{ServerID: server, DataAddr: "127.0.0.1:9200", CtrlAddr: "127.0.0.1:9100"}); e != nil {