test(k8s): add attach detach loop wrapper

This commit is contained in:
pingqiu committed 2026-05-04 22:25:30 -07:00
1 parent 45bc4b1a80
commit adc394b1bb
3 files changed
+53 -2

No files matched your search

+5 -2
View File
@@ -123,6 +123,7 @@ References:
- multiple sessions sharing a volume if supported,
- reconnect after logout/login,
- repeated attach/detach loop,
- script prepared: `scripts/run-k8s-attach-detach-loop.sh`,
- app writer pod replaced by reader pod on the same PVC,
- blockvolume restart and reattach once durable state is ready.
@@ -133,8 +134,10 @@ References:
- product logs are enough to diagnose failures.
- QA/tooling:
- prefer TestOps scenario for repeated attach/detach.
- if missing, prepare a script first and let QA run it on M02.
- repeated attach/detach script exists:
`scripts/run-k8s-attach-detach-loop.sh`.
- default loop count comes from `SW_BLOCK_ATTACH_DETACH_ITERATIONS`.
- QA should run it on M02 before P3 close and return the artifact dir.
## Milestone: iSCSI-P4 CHAP / Access Control
+1
View File
@@ -13,6 +13,7 @@ This directory contains developer and QA helper scripts.
| `run-k8s-demo-ghcr.sh` | Public app-demo wrapper using published GHCR alpha images. |
| `run-k8s-alpha.sh` | Public alpha smoke wrapper. Prefer this in README/user docs. |
| `run-k8s-alpha-large.sh` | Optional 256 MiB Kubernetes alpha smoke for larger iSCSI write coverage. |
| `run-k8s-attach-detach-loop.sh` | QA loop wrapper. Repeats the app PVC attach/write/read/delete flow and stores per-iteration artifacts. |
| `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-alpha-app-demo.sh` | App-demo implementation used by `run-k8s-demo.sh`. |
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="${1:-$(pwd)}"
ITERATIONS="${SW_BLOCK_ATTACH_DETACH_ITERATIONS:-3}"
RUN_ID="${RUN_ID:-$(date -u +%Y%m%dT%H%M%SZ)}"
BASE_ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-/tmp/sw-block-attach-detach-${RUN_ID}}"
SUMMARY="$BASE_ARTIFACT_DIR/summary.log"
mkdir -p "$BASE_ARTIFACT_DIR"
log() {
printf '[attach-loop] %s\n' "$*" | tee -a "$SUMMARY"
}
if [[ -z "${KUBECONFIG:-}" && -f /etc/rancher/k3s/k3s.yaml ]]; then
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
fi
log "root=$ROOT"
log "artifact_dir=$BASE_ARTIFACT_DIR"
log "iterations=$ITERATIONS"
log "launcher_pvc_owner_ref=${SW_BLOCK_LAUNCHER_PVC_OWNER_REF:-1}"
for iter in $(seq 1 "$ITERATIONS"); do
iter_dir="$BASE_ARTIFACT_DIR/iter-${iter}"
log "iteration ${iter}: start"
SW_BLOCK_ARTIFACT_DIR="$iter_dir" \
SW_BLOCK_LAUNCHER_PVC_OWNER_REF="${SW_BLOCK_LAUNCHER_PVC_OWNER_REF:-1}" \
bash "$ROOT/scripts/run-alpha-app-demo.sh" "$ROOT" \
>"$iter_dir.stdout.log" 2>"$iter_dir.stderr.log"
if ! grep -q "PASS: app pod wrote data" "$iter_dir/run.log"; then
log "iteration ${iter}: missing PASS line"
exit 1
fi
if [[ -f "$iter_dir/iscsi-sessions.after-delete.txt" ]] &&
! grep -q "No active sessions" "$iter_dir/iscsi-sessions.after-delete.txt"; then
log "iteration ${iter}: dangling iSCSI session"
cat "$iter_dir/iscsi-sessions.after-delete.txt" | tee -a "$SUMMARY"
exit 1
fi
log "iteration ${iter}: PASS"
done
log "PASS: ${ITERATIONS} attach/detach app PVC cycles completed"
log "artifacts=$BASE_ARTIFACT_DIR"