From 13683aca43b986ffe751ac84cc3b3e263deac90e Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 3 May 2026 23:21:25 -0700 Subject: [PATCH 01/11] docs: audit V2 frontend coverage gaps --- .../docs/iscsi-v2-coverage-gap-audit.md | 255 ++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 seaweed-block/internal/docs/iscsi-v2-coverage-gap-audit.md diff --git a/seaweed-block/internal/docs/iscsi-v2-coverage-gap-audit.md b/seaweed-block/internal/docs/iscsi-v2-coverage-gap-audit.md new file mode 100644 index 0000000000..d69c4b230a --- /dev/null +++ b/seaweed-block/internal/docs/iscsi-v2-coverage-gap-audit.md @@ -0,0 +1,255 @@ +# iSCSI / Frontend V2 Coverage Gap Audit + +Date: 2026-05-04 +Branch: `iscsi-p2/os-initiator-stability` +Scope: compare V2 `weed/storage/blockvol` frontend coverage against V3 `seaweed-block` before adding more iSCSI-P2 product code. + +## Goal + +Do not port V2 code blindly. Use V2's test suite as a coverage inventory and decide which missing V3 tests would have prevented recent debug loops, especially the iSCSI OS-initiator large I/O issues. + +## Source Inventory + +V2 paths reviewed: + +- `weed/storage/blockvol/iscsi/*_test.go` +- `weed/storage/blockvol/nvme/*_test.go` +- `weed/storage/blockvol/csi/*_test.go` +- `weed/storage/blockvol/test/component/*` +- `weed/storage/blockvol/testrunner/scenarios/*` + +V3 paths compared: + +- `core/frontend/iscsi/*_test.go` +- `core/frontend/nvme/*_test.go` +- `core/csi/*_test.go` +- `cmd/blockcsi/*_test.go` +- `cmd/blockvolume/*_test.go` +- `internal/docs/iscsi-os-initiator-compat-plan.md` + +## What V3 Already Covers Well + +### iSCSI protocol basics + +V3 has good coverage for: + +- PDU framing, AHS, data segment size, truncation. +- Login direct-to-FFP and staged negotiation. +- Discovery session basics and SendTargets. +- Basic SCSI READ/WRITE, stale backend, closed backend, unknown opcode. +- INQUIRY, VPD 0x80/0x83, READ CAPACITY 10/16, MODE SENSE, SYNC CACHE. +- Endpoint version / stale lineage fail-closed. + +Representative V3 tests: + +- `core/frontend/iscsi/pdu_test.go` +- `core/frontend/iscsi/login_test.go` +- `core/frontend/iscsi/discovery_test.go` +- `core/frontend/iscsi/scsi_test.go` +- `core/frontend/iscsi/scsi_batch10_5_test.go` +- `core/frontend/iscsi/t2_route_iscsi_test.go` + +### Recent OS-initiator compatibility fixes + +V3 now has focused P1 coverage for the bug class that blocked the demo: + +- Large WRITE R2T path. +- Data-Out collector checks DataSN, BufferOffset, TTT, overflow, premature final. +- Bounded pending queue while collecting Data-Out. +- Data-Out timeout. +- Large READ split into bounded Data-In PDUs. +- Residual count plus underflow/overflow direction flags. + +Representative V3 tests: + +- `core/frontend/iscsi/t2_large_write_test.go` +- `core/frontend/iscsi/dataout_test.go` +- `core/frontend/iscsi/p1_os_initiator_test.go` +- `core/frontend/iscsi/p1_large_read_test.go` +- `core/frontend/iscsi/datain_test.go` + +## High-Value Gaps From V2 + +### Gap 1: iSCSI RX/TX session stress + +V2 has a dedicated `qa_rxtx_test.go` suite covering: + +- Response-channel backpressure. +- Double session close. +- Tx-loop goroutine leak. +- 50 concurrent sessions. +- SCSI command during Data-Out. +- NOP-Out during Data-Out and response ordering. +- StatSN monotonicity and error-response StatSN. +- Target close while I/O is active. +- New session after target close. + +V3 has partial coverage: + +- SCSI command during Data-Out is covered in `TestP1_ISCSI_R2TDataOut_AllowsPipelinedCommand`. +- Pending queue bounded is covered. +- Data-Out timeout is covered. + +V3 still lacks a compact RX/TX stress pack: + +- 50 concurrent sessions. +- target close during active I/O. +- double close no panic. +- StatSN after error response. +- NOP-Out pending ordering. +- goroutine leak budget across many connect/login/logout cycles. + +Priority: **P2 high**. These are low-cost in-process tests and can catch correctness regressions before hardware. + +### Gap 2: large-write memory pressure and slow backend + +V2 has `large_write_mem_test.go`: + +- `TestLargeWriteMemory_4MB`: 10 x 4 MiB writes through a real iSCSI session and heap growth check. +- `TestLargeWriteMemory_SlowDevice`: slow `WriteAt` simulates WAL/admission pressure and checks buffers do not accumulate. + +V3 has large WRITE protocol tests but not an equivalent memory/slow-backend guard. + +Priority: **P2 high**. This directly matches the demo failure class. Add a V3 test with a fake backend that sleeps and tracks heap/goroutines. + +### Gap 3: product-backed iSCSI stability + +V2 `qa_stability_test.go` covers iSCSI over a real block volume: + +- sustained 1000 writes. +- write/read under WAL pressure. +- SYNC CACHE under pressure. +- multiple sessions sharing one volume. +- crash recovery via iSCSI. +- session reconnect. +- rapid open/close target. +- extreme valid config values. + +V3 has product-level K8s/CSI smoke and blockvolume L2 tests, but not this exact "frontend over durable backend under pressure" pack. + +Priority: **P2/P3 medium-high**. This should be adapted to V3 durable backend semantics, not copied mechanically from V2. + +### Gap 4: CHAP + +V2 has `auth_test.go` and `qa_chap_test.go`: + +- CHAP config validation. +- challenge/response state machine. +- wrong username/password. +- replayed challenge rejected. +- login integration with missing CHAP_N / CHAP_R. + +V3 does not implement CHAP. + +Priority: **iSCSI-P4**, not P2. Security is product-important but should not block basic single-path protocol correctness. + +### Gap 5: ALUA / MPIO foundation + +V2 has `alua.go` and `qa_alua_test.go`: + +- standby metadata commands allowed. +- unavailable/transitioning reject writes. +- active allows all ops. +- state change mid-stream fences the next write. +- VPD 0x83 / REPORT TARGET PORT GROUPS. +- concurrent state reads and standby reject. + +V3 does not implement ALUA. + +Priority: **iSCSI-P6**. This belongs after the HA/frontend fact model is stable. Do not mix it into P2. + +### Gap 6: CSI node lifecycle hardening + +V2 CSI tests are much broader than V3: + +- NodeStage/NodeUnstage idempotency. +- login failure cleanup. +- mkfs failure cleanup. +- unstage retry preserves staged entry. +- restart fallback using transport files. +- expand behavior. +- wrong volume at staging path. +- concurrent stage/unstage. +- NVMe vs iSCSI transport stickiness. + +V3 has the alpha K8s dynamic PVC path and some controller/node basics, but not the full adversarial node lifecycle matrix. + +Priority: **K8s/CSI-P2**, separate from iSCSI-P2. These tests matter before public alpha hardening. + +### Gap 7: NVMe QA breadth + +V2 NVMe has extensive coverage: + +- wire truncation and malformed PDUs. +- connect sequencing. +- admin / IO queue separation. +- large read chunking. +- ANA behavior. +- concurrent IO. +- reconnect/disconnect loops. +- buffer pool safety. +- WAL pressure classification. + +V3 NVMe has a solid initial port but less breadth. + +Priority: **NVMe-P2+**. Do not block iSCSI-P2, but use the same audit method before claiming NVMe product readiness. + +## First V3 Tests To Add Before More Product Code + +### Test Slice A: iSCSI RX/TX session stability pack + +Add a V3 test file, likely: + +- `core/frontend/iscsi/p2_rxtx_stability_test.go` + +Initial tests: + +- `TestP2_ISCSI_RapidLoginLogout_NoGoroutineLeak` +- `TestP2_ISCSI_ConcurrentSessions50_WriteRead` +- `TestP2_ISCSI_TargetCloseDuringActiveIO_ExitsCleanly` +- `TestP2_ISCSI_NopDuringDataOut_DrainsAfterWrite` +- `TestP2_ISCSI_ErrorResponseAdvancesStatSN` + +Rationale: this is cheap, local, and directly protects the new pending-queue/Data-Out/Data-In state machine. + +### Test Slice B: large write memory / slow backend + +Add: + +- `TestP2_ISCSI_LargeWrite4MiB_DoesNotGrowHeapUnbounded` +- `TestP2_ISCSI_LargeWrite_SlowBackend_DoesNotAccumulateBuffers` + +Keep thresholds loose enough for CI, but strict enough to catch unbounded buffering. + +Rationale: this would likely have exposed the original large WRITE issue before the Windows/Linux demo attempt. + +### Test Slice C: real OS initiator harness + +Add a harness, not necessarily a normal Go unit test: + +```text +Linux iscsiadm -> 256MiB/1GiB target -> mkfs.ext4 -> mount -> fio/dd read/write -> sha256 verify -> logout -> no sessions +``` + +Rationale: in-process clients do not perfectly model Linux kernel iSCSI behavior. P1 already proved this. + +## What Not To Do Now + +- Do not port V2 CHAP/ALUA into P2. +- Do not claim MPIO or mounted failover. +- Do not copy V2 blockvol internals into V3 storage/authority layers. +- Do not expand K8s operator cleanup while iSCSI single-path filesystem stability is still under verification. + +## Recommended Order + +1. Add Test Slice A: RX/TX session stability pack. +2. Add Test Slice B: large-write memory / slow backend. +3. Add Test Slice C: real OS initiator harness and run on M02. +4. Only then raise K8s alpha PVC size from toy/smoke scale to 256MiB/1GiB. +5. Track CHAP as iSCSI-P4, ALUA/MPIO as iSCSI-P6. + +## Decision + +Proceed with **tests first** on `iscsi-p2/os-initiator-stability`. + +The next implementation PR should not be a protocol refactor unless one of the P2 tests turns red and points to a concrete state-machine gap. From b3b585c18ed21b89775a2c5f58753259b1231dd8 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 3 May 2026 23:26:25 -0700 Subject: [PATCH 02/11] frontend: add iSCSI RXTX stability tests --- .../frontend/iscsi/p2_rxtx_stability_test.go | 180 ++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 seaweed-block/core/frontend/iscsi/p2_rxtx_stability_test.go diff --git a/seaweed-block/core/frontend/iscsi/p2_rxtx_stability_test.go b/seaweed-block/core/frontend/iscsi/p2_rxtx_stability_test.go new file mode 100644 index 0000000000..7a6abdd901 --- /dev/null +++ b/seaweed-block/core/frontend/iscsi/p2_rxtx_stability_test.go @@ -0,0 +1,180 @@ +package iscsi_test + +import ( + "bytes" + "encoding/binary" + "fmt" + "io" + "log" + "sync" + "testing" + "time" + + "github.com/seaweedfs/seaweed-block/core/frontend" + "github.com/seaweedfs/seaweed-block/core/frontend/iscsi" + "github.com/seaweedfs/seaweed-block/core/frontend/testback" +) + +func startP2Target(t *testing.T) (*iscsi.Target, string, *testback.RecordingBackend) { + t.Helper() + rec := testback.NewRecordingBackend(frontend.Identity{VolumeID: "v1", ReplicaID: "r1"}) + tg := iscsi.NewTarget(iscsi.TargetConfig{ + Listen: "127.0.0.1:0", + IQN: "iqn.2026-04.example.v3:v1", + VolumeID: "v1", + Provider: testback.NewStaticProvider(rec), + Logger: log.New(io.Discard, "", 0), + }) + addr, err := tg.Start() + if err != nil { + t.Fatalf("target Start: %v", err) + } + return tg, addr, rec +} + +func TestP2_ISCSI_ConcurrentSessions50_WriteRead(t *testing.T) { + tg, addr, _ := startP2Target(t) + defer tg.Close() + + const sessions = 50 + errs := make(chan error, sessions) + var wg sync.WaitGroup + for i := 0; i < sessions; i++ { + wg.Add(1) + go func(id int) { + defer wg.Done() + cli := dialAndLogin(t, addr) + defer cli.logout(t) + + payload := bytes.Repeat([]byte{byte(id)}, int(iscsi.DefaultBlockSize)) + status, _ := cli.scsiCmd(t, writeCDB10(uint32(id), 1), payload, 0) + if status != iscsi.StatusGood { + errs <- fmt.Errorf("session %d write status=0x%02x", id, status) + return + } + status, got := cli.scsiCmd(t, readCDB10(uint32(id), 1), nil, int(iscsi.DefaultBlockSize)) + if status != iscsi.StatusGood { + errs <- fmt.Errorf("session %d read status=0x%02x", id, status) + return + } + if !bytes.Equal(got, payload) { + errs <- fmt.Errorf("session %d read payload mismatch", id) + } + }(i) + } + + wg.Wait() + close(errs) + for err := range errs { + t.Error(err) + } +} + +func TestP2_ISCSI_TargetCloseWithActiveSessions_ExitsCleanly(t *testing.T) { + tg, addr, _ := startP2Target(t) + + const sessions = 8 + clients := make([]*testClient, 0, sessions) + for i := 0; i < sessions; i++ { + clients = append(clients, dialAndLogin(t, addr)) + } + + closed := make(chan error, 1) + go func() { closed <- tg.Close() }() + select { + case err := <-closed: + if err != nil { + t.Fatalf("target Close: %v", err) + } + case <-time.After(3 * time.Second): + t.Fatal("target Close timed out with active sessions") + } + + for i, cli := range clients { + _ = cli.conn.SetReadDeadline(time.Now().Add(100 * time.Millisecond)) + if _, err := iscsi.ReadPDU(cli.conn); err == nil { + t.Fatalf("client %d: expected read error after target Close", i) + } + _ = cli.conn.Close() + } +} + +func TestP2_ISCSI_ErrorResponseAdvancesStatSN(t *testing.T) { + tg, addr, _ := startP2Target(t) + defer tg.Close() + + cli := dialAndLogin(t, addr) + defer cli.logout(t) + + nop := &iscsi.PDU{} + nop.SetOpcode(iscsi.OpNOPOut) + nop.SetOpSpecific1(iscsi.FlagF) + nop.SetImmediate(true) + nop.SetInitiatorTaskTag(cli.itt) + cli.itt++ + nop.SetCmdSN(cli.cmdSN) + cli.cmdSN++ + if err := iscsi.WritePDU(cli.conn, nop); err != nil { + t.Fatalf("write initial NOP-Out: %v", err) + } + nopResp, err := iscsi.ReadPDU(cli.conn) + if err != nil { + t.Fatalf("read initial NOP-In: %v", err) + } + if nopResp.Opcode() != iscsi.OpNOPIn { + t.Fatalf("initial response opcode=%s want NOP-In", iscsi.OpcodeName(nopResp.Opcode())) + } + baseSN := nopResp.StatSN() + + read := &iscsi.PDU{} + read.SetOpcode(iscsi.OpSCSICmd) + read.SetOpSpecific1(iscsi.FlagF | iscsi.FlagR) + read.SetLUN(0) + read.SetInitiatorTaskTag(cli.itt) + cli.itt++ + read.SetExpectedDataTransferLength(uint32(iscsi.DefaultBlockSize)) + read.SetCmdSN(cli.cmdSN) + cli.cmdSN++ + read.SetExpStatSN(baseSN + 1) + var cdb [16]byte + cdb[0] = iscsi.ScsiRead10 + binary.BigEndian.PutUint32(cdb[2:6], 0xFFFFFFF0) + binary.BigEndian.PutUint16(cdb[7:9], 1) + read.SetCDB(cdb) + if err := iscsi.WritePDU(cli.conn, read); err != nil { + t.Fatalf("write out-of-range READ: %v", err) + } + errResp, err := iscsi.ReadPDU(cli.conn) + if err != nil { + t.Fatalf("read error response: %v", err) + } + if errResp.Opcode() != iscsi.OpSCSIResp { + t.Fatalf("error response opcode=%s want SCSIResp", iscsi.OpcodeName(errResp.Opcode())) + } + if errResp.SCSIStatusByte() != iscsi.StatusCheckCondition { + t.Fatalf("error response status=0x%02x want CheckCondition", errResp.SCSIStatusByte()) + } + if errResp.StatSN() != baseSN+1 { + t.Fatalf("error StatSN=%d want %d", errResp.StatSN(), baseSN+1) + } + + nop2 := &iscsi.PDU{} + nop2.SetOpcode(iscsi.OpNOPOut) + nop2.SetOpSpecific1(iscsi.FlagF) + nop2.SetImmediate(true) + nop2.SetInitiatorTaskTag(cli.itt) + cli.itt++ + nop2.SetCmdSN(cli.cmdSN) + cli.cmdSN++ + nop2.SetExpStatSN(baseSN + 2) + if err := iscsi.WritePDU(cli.conn, nop2); err != nil { + t.Fatalf("write second NOP-Out: %v", err) + } + nop2Resp, err := iscsi.ReadPDU(cli.conn) + if err != nil { + t.Fatalf("read second NOP-In: %v", err) + } + if nop2Resp.StatSN() != baseSN+2 { + t.Fatalf("post-error NOP StatSN=%d want %d", nop2Resp.StatSN(), baseSN+2) + } +} From 603899925461d73c603fbc49b3bf349604a98065 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 3 May 2026 23:33:38 -0700 Subject: [PATCH 03/11] frontend: add iSCSI large write memory tests --- .../iscsi/p2_large_write_memory_test.go | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 seaweed-block/core/frontend/iscsi/p2_large_write_memory_test.go diff --git a/seaweed-block/core/frontend/iscsi/p2_large_write_memory_test.go b/seaweed-block/core/frontend/iscsi/p2_large_write_memory_test.go new file mode 100644 index 0000000000..4ace423703 --- /dev/null +++ b/seaweed-block/core/frontend/iscsi/p2_large_write_memory_test.go @@ -0,0 +1,162 @@ +package iscsi_test + +import ( + "context" + "io" + "log" + "runtime" + "sync/atomic" + "testing" + "time" + + "github.com/seaweedfs/seaweed-block/core/frontend" + "github.com/seaweedfs/seaweed-block/core/frontend/iscsi" + "github.com/seaweedfs/seaweed-block/core/frontend/testback" +) + +type slowP2Backend struct { + inner *testback.RecordingBackend + writeDelay time.Duration + writeCalls atomic.Int64 +} + +func (b *slowP2Backend) Identity() frontend.Identity { return b.inner.Identity() } +func (b *slowP2Backend) Close() error { return b.inner.Close() } +func (b *slowP2Backend) SetOperational(ok bool, evidence string) { + b.inner.SetOperational(ok, evidence) +} +func (b *slowP2Backend) Sync(ctx context.Context) error { return b.inner.Sync(ctx) } +func (b *slowP2Backend) Read(ctx context.Context, offset int64, p []byte) (int, error) { + return b.inner.Read(ctx, offset, p) +} +func (b *slowP2Backend) Write(ctx context.Context, offset int64, p []byte) (int, error) { + b.writeCalls.Add(1) + if b.writeDelay > 0 { + time.Sleep(b.writeDelay) + } + return b.inner.Write(ctx, offset, p) +} + +func startP2MemoryTarget(t *testing.T, backend frontend.Backend, volumeSize uint64, maxBurst int) (*iscsi.Target, string) { + t.Helper() + neg := iscsi.DefaultNegotiableConfig() + neg.MaxBurstLength = maxBurst + neg.FirstBurstLength = maxBurst + tg := iscsi.NewTarget(iscsi.TargetConfig{ + Listen: "127.0.0.1:0", + IQN: "iqn.2026-04.example.v3:v1", + VolumeID: "v1", + Provider: testback.NewStaticProvider(backend), + Handler: iscsi.HandlerConfig{VolumeSize: volumeSize}, + Negotiation: neg, + Logger: log.New(io.Discard, "", 0), + }) + addr, err := tg.Start() + if err != nil { + t.Fatalf("target Start: %v", err) + } + return tg, addr +} + +func currentHeapAlloc() uint64 { + runtime.GC() + var m runtime.MemStats + runtime.ReadMemStats(&m) + return m.HeapAlloc +} + +// TestP2_ISCSI_LargeWrite4MiB_DoesNotGrowHeapUnbounded ports the useful +// part of V2's large-write memory guard to the V3 target. It exercises real +// R2T chunking with several filesystem-sized writes, then checks that the +// target is not retaining one assembled payload per completed command. +func TestP2_ISCSI_LargeWrite4MiB_DoesNotGrowHeapUnbounded(t *testing.T) { + const ( + writeBytes = 4 * 1024 * 1024 + blocks = writeBytes / int(iscsi.DefaultBlockSize) + writes = 5 + maxBurst = 256 * 1024 + ) + + rec := testback.NewRecordingBackend(frontend.Identity{VolumeID: "v1", ReplicaID: "r1"}) + tg, addr := startP2MemoryTarget(t, rec, writeBytes*writes, maxBurst) + defer tg.Close() + + cli := dialAndLogin(t, addr) + defer cli.logout(t) + + payload := make([]byte, writeBytes) + for i := range payload { + payload[i] = byte((i * 31) % 251) + } + + before := currentHeapAlloc() + for i := 0; i < writes; i++ { + lba := uint32(i * blocks) + status, _, traces := cli.scsiCmdFullWithR2TTrace(t, writeCDB10(lba, uint16(blocks)), nil, payload, 0) + expectGood(t, status, "4MiB WRITE(10)") + if len(traces) < 2 { + t.Fatalf("write %d: R2T count=%d want multiple chunks", i, len(traces)) + } + for j, tr := range traces { + if tr.Desired > maxBurst { + t.Fatalf("write %d R2T[%d] DesiredDataLength=%d exceeds MaxBurst=%d", i, j, tr.Desired, maxBurst) + } + } + } + after := currentHeapAlloc() + deltaMB := int64(after-before) / (1024 * 1024) + t.Logf("%d x 4MiB WRITE(10): heap delta=%d MB writes=%d", writes, deltaMB, rec.WriteCount()) + + if rec.WriteCount() != writes { + t.Fatalf("backend WriteCount=%d want %d", rec.WriteCount(), writes) + } + if deltaMB > 160 { + t.Fatalf("heap grew %d MB after %d x 4MiB iSCSI writes; likely retained Data-Out buffers", deltaMB, writes) + } +} + +// TestP2_ISCSI_LargeWrite_SlowBackend_DoesNotAccumulateBuffers simulates a +// backend that blocks briefly on each write, like a WAL admission or disk +// flush stall. Completed commands should release their R2T/Data-Out buffers +// even when backend writes are slower than the initiator's command loop. +func TestP2_ISCSI_LargeWrite_SlowBackend_DoesNotAccumulateBuffers(t *testing.T) { + const ( + writeBytes = 1 * 1024 * 1024 + blocks = writeBytes / int(iscsi.DefaultBlockSize) + writes = 8 + maxBurst = 128 * 1024 + ) + + rec := testback.NewRecordingBackend(frontend.Identity{VolumeID: "v1", ReplicaID: "r1"}) + slow := &slowP2Backend{inner: rec, writeDelay: 25 * time.Millisecond} + tg, addr := startP2MemoryTarget(t, slow, writeBytes*writes, maxBurst) + defer tg.Close() + + cli := dialAndLogin(t, addr) + defer cli.logout(t) + + payload := make([]byte, writeBytes) + for i := range payload { + payload[i] = byte((i * 17) % 251) + } + + before := currentHeapAlloc() + for i := 0; i < writes; i++ { + lba := uint32(i * blocks) + status, _, traces := cli.scsiCmdFullWithR2TTrace(t, writeCDB10(lba, uint16(blocks)), nil, payload, 0) + expectGood(t, status, "slow-backend WRITE(10)") + if len(traces) < 2 { + t.Fatalf("write %d: R2T count=%d want multiple chunks", i, len(traces)) + } + } + after := currentHeapAlloc() + deltaMB := int64(after-before) / (1024 * 1024) + t.Logf("%d x 1MiB slow WRITE(10): heap delta=%d MB writes=%d", writes, deltaMB, slow.writeCalls.Load()) + + if slow.writeCalls.Load() != writes { + t.Fatalf("backend writeCalls=%d want %d", slow.writeCalls.Load(), writes) + } + if deltaMB > 96 { + t.Fatalf("heap grew %d MB with slow backend; likely accumulating completed Data-Out buffers", deltaMB) + } +} From 4523835a92643e67af76e858f7da803d34294095 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 3 May 2026 23:35:39 -0700 Subject: [PATCH 04/11] scripts: add iSCSI OS smoke harness --- .../docs/iscsi-os-initiator-compat-plan.md | 8 +- seaweed-block/scripts/overview.md | 1 + seaweed-block/scripts/run-iscsi-os-smoke.sh | 169 ++++++++++++++++++ 3 files changed, 175 insertions(+), 3 deletions(-) create mode 100755 seaweed-block/scripts/run-iscsi-os-smoke.sh diff --git a/seaweed-block/internal/docs/iscsi-os-initiator-compat-plan.md b/seaweed-block/internal/docs/iscsi-os-initiator-compat-plan.md index 25549d986b..71197ff35f 100644 --- a/seaweed-block/internal/docs/iscsi-os-initiator-compat-plan.md +++ b/seaweed-block/internal/docs/iscsi-os-initiator-compat-plan.md @@ -288,11 +288,13 @@ Harness note: ```text V:\share\iscsi-p1\run-p1-iscsi-os.sh +scripts/run-iscsi-os-smoke.sh ``` -This is a share-driven QA harness, not a repository script yet. It starts a -single-slot blockmaster/blockvolume pair with a 256 MiB durable target, then -drives Linux `iscsiadm`, `mkfs.ext4`, mount, payload checksum, and cleanup. +The share-driven harness captured the original P1 evidence. The repository +script is the repeatable developer/QA entrypoint. Both start a single-slot +blockmaster/blockvolume pair with a 256 MiB durable target, then drive Linux +`iscsiadm`, `mkfs.ext4`, mount, payload checksum, and cleanup. ### Slice F: Large READ / DataInWriter diff --git a/seaweed-block/scripts/overview.md b/seaweed-block/scripts/overview.md index b39ea899dc..c2009488ef 100644 --- a/seaweed-block/scripts/overview.md +++ b/seaweed-block/scripts/overview.md @@ -9,6 +9,7 @@ This directory contains developer and QA helper scripts. | `run-k8s-alpha.sh` | Public alpha smoke wrapper. Prefer this in README/user docs. | | `build-alpha-images.sh` | Builds local Docker images used by the Kubernetes alpha harness. | | `run-alpha-k8s-dynamic.sh` | Public dynamic PVC alpha smoke entry. | +| `run-iscsi-os-smoke.sh` | Privileged Linux OS-initiator smoke: `iscsiadm` -> `mkfs.ext4` -> mount -> checksum -> logout on a 256 MiB target. | | `build-g15b-images.sh` | Compatibility wrapper for older QA scripts. | | `run-g15b-k8s-static.sh` | Historical static PV Kubernetes harness. | | `run-g15d-k8s-dynamic.sh` | Historical dynamic PVC harness used by compatibility scenarios. | diff --git a/seaweed-block/scripts/run-iscsi-os-smoke.sh b/seaweed-block/scripts/run-iscsi-os-smoke.sh new file mode 100755 index 0000000000..f8a69faf6a --- /dev/null +++ b/seaweed-block/scripts/run-iscsi-os-smoke.sh @@ -0,0 +1,169 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="${1:-$(pwd)}" +RUN_ID="${RUN_ID:-$(date -u +%Y%m%dT%H%M%SZ)}" +WORK_DIR="${SW_BLOCK_ISCSI_WORK_DIR:-/tmp/sw-block-iscsi-os}" +ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${WORK_DIR}/runs/${RUN_ID}}" +IQN="${SW_BLOCK_ISCSI_IQN:-iqn.2026-05.io.seaweedfs:os-smoke-v1}" +PORT="${SW_BLOCK_ISCSI_PORT:-3267}" +MOUNT_DIR="${SW_BLOCK_ISCSI_MOUNT_DIR:-${WORK_DIR}/mnt}" +MASTER_ADDR="${SW_BLOCK_MASTER_ADDR:-127.0.0.1:19333}" +DATA_ADDR="${SW_BLOCK_DATA_ADDR:-127.0.0.1:19101}" +CTRL_ADDR="${SW_BLOCK_CTRL_ADDR:-127.0.0.1:19102}" +STATUS_ADDR="${SW_BLOCK_STATUS_ADDR:-127.0.0.1:19103}" +BLOCKS="${SW_BLOCK_DURABLE_BLOCKS:-65536}" # 256 MiB at 4 KiB. +BLOCK_SIZE="${SW_BLOCK_DURABLE_BLOCKSIZE:-4096}" + +BIN_DIR="${WORK_DIR}/bin" +RUN_DIR="${WORK_DIR}/run" +DEVLINK_GLOB="/dev/disk/by-path/*ip-127.0.0.1:${PORT}-iscsi-${IQN}-lun-0" + +mkdir -p "$ARTIFACT_DIR" "$BIN_DIR" "$RUN_DIR" "$MOUNT_DIR" + +log() { + printf '[iscsi-os] %s\n' "$*" | tee -a "$ARTIFACT_DIR/run.log" +} + +require_cmd() { + if ! command -v "$1" >/dev/null 2>&1; then + echo "missing required command: $1" >&2 + exit 2 + fi +} + +cleanup() { + set +e + log "cleanup" + mountpoint -q "$MOUNT_DIR" && sudo umount "$MOUNT_DIR" >>"$ARTIFACT_DIR/cleanup.log" 2>&1 + sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --logout >>"$ARTIFACT_DIR/cleanup.log" 2>&1 || true + sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" -o delete >>"$ARTIFACT_DIR/cleanup.log" 2>&1 || true + pkill -TERM -f "${BIN_DIR}/blockvolume" >>"$ARTIFACT_DIR/cleanup.log" 2>&1 || true + pkill -TERM -f "${BIN_DIR}/blockmaster" >>"$ARTIFACT_DIR/cleanup.log" 2>&1 || true + sleep 1 + pkill -KILL -f "${BIN_DIR}/blockvolume" >>"$ARTIFACT_DIR/cleanup.log" 2>&1 || true + pkill -KILL -f "${BIN_DIR}/blockmaster" >>"$ARTIFACT_DIR/cleanup.log" 2>&1 || true + sudo iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.after.txt" 2>&1 || true +} +trap cleanup EXIT + +require_cmd go +require_cmd sudo +require_cmd iscsiadm +require_cmd mkfs.ext4 +require_cmd mount +require_cmd sha256sum + +log "run_id=$RUN_ID" +log "root=$ROOT" +log "artifact_dir=$ARTIFACT_DIR" +log "iqn=$IQN" +log "portal=127.0.0.1:${PORT}" +log "size_blocks=${BLOCKS} block_size=${BLOCK_SIZE}" + +cd "$ROOT" +git rev-parse --short HEAD >"$ARTIFACT_DIR/git-head.txt" 2>/dev/null || true + +log "build binaries" +go build -o "${BIN_DIR}/blockmaster" ./cmd/blockmaster +go build -o "${BIN_DIR}/blockvolume" ./cmd/blockvolume + +cat >"$ARTIFACT_DIR/topology.yaml" </dev/null 2>&1 || true +pkill -KILL -f "${BIN_DIR}/blockmaster" >/dev/null 2>&1 || true +sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --logout >/dev/null 2>&1 || true +sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" -o delete >/dev/null 2>&1 || true +sudo iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.before.txt" 2>&1 || true + +log "start blockmaster" +setsid -f "${BIN_DIR}/blockmaster" \ + --authority-store "${RUN_DIR}/master-store" \ + --listen "$MASTER_ADDR" \ + --topology "$ARTIFACT_DIR/topology.yaml" \ + --expected-slots-per-volume 1 \ + >"$ARTIFACT_DIR/blockmaster.log" 2>&1 +sleep 1 + +log "start blockvolume iSCSI target" +setsid -f "${BIN_DIR}/blockvolume" \ + --master "$MASTER_ADDR" \ + --server-id s1 \ + --volume-id v1 \ + --replica-id r1 \ + --data-addr "$DATA_ADDR" \ + --ctrl-addr "$CTRL_ADDR" \ + --status-addr "$STATUS_ADDR" \ + --heartbeat-interval 200ms \ + --t1-readiness \ + --durable-root "${RUN_DIR}/volume-store" \ + --durable-impl smartwal \ + --durable-blocks "$BLOCKS" \ + --durable-blocksize "$BLOCK_SIZE" \ + --iscsi-listen "127.0.0.1:${PORT}" \ + --iscsi-iqn "$IQN" \ + >"$ARTIFACT_DIR/blockvolume.log" 2>&1 + +log "wait iSCSI listener" +for _ in $(seq 1 100); do + if bash -c "/dev/null 2>&1; then + break + fi + sleep 0.1 +done +bash -c "/dev/null 2>&1 +sleep 2 + +log "iscsi discovery/login" +sudo iscsiadm -m discovery -t sendtargets -p "127.0.0.1:${PORT}" | tee "$ARTIFACT_DIR/discovery.log" +sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --login | tee "$ARTIFACT_DIR/login.log" + +log "wait kernel block device" +DEV="" +for _ in $(seq 1 100); do + DEV="$(ls $DEVLINK_GLOB 2>/dev/null | head -n1 || true)" + if [[ -n "$DEV" ]]; then + break + fi + sleep 0.1 +done +if [[ -z "$DEV" ]]; then + ls -l /dev/disk/by-path >"$ARTIFACT_DIR/by-path.txt" 2>&1 || true + dmesg | tail -n 120 >"$ARTIFACT_DIR/dmesg.tail.txt" 2>&1 || true + echo "device not found for IQN ${IQN}" >&2 + exit 1 +fi +REAL_DEV="$(readlink -f "$DEV")" +log "device=$DEV real=$REAL_DEV" +lsblk "$REAL_DEV" >"$ARTIFACT_DIR/lsblk.before.txt" 2>&1 || true + +log "mkfs.ext4" +sudo mkfs.ext4 -F "$REAL_DEV" >"$ARTIFACT_DIR/mkfs.log" 2>&1 + +log "mount/write/read" +sudo mount "$REAL_DEV" "$MOUNT_DIR" +sudo dd if=/dev/urandom of="$MOUNT_DIR/payload.bin" bs=4096 count=8 status=none +sync +sudo sha256sum "$MOUNT_DIR/payload.bin" | tee "$ARTIFACT_DIR/payload.sha256" +sudo sha256sum -c "$ARTIFACT_DIR/payload.sha256" | tee "$ARTIFACT_DIR/sha256-check.log" +sudo umount "$MOUNT_DIR" + +log "logout" +sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --logout | tee "$ARTIFACT_DIR/logout.log" +sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" -o delete >>"$ARTIFACT_DIR/logout.log" 2>&1 || true +sudo iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.final.txt" 2>&1 || true +if ! grep -q "No active sessions" "$ARTIFACT_DIR/iscsi-sessions.final.txt"; then + cat "$ARTIFACT_DIR/iscsi-sessions.final.txt" + exit 1 +fi + +log "PASS: iscsiadm mkfs mount write/read logout" +log "artifacts=$ARTIFACT_DIR" From 2e23507fa2192345bc2c810b6120b73701bfc095 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 3 May 2026 23:36:30 -0700 Subject: [PATCH 05/11] scripts: allow prebuilt iSCSI smoke binaries --- seaweed-block/scripts/run-iscsi-os-smoke.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/seaweed-block/scripts/run-iscsi-os-smoke.sh b/seaweed-block/scripts/run-iscsi-os-smoke.sh index f8a69faf6a..a6fb8f6d39 100755 --- a/seaweed-block/scripts/run-iscsi-os-smoke.sh +++ b/seaweed-block/scripts/run-iscsi-os-smoke.sh @@ -15,7 +15,7 @@ STATUS_ADDR="${SW_BLOCK_STATUS_ADDR:-127.0.0.1:19103}" BLOCKS="${SW_BLOCK_DURABLE_BLOCKS:-65536}" # 256 MiB at 4 KiB. BLOCK_SIZE="${SW_BLOCK_DURABLE_BLOCKSIZE:-4096}" -BIN_DIR="${WORK_DIR}/bin" +BIN_DIR="${SW_BLOCK_BIN_DIR:-${WORK_DIR}/bin}" RUN_DIR="${WORK_DIR}/run" DEVLINK_GLOB="/dev/disk/by-path/*ip-127.0.0.1:${PORT}-iscsi-${IQN}-lun-0" @@ -47,7 +47,6 @@ cleanup() { } trap cleanup EXIT -require_cmd go require_cmd sudo require_cmd iscsiadm require_cmd mkfs.ext4 @@ -64,9 +63,14 @@ log "size_blocks=${BLOCKS} block_size=${BLOCK_SIZE}" cd "$ROOT" git rev-parse --short HEAD >"$ARTIFACT_DIR/git-head.txt" 2>/dev/null || true -log "build binaries" -go build -o "${BIN_DIR}/blockmaster" ./cmd/blockmaster -go build -o "${BIN_DIR}/blockvolume" ./cmd/blockvolume +if [[ -x "${BIN_DIR}/blockmaster" && -x "${BIN_DIR}/blockvolume" ]]; then + log "use prebuilt binaries from ${BIN_DIR}" +else + require_cmd go + log "build binaries" + go build -o "${BIN_DIR}/blockmaster" ./cmd/blockmaster + go build -o "${BIN_DIR}/blockvolume" ./cmd/blockvolume +fi cat >"$ARTIFACT_DIR/topology.yaml" < Date: Sun, 3 May 2026 23:38:02 -0700 Subject: [PATCH 06/11] testops: register iSCSI OS smoke scenario --- .../internal/testops/registration_test.go | 39 +++++++++++++++ .../testops/registry/iscsi-p2-os-smoke.json | 49 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json diff --git a/seaweed-block/internal/testops/registration_test.go b/seaweed-block/internal/testops/registration_test.go index 3e9ab7c079..d64c703fdb 100644 --- a/seaweed-block/internal/testops/registration_test.go +++ b/seaweed-block/internal/testops/registration_test.go @@ -172,6 +172,45 @@ func TestG15eK8sDynamicCleanupRegistrationBuildsShellDriver(t *testing.T) { } } +func TestISCSIP2OSSmokeRegistrationBuildsShellDriver(t *testing.T) { + repoRoot := findRepoRoot(t) + raw, err := os.Open(registrationPath(repoRoot, "iscsi-p2-os-smoke.json")) + if err != nil { + t.Fatalf("open registration: %v", err) + } + defer raw.Close() + + registration, err := DecodeRegistration(raw) + if err != nil { + t.Fatalf("DecodeRegistration: %v", err) + } + if registration.Scenario != "iscsi-p2-os-smoke" || registration.Driver.Type != "shell" { + t.Fatalf("registration=%+v", registration) + } + if registration.KnownGreenCommit != "854d912" { + t.Fatalf("known_green_commit=%q want 854d912", registration.KnownGreenCommit) + } + driver, err := registration.NewDriver(repoRoot) + if err != nil { + t.Fatalf("NewDriver: %v", err) + } + shell, ok := driver.(ShellDriver) + if !ok { + t.Fatalf("driver type=%T want ShellDriver", driver) + } + if !filepath.IsAbs(shell.Path) || filepath.Base(shell.Path) != "run-iscsi-os-smoke.sh" { + t.Fatalf("shell path=%q", shell.Path) + } + if _, err := os.Stat(shell.Path); err != nil { + t.Fatalf("shell driver path missing: %v", err) + } + for _, want := range []string{"mkfs.log", "sha256-check.log", "iscsi-sessions.final.txt"} { + if !containsString(registration.Artifacts, want) { + t.Fatalf("registration artifacts missing %q: %v", want, registration.Artifacts) + } + } +} + func containsString(values []string, want string) bool { for _, value := range values { if value == want { diff --git a/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json b/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json new file mode 100644 index 0000000000..1523c4cdb8 --- /dev/null +++ b/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json @@ -0,0 +1,49 @@ +{ + "schema_version": "1.0", + "scenario": "iscsi-p2-os-smoke", + "gate": "iSCSI-P2", + "layer": "L3-privileged-host", + "driver": { + "type": "shell", + "path": "scripts/run-iscsi-os-smoke.sh" + }, + "default_timeout_s": 300, + "required_capabilities": [ + "bash", + "linux", + "sudo", + "iscsiadm", + "iscsi_tcp-loadable", + "mkfs.ext4", + "mount", + "sha256sum" + ], + "qa_instruction": "internal/docs/iscsi-os-initiator-compat-plan.md", + "known_green_commit": "854d912", + "artifacts": [ + "run.log", + "git-head.txt", + "topology.yaml", + "blockmaster.log", + "blockvolume.log", + "iscsi-sessions.before.txt", + "discovery.log", + "login.log", + "lsblk.before.txt", + "mkfs.log", + "payload.sha256", + "sha256-check.log", + "logout.log", + "iscsi-sessions.final.txt", + "iscsi-sessions.after.txt", + "cleanup.log" + ], + "non_claims": [ + "Single-host Linux initiator only.", + "Single replica and single iSCSI session only.", + "No CHAP, ALUA, MPIO, or mounted-volume failover claim.", + "No Windows initiator claim.", + "No performance, soak, or multi-client claim.", + "No Kubernetes CSI claim; K8s is covered by separate G15 scenarios." + ] +} From d2ab1b738c5dc129e000362eb07dd062178f67d7 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 3 May 2026 23:49:57 -0700 Subject: [PATCH 07/11] frontend: add iSCSI sustained sync smoke --- .../frontend/iscsi/p2_sustained_sync_test.go | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 seaweed-block/core/frontend/iscsi/p2_sustained_sync_test.go diff --git a/seaweed-block/core/frontend/iscsi/p2_sustained_sync_test.go b/seaweed-block/core/frontend/iscsi/p2_sustained_sync_test.go new file mode 100644 index 0000000000..5492f4a244 --- /dev/null +++ b/seaweed-block/core/frontend/iscsi/p2_sustained_sync_test.go @@ -0,0 +1,100 @@ +package iscsi_test + +import ( + "bytes" + "path/filepath" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend" + "github.com/seaweedfs/seaweed-block/core/frontend/durable" + "github.com/seaweedfs/seaweed-block/core/frontend/iscsi" + "github.com/seaweedfs/seaweed-block/core/storage/smartwal" +) + +type p2ProjectionView struct { + proj frontend.Projection +} + +func (v p2ProjectionView) Projection() frontend.Projection { return v.proj } + +// TestP2_ISCSI_SustainedWriteSyncCache_SurvivesSmartWALReopen pins the +// product-backed write/flush path that Linux filesystems depend on: +// WRITE(10) reaches durable.StorageBackend, SYNCHRONIZE CACHE reaches +// storage.Sync, and synced blocks survive a clean close/reopen. +func TestP2_ISCSI_SustainedWriteSyncCache_SurvivesSmartWALReopen(t *testing.T) { + const ( + blockSize = 4096 + numBlocks = 128 + scsiBlocksPerIO = uint16(blockSize / int(iscsi.DefaultBlockSize)) + writeCount = 48 + syncEvery = 8 + maxBurst = 128 * 1024 + frontendByteSize = numBlocks * blockSize + ) + + path := filepath.Join(t.TempDir(), "smartwal.bin") + store, err := smartwal.CreateStore(path, numBlocks, blockSize) + if err != nil { + t.Fatalf("smartwal.CreateStore: %v", err) + } + + id := frontend.Identity{VolumeID: "v1", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1} + view := p2ProjectionView{proj: frontend.Projection{ + VolumeID: id.VolumeID, + ReplicaID: id.ReplicaID, + Epoch: id.Epoch, + EndpointVersion: id.EndpointVersion, + Healthy: true, + }} + backend := durable.NewStorageBackend(store, view, id) + backend.SetOperational(true, "p2 sustained sync test") + + tg, addr := startP2MemoryTarget(t, backend, frontendByteSize, maxBurst) + cli := dialAndLogin(t, addr) + + expected := make(map[uint32][]byte, writeCount) + for i := 0; i < writeCount; i++ { + lba := uint32(i) + payload := bytes.Repeat([]byte{byte(i + 1)}, blockSize) + status, _, traces := cli.scsiCmdFullWithR2TTrace(t, writeCDB10(lba*uint32(scsiBlocksPerIO), scsiBlocksPerIO), nil, payload, 0) + expectGood(t, status, "sustained WRITE(10)") + if len(traces) == 0 { + t.Fatalf("write %d: expected R2T path for 4KiB payload", i) + } + expected[lba] = payload + + if (i+1)%syncEvery == 0 { + status, _ := cli.scsiCmd(t, syncCacheCDB10(), nil, 0) + expectGood(t, status, "SYNCHRONIZE CACHE(10)") + } + } + status, _ := cli.scsiCmd(t, syncCacheCDB10(), nil, 0) + expectGood(t, status, "final SYNCHRONIZE CACHE(10)") + + cli.logout(t) + if err := tg.Close(); err != nil { + t.Fatalf("target Close: %v", err) + } + if err := store.Close(); err != nil { + t.Fatalf("smartwal close: %v", err) + } + + reopened, err := smartwal.OpenStore(path) + if err != nil { + t.Fatalf("smartwal.OpenStore: %v", err) + } + defer reopened.Close() + if _, err := reopened.Recover(); err != nil { + t.Fatalf("smartwal Recover: %v", err) + } + + for _, lba := range []uint32{0, 7, 8, 23, 47} { + got, err := reopened.Read(lba) + if err != nil { + t.Fatalf("reopened Read lba=%d: %v", lba, err) + } + if !bytes.Equal(got, expected[lba]) { + t.Fatalf("reopened data mismatch at lba=%d", lba) + } + } +} From 226f9a3d8352a545575eb6472e1f834e2a8309ff Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 4 May 2026 00:01:24 -0700 Subject: [PATCH 08/11] scripts: loop iSCSI OS smoke iterations --- .../docs/iscsi-v2-coverage-gap-audit.md | 5 +- .../internal/testops/registration_test.go | 2 +- .../testops/registry/iscsi-p2-os-smoke.json | 15 +-- seaweed-block/scripts/run-iscsi-os-smoke.sh | 92 +++++++++++-------- 4 files changed, 66 insertions(+), 48 deletions(-) diff --git a/seaweed-block/internal/docs/iscsi-v2-coverage-gap-audit.md b/seaweed-block/internal/docs/iscsi-v2-coverage-gap-audit.md index d69c4b230a..3a8bac476d 100644 --- a/seaweed-block/internal/docs/iscsi-v2-coverage-gap-audit.md +++ b/seaweed-block/internal/docs/iscsi-v2-coverage-gap-audit.md @@ -244,7 +244,10 @@ Rationale: in-process clients do not perfectly model Linux kernel iSCSI behavior 1. Add Test Slice A: RX/TX session stability pack. 2. Add Test Slice B: large-write memory / slow backend. -3. Add Test Slice C: real OS initiator harness and run on M02. +3. Add Test Slice C: real OS initiator harness and run on M02. Keep the + default single-iteration path cheap, but support repeated + `SW_BLOCK_ISCSI_ITERATIONS=N` login/mkfs/mount/logout loops for session + reconnect stability. 4. Only then raise K8s alpha PVC size from toy/smoke scale to 256MiB/1GiB. 5. Track CHAP as iSCSI-P4, ALUA/MPIO as iSCSI-P6. diff --git a/seaweed-block/internal/testops/registration_test.go b/seaweed-block/internal/testops/registration_test.go index d64c703fdb..a49d87f894 100644 --- a/seaweed-block/internal/testops/registration_test.go +++ b/seaweed-block/internal/testops/registration_test.go @@ -204,7 +204,7 @@ func TestISCSIP2OSSmokeRegistrationBuildsShellDriver(t *testing.T) { if _, err := os.Stat(shell.Path); err != nil { t.Fatalf("shell driver path missing: %v", err) } - for _, want := range []string{"mkfs.log", "sha256-check.log", "iscsi-sessions.final.txt"} { + for _, want := range []string{"mkfs.iter1.log", "sha256-check.iter1.log", "iscsi-sessions.final.txt"} { if !containsString(registration.Artifacts, want) { t.Fatalf("registration artifacts missing %q: %v", want, registration.Artifacts) } diff --git a/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json b/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json index 1523c4cdb8..23944942a3 100644 --- a/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json +++ b/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json @@ -27,13 +27,14 @@ "blockmaster.log", "blockvolume.log", "iscsi-sessions.before.txt", - "discovery.log", - "login.log", - "lsblk.before.txt", - "mkfs.log", - "payload.sha256", - "sha256-check.log", - "logout.log", + "discovery.iter1.log", + "login.iter1.log", + "lsblk.iter1.txt", + "mkfs.iter1.log", + "payload.iter1.sha256", + "sha256-check.iter1.log", + "logout.iter1.log", + "iscsi-sessions.iter1.txt", "iscsi-sessions.final.txt", "iscsi-sessions.after.txt", "cleanup.log" diff --git a/seaweed-block/scripts/run-iscsi-os-smoke.sh b/seaweed-block/scripts/run-iscsi-os-smoke.sh index a6fb8f6d39..d797c6daf9 100755 --- a/seaweed-block/scripts/run-iscsi-os-smoke.sh +++ b/seaweed-block/scripts/run-iscsi-os-smoke.sh @@ -14,6 +14,7 @@ CTRL_ADDR="${SW_BLOCK_CTRL_ADDR:-127.0.0.1:19102}" STATUS_ADDR="${SW_BLOCK_STATUS_ADDR:-127.0.0.1:19103}" BLOCKS="${SW_BLOCK_DURABLE_BLOCKS:-65536}" # 256 MiB at 4 KiB. BLOCK_SIZE="${SW_BLOCK_DURABLE_BLOCKSIZE:-4096}" +ITERATIONS="${SW_BLOCK_ISCSI_ITERATIONS:-1}" BIN_DIR="${SW_BLOCK_BIN_DIR:-${WORK_DIR}/bin}" RUN_DIR="${WORK_DIR}/run" @@ -59,6 +60,7 @@ log "artifact_dir=$ARTIFACT_DIR" log "iqn=$IQN" log "portal=127.0.0.1:${PORT}" log "size_blocks=${BLOCKS} block_size=${BLOCK_SIZE}" +log "iterations=${ITERATIONS}" cd "$ROOT" git rev-parse --short HEAD >"$ARTIFACT_DIR/git-head.txt" 2>/dev/null || true @@ -126,48 +128,60 @@ done bash -c "/dev/null 2>&1 sleep 2 -log "iscsi discovery/login" -sudo iscsiadm -m discovery -t sendtargets -p "127.0.0.1:${PORT}" | tee "$ARTIFACT_DIR/discovery.log" -sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --login | tee "$ARTIFACT_DIR/login.log" +run_iteration() { + local iter="$1" + local suffix="iter${iter}" -log "wait kernel block device" -DEV="" -for _ in $(seq 1 100); do - DEV="$(ls $DEVLINK_GLOB 2>/dev/null | head -n1 || true)" - if [[ -n "$DEV" ]]; then - break + log "iteration ${iter}: iscsi discovery/login" + sudo iscsiadm -m discovery -t sendtargets -p "127.0.0.1:${PORT}" | tee "$ARTIFACT_DIR/discovery.${suffix}.log" + sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --login | tee "$ARTIFACT_DIR/login.${suffix}.log" + + log "iteration ${iter}: wait kernel block device" + local dev="" + for _ in $(seq 1 100); do + dev="$(ls $DEVLINK_GLOB 2>/dev/null | head -n1 || true)" + if [[ -n "$dev" ]]; then + break + fi + sleep 0.1 + done + if [[ -z "$dev" ]]; then + ls -l /dev/disk/by-path >"$ARTIFACT_DIR/by-path.${suffix}.txt" 2>&1 || true + dmesg | tail -n 120 >"$ARTIFACT_DIR/dmesg.${suffix}.tail.txt" 2>&1 || true + echo "device not found for IQN ${IQN} on iteration ${iter}" >&2 + exit 1 fi - sleep 0.1 + local real_dev + real_dev="$(readlink -f "$dev")" + log "iteration ${iter}: device=$dev real=$real_dev" + lsblk "$real_dev" >"$ARTIFACT_DIR/lsblk.${suffix}.txt" 2>&1 || true + + log "iteration ${iter}: mkfs.ext4" + sudo mkfs.ext4 -F "$real_dev" >"$ARTIFACT_DIR/mkfs.${suffix}.log" 2>&1 + + log "iteration ${iter}: mount/write/read" + sudo mount "$real_dev" "$MOUNT_DIR" + sudo dd if=/dev/urandom of="$MOUNT_DIR/payload.${suffix}.bin" bs=4096 count=8 status=none + sync + sudo sha256sum "$MOUNT_DIR/payload.${suffix}.bin" | tee "$ARTIFACT_DIR/payload.${suffix}.sha256" + sudo sha256sum -c "$ARTIFACT_DIR/payload.${suffix}.sha256" | tee "$ARTIFACT_DIR/sha256-check.${suffix}.log" + sudo umount "$MOUNT_DIR" + + log "iteration ${iter}: logout" + sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --logout | tee "$ARTIFACT_DIR/logout.${suffix}.log" + sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" -o delete >>"$ARTIFACT_DIR/logout.${suffix}.log" 2>&1 || true + sudo iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.${suffix}.txt" 2>&1 || true + if ! grep -q "No active sessions" "$ARTIFACT_DIR/iscsi-sessions.${suffix}.txt"; then + cat "$ARTIFACT_DIR/iscsi-sessions.${suffix}.txt" + exit 1 + fi +} + +for iter in $(seq 1 "$ITERATIONS"); do + run_iteration "$iter" done -if [[ -z "$DEV" ]]; then - ls -l /dev/disk/by-path >"$ARTIFACT_DIR/by-path.txt" 2>&1 || true - dmesg | tail -n 120 >"$ARTIFACT_DIR/dmesg.tail.txt" 2>&1 || true - echo "device not found for IQN ${IQN}" >&2 - exit 1 -fi -REAL_DEV="$(readlink -f "$DEV")" -log "device=$DEV real=$REAL_DEV" -lsblk "$REAL_DEV" >"$ARTIFACT_DIR/lsblk.before.txt" 2>&1 || true -log "mkfs.ext4" -sudo mkfs.ext4 -F "$REAL_DEV" >"$ARTIFACT_DIR/mkfs.log" 2>&1 +cp "$ARTIFACT_DIR/iscsi-sessions.iter${ITERATIONS}.txt" "$ARTIFACT_DIR/iscsi-sessions.final.txt" -log "mount/write/read" -sudo mount "$REAL_DEV" "$MOUNT_DIR" -sudo dd if=/dev/urandom of="$MOUNT_DIR/payload.bin" bs=4096 count=8 status=none -sync -sudo sha256sum "$MOUNT_DIR/payload.bin" | tee "$ARTIFACT_DIR/payload.sha256" -sudo sha256sum -c "$ARTIFACT_DIR/payload.sha256" | tee "$ARTIFACT_DIR/sha256-check.log" -sudo umount "$MOUNT_DIR" - -log "logout" -sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --logout | tee "$ARTIFACT_DIR/logout.log" -sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" -o delete >>"$ARTIFACT_DIR/logout.log" 2>&1 || true -sudo iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.final.txt" 2>&1 || true -if ! grep -q "No active sessions" "$ARTIFACT_DIR/iscsi-sessions.final.txt"; then - cat "$ARTIFACT_DIR/iscsi-sessions.final.txt" - exit 1 -fi - -log "PASS: iscsiadm mkfs mount write/read logout" +log "PASS: ${ITERATIONS} x iscsiadm mkfs mount write/read logout" log "artifacts=$ARTIFACT_DIR" From d9c4d0cd27f1480d44439faa564b0e340a315836 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 4 May 2026 00:04:44 -0700 Subject: [PATCH 09/11] testops: pin iSCSI smoke loop evidence --- seaweed-block/internal/testops/registration_test.go | 4 ++-- .../internal/testops/registry/iscsi-p2-os-smoke.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/seaweed-block/internal/testops/registration_test.go b/seaweed-block/internal/testops/registration_test.go index a49d87f894..a2a6fed603 100644 --- a/seaweed-block/internal/testops/registration_test.go +++ b/seaweed-block/internal/testops/registration_test.go @@ -187,8 +187,8 @@ func TestISCSIP2OSSmokeRegistrationBuildsShellDriver(t *testing.T) { if registration.Scenario != "iscsi-p2-os-smoke" || registration.Driver.Type != "shell" { t.Fatalf("registration=%+v", registration) } - if registration.KnownGreenCommit != "854d912" { - t.Fatalf("known_green_commit=%q want 854d912", registration.KnownGreenCommit) + if registration.KnownGreenCommit != "869292b" { + t.Fatalf("known_green_commit=%q want 869292b", registration.KnownGreenCommit) } driver, err := registration.NewDriver(repoRoot) if err != nil { diff --git a/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json b/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json index 23944942a3..0d0f526fe1 100644 --- a/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json +++ b/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json @@ -19,7 +19,7 @@ "sha256sum" ], "qa_instruction": "internal/docs/iscsi-os-initiator-compat-plan.md", - "known_green_commit": "854d912", + "known_green_commit": "869292b", "artifacts": [ "run.log", "git-head.txt", From ff62460805a5f884b3a15f13f8f47a1a1633f082 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 4 May 2026 00:13:43 -0700 Subject: [PATCH 10/11] scripts: add iSCSI OS stress mode --- .../docs/iscsi-v2-coverage-gap-audit.md | 3 +- .../internal/testops/registration_test.go | 2 +- .../testops/registry/iscsi-p2-os-smoke.json | 5 ++- seaweed-block/scripts/run-iscsi-os-smoke.sh | 39 +++++++++++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/seaweed-block/internal/docs/iscsi-v2-coverage-gap-audit.md b/seaweed-block/internal/docs/iscsi-v2-coverage-gap-audit.md index 3a8bac476d..aa933737bb 100644 --- a/seaweed-block/internal/docs/iscsi-v2-coverage-gap-audit.md +++ b/seaweed-block/internal/docs/iscsi-v2-coverage-gap-audit.md @@ -247,7 +247,8 @@ Rationale: in-process clients do not perfectly model Linux kernel iSCSI behavior 3. Add Test Slice C: real OS initiator harness and run on M02. Keep the default single-iteration path cheap, but support repeated `SW_BLOCK_ISCSI_ITERATIONS=N` login/mkfs/mount/logout loops for session - reconnect stability. + reconnect stability. Use `SW_BLOCK_ISCSI_STRESS=fio` or `dd` for sustained + filesystem write/read pressure once the basic loop is green. 4. Only then raise K8s alpha PVC size from toy/smoke scale to 256MiB/1GiB. 5. Track CHAP as iSCSI-P4, ALUA/MPIO as iSCSI-P6. diff --git a/seaweed-block/internal/testops/registration_test.go b/seaweed-block/internal/testops/registration_test.go index a2a6fed603..4f9157aca7 100644 --- a/seaweed-block/internal/testops/registration_test.go +++ b/seaweed-block/internal/testops/registration_test.go @@ -204,7 +204,7 @@ func TestISCSIP2OSSmokeRegistrationBuildsShellDriver(t *testing.T) { if _, err := os.Stat(shell.Path); err != nil { t.Fatalf("shell driver path missing: %v", err) } - for _, want := range []string{"mkfs.iter1.log", "sha256-check.iter1.log", "iscsi-sessions.final.txt"} { + for _, want := range []string{"mkfs.iter1.log", "sha256-check.iter1.log", "fio.iter1.log", "iscsi-sessions.final.txt"} { if !containsString(registration.Artifacts, want) { t.Fatalf("registration artifacts missing %q: %v", want, registration.Artifacts) } diff --git a/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json b/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json index 0d0f526fe1..298bbb1516 100644 --- a/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json +++ b/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json @@ -16,7 +16,8 @@ "iscsi_tcp-loadable", "mkfs.ext4", "mount", - "sha256sum" + "sha256sum", + "fio-optional" ], "qa_instruction": "internal/docs/iscsi-os-initiator-compat-plan.md", "known_green_commit": "869292b", @@ -33,6 +34,8 @@ "mkfs.iter1.log", "payload.iter1.sha256", "sha256-check.iter1.log", + "fio.iter1.log", + "dd.iter1.log", "logout.iter1.log", "iscsi-sessions.iter1.txt", "iscsi-sessions.final.txt", diff --git a/seaweed-block/scripts/run-iscsi-os-smoke.sh b/seaweed-block/scripts/run-iscsi-os-smoke.sh index d797c6daf9..7dbd48804c 100755 --- a/seaweed-block/scripts/run-iscsi-os-smoke.sh +++ b/seaweed-block/scripts/run-iscsi-os-smoke.sh @@ -15,6 +15,9 @@ STATUS_ADDR="${SW_BLOCK_STATUS_ADDR:-127.0.0.1:19103}" BLOCKS="${SW_BLOCK_DURABLE_BLOCKS:-65536}" # 256 MiB at 4 KiB. BLOCK_SIZE="${SW_BLOCK_DURABLE_BLOCKSIZE:-4096}" ITERATIONS="${SW_BLOCK_ISCSI_ITERATIONS:-1}" +STRESS="${SW_BLOCK_ISCSI_STRESS:-none}" # none | fio | dd +FIO_SIZE="${SW_BLOCK_ISCSI_FIO_SIZE:-32m}" +FIO_RUNTIME="${SW_BLOCK_ISCSI_FIO_RUNTIME:-10}" BIN_DIR="${SW_BLOCK_BIN_DIR:-${WORK_DIR}/bin}" RUN_DIR="${WORK_DIR}/run" @@ -53,6 +56,9 @@ require_cmd iscsiadm require_cmd mkfs.ext4 require_cmd mount require_cmd sha256sum +if [[ "$STRESS" == "fio" ]]; then + require_cmd fio +fi log "run_id=$RUN_ID" log "root=$ROOT" @@ -61,6 +67,7 @@ log "iqn=$IQN" log "portal=127.0.0.1:${PORT}" log "size_blocks=${BLOCKS} block_size=${BLOCK_SIZE}" log "iterations=${ITERATIONS}" +log "stress=${STRESS}" cd "$ROOT" git rev-parse --short HEAD >"$ARTIFACT_DIR/git-head.txt" 2>/dev/null || true @@ -165,6 +172,38 @@ run_iteration() { sync sudo sha256sum "$MOUNT_DIR/payload.${suffix}.bin" | tee "$ARTIFACT_DIR/payload.${suffix}.sha256" sudo sha256sum -c "$ARTIFACT_DIR/payload.${suffix}.sha256" | tee "$ARTIFACT_DIR/sha256-check.${suffix}.log" + + case "$STRESS" in + none) + ;; + fio) + log "iteration ${iter}: fio randrw stress" + sudo fio \ + --name="sw-block-${suffix}" \ + --directory="$MOUNT_DIR" \ + --filename="fio-${suffix}.dat" \ + --size="$FIO_SIZE" \ + --rw=randrw \ + --rwmixread=50 \ + --bs=4k \ + --ioengine=sync \ + --direct=0 \ + --fsync=1 \ + --runtime="$FIO_RUNTIME" \ + --time_based \ + --group_reporting \ + --output="$ARTIFACT_DIR/fio.${suffix}.log" + ;; + dd) + log "iteration ${iter}: dd sequential stress" + sudo dd if=/dev/urandom of="$MOUNT_DIR/dd-${suffix}.bin" bs=1M count=32 conv=fsync status=none 2>"$ARTIFACT_DIR/dd.${suffix}.log" + ;; + *) + echo "unsupported SW_BLOCK_ISCSI_STRESS=${STRESS} (want none, fio, or dd)" >&2 + exit 2 + ;; + esac + sudo umount "$MOUNT_DIR" log "iteration ${iter}: logout" From b4a9cf30716e381cda8af816b4292b483ddb43a1 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 4 May 2026 00:17:06 -0700 Subject: [PATCH 11/11] testops: pin iSCSI fio smoke evidence --- seaweed-block/internal/testops/registration_test.go | 4 ++-- .../internal/testops/registry/iscsi-p2-os-smoke.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/seaweed-block/internal/testops/registration_test.go b/seaweed-block/internal/testops/registration_test.go index 4f9157aca7..e4c1c1799e 100644 --- a/seaweed-block/internal/testops/registration_test.go +++ b/seaweed-block/internal/testops/registration_test.go @@ -187,8 +187,8 @@ func TestISCSIP2OSSmokeRegistrationBuildsShellDriver(t *testing.T) { if registration.Scenario != "iscsi-p2-os-smoke" || registration.Driver.Type != "shell" { t.Fatalf("registration=%+v", registration) } - if registration.KnownGreenCommit != "869292b" { - t.Fatalf("known_green_commit=%q want 869292b", registration.KnownGreenCommit) + if registration.KnownGreenCommit != "d25e7b4" { + t.Fatalf("known_green_commit=%q want d25e7b4", registration.KnownGreenCommit) } driver, err := registration.NewDriver(repoRoot) if err != nil { diff --git a/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json b/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json index 298bbb1516..d9c081493a 100644 --- a/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json +++ b/seaweed-block/internal/testops/registry/iscsi-p2-os-smoke.json @@ -20,7 +20,7 @@ "fio-optional" ], "qa_instruction": "internal/docs/iscsi-os-initiator-compat-plan.md", - "known_green_commit": "869292b", + "known_green_commit": "d25e7b4", "artifacts": [ "run.log", "git-head.txt",