mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
test(iscsi): add CHAP OS smoke path
This commit is contained in:
1 parent
f945188794
commit
9a42ad2957
4 files changed
+153
-7
No files matched your search
@@ -11,8 +11,9 @@ package iscsi
|
||||
// connection, but it now supports the OS-initiator essentials:
|
||||
// discovery, login, R2T/Data-Out chunking for large writes, bounded
|
||||
// pending commands during Data-Out, Data-Out timeout, and split
|
||||
// Data-In for large reads. It still does not implement CHAP, ALUA,
|
||||
// MPIO, or mounted-volume failover.
|
||||
// Data-In for large reads. Target-side CHAP login auth is implemented
|
||||
// in login.go. ALUA, MPIO, and mounted-volume failover are later
|
||||
// frontend milestones.
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
@@ -170,9 +170,8 @@ References:
|
||||
- flags require `--iscsi-listen`,
|
||||
- username and secret must be set together.
|
||||
- OS initiator CHAP smoke script:
|
||||
- status: next.
|
||||
- add `scripts/run-iscsi-chap-smoke.sh` or extend
|
||||
`scripts/run-iscsi-os-smoke.sh` behind an explicit env flag.
|
||||
- status: local implementation in `scripts/run-iscsi-os-smoke.sh`,
|
||||
pending QA.
|
||||
- configure `iscsiadm` node auth before login,
|
||||
- prove correct secret succeeds and wrong secret fails without residue.
|
||||
- Kubernetes / CSI Secret integration:
|
||||
@@ -187,7 +186,8 @@ References:
|
||||
- failed auth leaves no partial session/device state.
|
||||
|
||||
- QA/tooling:
|
||||
- #QA needs CHAP-capable initiator script once OS smoke lands.
|
||||
- #QA assignment:
|
||||
`internal/docs/qa-assignments/iscsi-p4-chap-lab-validation.md`.
|
||||
- V2 CHAP tests are the reference coverage inventory.
|
||||
|
||||
## Milestone: iSCSI-P5 CSI Node Lifecycle
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
# QA Assignment: iSCSI P4 CHAP Lab Validation
|
||||
|
||||
Status: ready for QA.
|
||||
Branch: `iscsi/frontend-completeness`.
|
||||
Scope: target-side CHAP login auth through the real Linux `iscsiadm`
|
||||
initiator. No Kubernetes Secret or CSI CHAP claim in this assignment.
|
||||
|
||||
## Preconditions
|
||||
|
||||
- Host: M02 or equivalent Linux host with `sudo`, `iscsiadm`, `mkfs.ext4`,
|
||||
`mount`, `sha256sum`, and optional `fio`.
|
||||
- Worktree: `C:\work\seaweed_block` branch `iscsi/frontend-completeness`,
|
||||
or archived copy of the same commit on the Linux host.
|
||||
- Lab must start clean:
|
||||
- `sudo iscsiadm -m session` reports no active sessions, or only unrelated
|
||||
sessions explicitly noted.
|
||||
- no stale `blockmaster` / `blockvolume` from prior runs.
|
||||
|
||||
## Test 1: Default Non-CHAP Regression
|
||||
|
||||
Command:
|
||||
|
||||
```bash
|
||||
RUN_ID="$(date -u +%Y%m%dT%H%M%SZ)-iscsi-p4-default" \
|
||||
SW_BLOCK_ISCSI_ITERATIONS=1 \
|
||||
SW_BLOCK_ISCSI_STRESS=dd \
|
||||
bash scripts/run-iscsi-os-smoke.sh "$PWD"
|
||||
```
|
||||
|
||||
Expected:
|
||||
|
||||
- final line contains:
|
||||
`[iscsi-os] PASS: 1 x iscsiadm mkfs mount write/read logout`
|
||||
- `iscsi-sessions.final.txt` reports no active sessions.
|
||||
- no `expected Data-Out` session errors in `blockvolume.log`.
|
||||
|
||||
## Test 2: CHAP Positive + Negative Login
|
||||
|
||||
Command:
|
||||
|
||||
```bash
|
||||
RUN_ID="$(date -u +%Y%m%dT%H%M%SZ)-iscsi-p4-chap" \
|
||||
SW_BLOCK_ISCSI_ITERATIONS=1 \
|
||||
SW_BLOCK_ISCSI_STRESS=dd \
|
||||
SW_BLOCK_ISCSI_CHAP_USERNAME=swchap \
|
||||
SW_BLOCK_ISCSI_CHAP_SECRET=swchap-secret \
|
||||
SW_BLOCK_ISCSI_CHAP_BAD_SECRET=wrong-secret \
|
||||
bash scripts/run-iscsi-os-smoke.sh "$PWD"
|
||||
```
|
||||
|
||||
Expected:
|
||||
|
||||
- run log includes `chap=enabled username=swchap`.
|
||||
- run log includes `verify wrong CHAP secret fails`.
|
||||
- `login-bad.iter1.log` exists and shows the wrong-secret login failed.
|
||||
- `iscsi-sessions.bad-auth.iter1.txt` does not show an established session
|
||||
for this IQN.
|
||||
- the following correct-secret login succeeds.
|
||||
- final line contains:
|
||||
`[iscsi-os] PASS: 1 x iscsiadm mkfs mount write/read logout`
|
||||
- `iscsi-sessions.final.txt` reports no active sessions.
|
||||
- no `expected Data-Out` session errors in `blockvolume.log`.
|
||||
|
||||
## Test 3: Optional CHAP fio
|
||||
|
||||
Run this only if Test 2 is green and the host has `fio`.
|
||||
|
||||
```bash
|
||||
RUN_ID="$(date -u +%Y%m%dT%H%M%SZ)-iscsi-p4-chap-fio" \
|
||||
SW_BLOCK_ISCSI_ITERATIONS=1 \
|
||||
SW_BLOCK_ISCSI_STRESS=fio \
|
||||
SW_BLOCK_ISCSI_FIO_RUNTIME=60 \
|
||||
SW_BLOCK_ISCSI_CHAP_USERNAME=swchap \
|
||||
SW_BLOCK_ISCSI_CHAP_SECRET=swchap-secret \
|
||||
SW_BLOCK_ISCSI_CHAP_BAD_SECRET=wrong-secret \
|
||||
bash scripts/run-iscsi-os-smoke.sh "$PWD"
|
||||
```
|
||||
|
||||
Expected:
|
||||
|
||||
- fio exits with `err=0`.
|
||||
- final line contains PASS.
|
||||
- no active sessions after cleanup.
|
||||
|
||||
## Report Format
|
||||
|
||||
QA should report:
|
||||
|
||||
- branch and commit SHA,
|
||||
- host and kernel,
|
||||
- exact commands,
|
||||
- result for each test,
|
||||
- artifact path for each run,
|
||||
- final PASS line,
|
||||
- `login-bad.iter1.log` result for Test 2,
|
||||
- `iscsi-sessions.final.txt`,
|
||||
- count of `expected Data-Out` in `blockvolume.log`,
|
||||
- any host setup changes, such as installing `open-iscsi` or `fio`.
|
||||
|
||||
## Non-Claims
|
||||
|
||||
- No Kubernetes Secret integration.
|
||||
- No CSI publish_context CHAP secret transport.
|
||||
- No CHAP mutual authentication.
|
||||
- No ALUA, MPIO, NVMe, or mounted failover claim.
|
||||
@@ -9,6 +9,9 @@ IQN="${SW_BLOCK_ISCSI_IQN:-iqn.2026-05.io.seaweedfs:os-smoke-v1}"
|
||||
PORT="${SW_BLOCK_ISCSI_PORT:-3267}"
|
||||
PORTAL_ADDR="${SW_BLOCK_ISCSI_PORTAL_ADDR:-}"
|
||||
DATAOUT_TIMEOUT="${SW_BLOCK_ISCSI_DATAOUT_TIMEOUT:-}"
|
||||
CHAP_USERNAME="${SW_BLOCK_ISCSI_CHAP_USERNAME:-}"
|
||||
CHAP_SECRET="${SW_BLOCK_ISCSI_CHAP_SECRET:-}"
|
||||
CHAP_BAD_SECRET="${SW_BLOCK_ISCSI_CHAP_BAD_SECRET:-}"
|
||||
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}"
|
||||
@@ -44,6 +47,7 @@ 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
|
||||
sudo iscsiadm -m discoverydb -t sendtargets -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
|
||||
@@ -73,6 +77,16 @@ fi
|
||||
if [[ -n "$DATAOUT_TIMEOUT" ]]; then
|
||||
log "dataout_timeout=$DATAOUT_TIMEOUT"
|
||||
fi
|
||||
if [[ -n "$CHAP_USERNAME" || -n "$CHAP_SECRET" ]]; then
|
||||
if [[ -z "$CHAP_USERNAME" || -z "$CHAP_SECRET" ]]; then
|
||||
echo "SW_BLOCK_ISCSI_CHAP_USERNAME and SW_BLOCK_ISCSI_CHAP_SECRET must be set together" >&2
|
||||
exit 2
|
||||
fi
|
||||
log "chap=enabled username=${CHAP_USERNAME}"
|
||||
if [[ -n "$CHAP_BAD_SECRET" ]]; then
|
||||
log "chap_negative_login=enabled"
|
||||
fi
|
||||
fi
|
||||
log "size_blocks=${BLOCKS} block_size=${BLOCK_SIZE}"
|
||||
log "iterations=${ITERATIONS}"
|
||||
log "stress=${STRESS}"
|
||||
@@ -103,6 +117,7 @@ pkill -KILL -f "${BIN_DIR}/blockvolume" >/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 discoverydb -t sendtargets -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"
|
||||
@@ -125,6 +140,10 @@ fi
|
||||
if [[ -n "$DATAOUT_TIMEOUT" ]]; then
|
||||
blockvolume_iscsi_args+=(--iscsi-dataout-timeout "$DATAOUT_TIMEOUT")
|
||||
fi
|
||||
if [[ -n "$CHAP_SECRET" ]]; then
|
||||
blockvolume_iscsi_args+=(--iscsi-chap-username "$CHAP_USERNAME")
|
||||
blockvolume_iscsi_args+=(--iscsi-chap-secret "$CHAP_SECRET")
|
||||
fi
|
||||
|
||||
setsid -f "${BIN_DIR}/blockvolume" \
|
||||
--master "$MASTER_ADDR" \
|
||||
@@ -157,7 +176,28 @@ run_iteration() {
|
||||
local suffix="iter${iter}"
|
||||
|
||||
log "iteration ${iter}: iscsi discovery/login"
|
||||
sudo iscsiadm -m discovery -t sendtargets -p "127.0.0.1:${PORT}" | tee "$ARTIFACT_DIR/discovery.${suffix}.log"
|
||||
if [[ -n "$CHAP_SECRET" ]]; then
|
||||
sudo iscsiadm -m discoverydb -t sendtargets -p "127.0.0.1:${PORT}" -o new >>"$ARTIFACT_DIR/discoverydb.${suffix}.log" 2>&1 || true
|
||||
sudo iscsiadm -m discoverydb -t sendtargets -p "127.0.0.1:${PORT}" --op=update -n discovery.sendtargets.auth.authmethod -v CHAP >>"$ARTIFACT_DIR/discoverydb.${suffix}.log" 2>&1
|
||||
sudo iscsiadm -m discoverydb -t sendtargets -p "127.0.0.1:${PORT}" --op=update -n discovery.sendtargets.auth.username -v "$CHAP_USERNAME" >>"$ARTIFACT_DIR/discoverydb.${suffix}.log" 2>&1
|
||||
sudo iscsiadm -m discoverydb -t sendtargets -p "127.0.0.1:${PORT}" --op=update -n discovery.sendtargets.auth.password -v "$CHAP_SECRET" >>"$ARTIFACT_DIR/discoverydb.${suffix}.log" 2>&1
|
||||
sudo iscsiadm -m discoverydb -t sendtargets -p "127.0.0.1:${PORT}" --discover | tee "$ARTIFACT_DIR/discovery.${suffix}.log"
|
||||
sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --op=update -n node.session.auth.authmethod -v CHAP >>"$ARTIFACT_DIR/node-auth.${suffix}.log" 2>&1
|
||||
sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --op=update -n node.session.auth.username -v "$CHAP_USERNAME" >>"$ARTIFACT_DIR/node-auth.${suffix}.log" 2>&1
|
||||
sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --op=update -n node.session.auth.password -v "$CHAP_SECRET" >>"$ARTIFACT_DIR/node-auth.${suffix}.log" 2>&1
|
||||
if [[ "$iter" == "1" && -n "$CHAP_BAD_SECRET" ]]; then
|
||||
log "iteration ${iter}: verify wrong CHAP secret fails"
|
||||
sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --op=update -n node.session.auth.password -v "$CHAP_BAD_SECRET" >>"$ARTIFACT_DIR/node-auth-bad.${suffix}.log" 2>&1
|
||||
if sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --login >"$ARTIFACT_DIR/login-bad.${suffix}.log" 2>&1; then
|
||||
echo "wrong CHAP secret unexpectedly logged in" >&2
|
||||
exit 1
|
||||
fi
|
||||
sudo iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.bad-auth.${suffix}.txt" 2>&1 || true
|
||||
sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --op=update -n node.session.auth.password -v "$CHAP_SECRET" >>"$ARTIFACT_DIR/node-auth.${suffix}.log" 2>&1
|
||||
fi
|
||||
else
|
||||
sudo iscsiadm -m discovery -t sendtargets -p "127.0.0.1:${PORT}" | tee "$ARTIFACT_DIR/discovery.${suffix}.log"
|
||||
fi
|
||||
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"
|
||||
|
||||
Reference in new issue
Block a user