test: keep the status endpoint on loopback when the harness listens off loopback

blockvolume refuses a non-loopback status bind; sw-block ops reach it
with --status-addr from the same host, so it uses headSzLoopbackAddr
like the NVMe listener.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-24 13:49:22 -08:00
1 parent eb471459de
commit 05ebed50c2
2 files changed
+6 -5

No files matched your search

@@ -218,7 +218,7 @@ func headSzStartCluster(t *testing.T, prefix string, vols []headSzVol) (*handoff
server, replica = v.server, "r1"
}
b := bvHost{id: v.id, server: server, replica: replica, volume: v.id, root: filepath.Join(h.dir, "vol-"+v.id),
data: handoffAddress(t), ctrl: handoffAddress(t), status: handoffAddress(t), nvme: headSzLoopbackAddr(t)}
data: handoffAddress(t), ctrl: handoffAddress(t), status: headSzLoopbackAddr(t), nvme: headSzLoopbackAddr(t)}
if v.host != "" {
b.data, b.ctrl = headSzRemoteAddr(t, v.host), headSzRemoteAddr(t, v.host)
}
@@ -246,9 +246,10 @@ func headSzStartCluster(t *testing.T, prefix string, vols []headSzVol) (*handoff
}
// headSzLoopbackAddr picks a free 127.0.0.1 port from the harness's range:
// blockvolume's NVMe/TCP target refuses any non-loopback bind, and the test
// (user-space client or kernel nvme connect) always runs on the same host as
// that blockvolume, also when SWBLOCK_TEST_LISTEN_HOST names a host address.
// blockvolume's NVMe/TCP target and status endpoint refuse any non-loopback
// bind, and the test (user-space client, kernel nvme connect, sw-block ops
// --status-addr) always reaches them from the same host as that blockvolume,
// also when SWBLOCK_TEST_LISTEN_HOST names a host address.
func headSzLoopbackAddr(t *testing.T) string {
t.Helper()
handoffPorts.Lock()
@@ -244,7 +244,7 @@ func kzTargetRole(t *testing.T, rep *kzReport, bytes uint64, device bool, run st
rep.ChunkPath = ho.ChunkPath
for _, ht := range ho.Targets {
tb := bvHost{id: ht.Volume, server: ht.Server, replica: "r1", volume: ht.Volume, root: filepath.Join(h.dir, "vol-"+ht.Volume),
data: ht.Data, ctrl: ht.Ctrl, status: handoffAddress(t), nvme: headSzLoopbackAddr(t)}
data: ht.Data, ctrl: ht.Ctrl, status: headSzLoopbackAddr(t), nvme: headSzLoopbackAddr(t)}
env.hosts[ht.Volume] = tb
src := kzVolume{Volume: ht.Source, S1Name: ht.S1, Dirty1: ht.Dirty1, Files: ht.Files, Blocks: map[uint64][]byte{}}
for k, v := range ht.Blocks {