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 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-28 10:05:22 -08:00
1 parent 2095acfd7a
commit 16c8f86864
2 files changed
+7 -3

No files matched your search

@@ -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 {
@@ -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 {