mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
* seaweed-block: release gate .ps1 runs swblock from PATH without a runner checkout RunnerRoot became mandatory when its lab default was dropped, so the script could no longer fall back to the swblock binary on PATH the way the .sh does when SWBLOCK_RUNNER_ROOT is unset. Default it to empty and check for an empty value before Test-Path, which rejects an empty path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-block: release gate refuses an artifact root with whitespace The kept scenarios substitute artifact_root into shell commands without quotes, including rm -rf of the run directory, so a path with a space would split into separate arguments. Refuse such a value up front in both release-gate scripts and say so in the settings table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-block: drop the removed testops/suites/ from the authoring page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-block: NVMe/TCP chains import images with the node-side key The image import runs build-alpha-images.sh on node-a, which ssh's from there to the import nodes, but these two chains passed ssh_key, the controller-side key. Pass node_ssh_key like the node-loss chain does; left empty, ssh falls back to node-a's default identity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-block: scenario headers list every setting a run needs The expected-invocation comments still showed only product_root and ssh_key, but each chain now also reads node_host, node_user and artifact_root and leaves them empty by default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-block: testops README names the lab-only scenario and the import chains helm-multi-volume-rf3-app-spread-failover-chain.yaml still names lab hosts, so the 'no scenario names a host' line now excepts it. The run example used <...> placeholders, which bash reads as redirections. The import_nodes and node_ssh_key rows now name the chains that read them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-block: test the release gate's artifact-root whitespace check Runs the .sh with a space and a tab in SW_BLOCK_NODE_ARTIFACT_ROOT and expects it to stop before creating the artifact directory, and checks that the .ps1 refuses such a value before its first New-Item. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
225 lines
7.8 KiB
Bash
Executable File
225 lines
7.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT="${1:-$(pwd)}"
|
|
RUN_ID="${SW_BLOCK_RUN_ID:-protocol-release-gate-$(date -u +%Y%m%dT%H%M%SZ)}"
|
|
ARTIFACT_ROOT="${SW_BLOCK_ARTIFACT_DIR:-$ROOT/results/$RUN_ID}"
|
|
RESULTS_ROOT="${SW_BLOCK_RESULTS_DIR:-$ARTIFACT_ROOT/runs}"
|
|
REMOTE_PRODUCT_ROOT="${SW_BLOCK_REMOTE_PRODUCT_ROOT:-/tmp/seaweed-block-nvme-p4l}"
|
|
# The test node and its access: required, with no default host, user, key or share.
|
|
SSH_KEY="${SW_BLOCK_SSH_KEY:?set SW_BLOCK_SSH_KEY to the private key for the test node}"
|
|
NODE_HOST="${SW_BLOCK_NODE_HOST:?set SW_BLOCK_NODE_HOST to the test node address}"
|
|
NODE_USER="${SW_BLOCK_NODE_USER:?set SW_BLOCK_NODE_USER to the ssh user on the test node}"
|
|
NODE_ARTIFACT_ROOT="${SW_BLOCK_NODE_ARTIFACT_ROOT:?set SW_BLOCK_NODE_ARTIFACT_ROOT to the shared artifact directory on the test node}"
|
|
# The scenarios put artifact_root into shell commands unquoted.
|
|
if [[ "$NODE_ARTIFACT_ROOT" =~ [[:space:]] ]]; then
|
|
echo "SW_BLOCK_NODE_ARTIFACT_ROOT must not contain whitespace: $NODE_ARTIFACT_ROOT" >&2
|
|
exit 2
|
|
fi
|
|
SWBLOCK_CMD="${SWBLOCK_CMD:-swblock}"
|
|
SWBLOCK_RUNNER_ROOT="${SWBLOCK_RUNNER_ROOT:-}"
|
|
SUITE_STARTED_EPOCH="$(date -u +%s)"
|
|
SUITE_STARTED_AT="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
PRODUCT_COMMIT="$(git -C "$ROOT" rev-parse HEAD 2>/dev/null || echo unknown)"
|
|
RUNNER_COMMIT="unknown"
|
|
|
|
to_bash_path() {
|
|
local p="$1"
|
|
if command -v cygpath >/dev/null 2>&1 && [[ "$p" =~ ^[A-Za-z]:\\ ]]; then
|
|
cygpath -u "$p"
|
|
return
|
|
fi
|
|
printf '%s\n' "$p"
|
|
}
|
|
|
|
if [[ -n "$SWBLOCK_RUNNER_ROOT" ]]; then
|
|
SWBLOCK_RUNNER_ROOT="$(to_bash_path "$SWBLOCK_RUNNER_ROOT")"
|
|
RUNNER_COMMIT="$(git -C "$SWBLOCK_RUNNER_ROOT" rev-parse HEAD 2>/dev/null || echo unknown)"
|
|
fi
|
|
|
|
mkdir -p "$ARTIFACT_ROOT" "$RESULTS_ROOT"
|
|
|
|
log() {
|
|
printf '[%s] [protocol-gate] %s\n' "$(date -u +%H:%M:%S)" "$*" | tee -a "$ARTIFACT_ROOT/suite.log"
|
|
}
|
|
|
|
run_swblock() {
|
|
if [[ -n "$SWBLOCK_RUNNER_ROOT" ]]; then
|
|
(cd "$SWBLOCK_RUNNER_ROOT" && go run ./cmd/swblock "$@")
|
|
else
|
|
"$SWBLOCK_CMD" "$@"
|
|
fi
|
|
}
|
|
|
|
json_escape() {
|
|
python3 -c 'import json,sys; print(json.dumps(sys.argv[1]))' "$1"
|
|
}
|
|
|
|
write_result() {
|
|
local status="$1"
|
|
local summary="$2"
|
|
local current_phase="${3:-}"
|
|
local now_epoch
|
|
now_epoch="$(date -u +%s)"
|
|
python3 - "$ARTIFACT_ROOT" "$RUN_ID" "$status" "$summary" "$current_phase" "$PRODUCT_COMMIT" "$RUNNER_COMMIT" "$REMOTE_PRODUCT_ROOT" "$SUITE_STARTED_EPOCH" "$SUITE_STARTED_AT" "$now_epoch" <<'PY'
|
|
import json
|
|
import pathlib
|
|
import sys
|
|
from datetime import datetime, timezone
|
|
|
|
root = pathlib.Path(sys.argv[1])
|
|
run_id, status, summary, current_phase, product_commit, runner_commit, remote_product_root = sys.argv[2:9]
|
|
started_epoch = int(sys.argv[9])
|
|
started_at = sys.argv[10]
|
|
now_epoch = int(sys.argv[11])
|
|
order = [
|
|
"iscsi-p6-alua-failover",
|
|
"nvme-p4-multipath-failover",
|
|
"nvme-p5-csi-protocol",
|
|
"iscsi-p8-compat-soak",
|
|
]
|
|
steps = []
|
|
for step in order:
|
|
step_dir = root / step
|
|
child = step_dir / "child-run.txt"
|
|
if not child.exists():
|
|
steps.append({
|
|
"name": step,
|
|
"status": "running" if step == current_phase else "pending",
|
|
"run_id": None,
|
|
"artifact_dir": str(step_dir),
|
|
"run_dir": None,
|
|
"phases_done": None,
|
|
"phases_total": None,
|
|
})
|
|
continue
|
|
child_run = child.read_text(encoding="utf-8").strip()
|
|
status_path = step_dir / "runs" / child_run / "status.json"
|
|
child_status = "error"
|
|
phases_done = None
|
|
phases_total = None
|
|
if status_path.exists():
|
|
data = json.loads(status_path.read_text(encoding="utf-8"))
|
|
child_status = data.get("state", child_status)
|
|
phases_done = data.get("phases_done")
|
|
phases_total = data.get("phases_total")
|
|
steps.append({
|
|
"name": step_dir.name,
|
|
"status": child_status,
|
|
"run_id": child_run,
|
|
"artifact_dir": str(step_dir),
|
|
"run_dir": str(step_dir / "runs" / child_run),
|
|
"phases_done": phases_done,
|
|
"phases_total": phases_total,
|
|
})
|
|
ended_at = None if status == "running" else datetime.now(timezone.utc).isoformat()
|
|
res = {
|
|
"schema_version": "1.0",
|
|
"run_id": run_id,
|
|
"scenario": "protocol-release-gate-suite",
|
|
"source_commit": product_commit,
|
|
"product_commit": product_commit,
|
|
"runner_commit": runner_commit,
|
|
"remote_product_root": remote_product_root,
|
|
"status": status,
|
|
"summary": summary,
|
|
"started_at": started_at,
|
|
"ended_at": ended_at,
|
|
"wall_clock_s": float(now_epoch - started_epoch),
|
|
"phase_results": steps,
|
|
"artifact_dir": str(root),
|
|
"artifacts": {
|
|
"suite_log": str(root / "suite.log"),
|
|
"runs_root": str(root / "runs"),
|
|
},
|
|
"non_claims": [
|
|
"Single-node lab release gate over existing runner-native chains.",
|
|
"Does not claim multi-node Kubernetes, RoCE, long soak, or production HA.",
|
|
"Each child chain owns its own product-level assertions and artifacts.",
|
|
],
|
|
}
|
|
(root / "result.json").write_text(json.dumps(res, indent=2) + "\n", encoding="utf-8")
|
|
terminal = {"pass", "fail", "cancelled", "error"}
|
|
status_doc = {
|
|
"schema_version": 1,
|
|
"run_id": run_id,
|
|
"scenario": "protocol-release-gate-suite",
|
|
"state": "pass" if status == "pass" else ("running" if status == "running" else "fail"),
|
|
"current_phase": current_phase,
|
|
"phases_total": 4,
|
|
"phases_done": sum(1 for s in steps if s["status"] in terminal),
|
|
"phases": steps,
|
|
"started_at": started_at,
|
|
"ended_at": ended_at,
|
|
"wall_clock_s": float(now_epoch - started_epoch),
|
|
"product_commit": product_commit,
|
|
"runner_commit": runner_commit,
|
|
"remote_product_root": remote_product_root,
|
|
"updated_at": datetime.now(timezone.utc).isoformat(),
|
|
"artifact_dir": str(root),
|
|
"error_summary": None if status == "pass" else summary,
|
|
}
|
|
(root / "status.json").write_text(json.dumps(status_doc, indent=2) + "\n", encoding="utf-8")
|
|
PY
|
|
}
|
|
|
|
run_chain() {
|
|
local step="$1"
|
|
local scenario="$2"
|
|
local step_dir="$ARTIFACT_ROOT/$step"
|
|
local step_results="$step_dir/runs"
|
|
mkdir -p "$step_dir" "$step_results"
|
|
|
|
log "run step=$step scenario=$scenario"
|
|
write_result running "running $step" "$step"
|
|
set +e
|
|
run_swblock run \
|
|
--env "product_root=$REMOTE_PRODUCT_ROOT" \
|
|
--env "ssh_key=$SSH_KEY" \
|
|
--env "node_host=$NODE_HOST" \
|
|
--env "node_user=$NODE_USER" \
|
|
--env "artifact_root=$NODE_ARTIFACT_ROOT" \
|
|
--results-dir "$step_results" \
|
|
"$ROOT/$scenario" \
|
|
>"$step_dir/swblock.stdout.log" \
|
|
2>"$step_dir/swblock.stderr.log"
|
|
local rc=$?
|
|
set -e
|
|
printf '%s\n' "$rc" >"$step_dir/exit_code.txt"
|
|
|
|
local child_run=""
|
|
if [[ -f "$step_results/latest" ]]; then
|
|
child_run="$(tr -d '\r\n' < "$step_results/latest")"
|
|
printf '%s\n' "$child_run" >"$step_dir/child-run.txt"
|
|
elif [[ "$rc" -eq 0 ]]; then
|
|
rc=1
|
|
printf 'swblock exited 0 but did not write latest run pointer: %s\n' "$step_results/latest" >>"$step_dir/swblock.stderr.log"
|
|
fi
|
|
|
|
if [[ "$rc" -ne 0 ]]; then
|
|
log "FAIL step=$step rc=$rc child_run=${child_run:-unknown}"
|
|
write_result fail "release gate failed at $step" "$step"
|
|
return "$rc"
|
|
fi
|
|
log "PASS step=$step child_run=${child_run:-unknown}"
|
|
write_result running "completed $step"
|
|
}
|
|
|
|
write_result running "protocol release gate queued"
|
|
log "run_id=$RUN_ID"
|
|
log "root=$ROOT"
|
|
log "artifact_root=$ARTIFACT_ROOT"
|
|
log "results_root=$RESULTS_ROOT"
|
|
log "remote_product_root=$REMOTE_PRODUCT_ROOT"
|
|
log "product_commit=$PRODUCT_COMMIT"
|
|
log "runner_commit=$RUNNER_COMMIT"
|
|
|
|
run_chain "iscsi-p6-alua-failover" "testops/scenarios/iscsi-p6-alua-failover-chain.yaml"
|
|
run_chain "nvme-p4-multipath-failover" "testops/scenarios/nvme-p4-multipath-failover-chain.yaml"
|
|
run_chain "nvme-p5-csi-protocol" "testops/scenarios/nvme-p5-csi-protocol-chain.yaml"
|
|
run_chain "iscsi-p8-compat-soak" "testops/scenarios/iscsi-p8-compat-soak-chain.yaml"
|
|
|
|
write_result pass "protocol release gate passed"
|
|
log "PASS: protocol release gate"
|
|
log "artifacts=$ARTIFACT_ROOT"
|