From aeaa2ab8ce017261b13d82a538eebecfc7cffda3 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 4 Dec 2026 20:50:10 -0800 Subject: [PATCH] seaweed-block: release gate fixes on top of the scenario cleanup (#13419) * 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 * 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 * seaweed-block: drop the removed testops/suites/ from the authoring page Co-Authored-By: Claude Opus 5.5 * 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 * 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 * 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 * 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 --------- Co-authored-by: Claude Opus 5.5 --- .../docs/wiki/deep-dives/testops-authoring.md | 1 - .../release_gate_artifact_root_test.go | 53 +++++++++++++++++++ .../testops-run-protocol-release-gate.ps1 | 11 ++-- .../testops-run-protocol-release-gate.sh | 5 ++ seaweed-block/testops/README.md | 15 +++--- .../activation-day1-install-chain.yaml | 3 ++ .../iscsi-p6-alua-failover-chain.yaml | 3 ++ .../scenarios/iscsi-p8-compat-soak-chain.yaml | 3 ++ ...use-first-volume-failure-bundle-chain.yaml | 3 ++ .../nvme-p4-multipath-failover-chain.yaml | 3 ++ .../scenarios/nvme-p5-csi-protocol-chain.yaml | 3 ++ .../nvme-p5-protocol-component-gate.yaml | 3 ++ ...node-multivolume-lifecycle-soak-chain.yaml | 3 +- ...vme-tcp-status-surface-evidence-chain.yaml | 3 +- 14 files changed, 99 insertions(+), 13 deletions(-) create mode 100644 seaweed-block/scripts/release_gate_artifact_root_test.go diff --git a/seaweed-block/docs/wiki/deep-dives/testops-authoring.md b/seaweed-block/docs/wiki/deep-dives/testops-authoring.md index 6da768fb5f..a8368d824a 100644 --- a/seaweed-block/docs/wiki/deep-dives/testops-authoring.md +++ b/seaweed-block/docs/wiki/deep-dives/testops-authoring.md @@ -85,7 +85,6 @@ Prefer gates that compare at least two surfaces: | Area | Path | |---|---| | scenario definitions | `testops/scenarios/` | -| suites | `testops/suites/` | | runner contracts | `internal/docs/ref/testops-runner-binary-contract.md` | | control/data contract | `internal/docs/ref/testops-control-data-contract.md` | | QA sign-offs | `internal/docs/qa-assignments/` | diff --git a/seaweed-block/scripts/release_gate_artifact_root_test.go b/seaweed-block/scripts/release_gate_artifact_root_test.go new file mode 100644 index 0000000000..f632a1a29d --- /dev/null +++ b/seaweed-block/scripts/release_gate_artifact_root_test.go @@ -0,0 +1,53 @@ +package scripts_test + +import ( + "os" + "os/exec" + "path/filepath" + "runtime" + "strings" + "testing" +) + +func TestReleaseGateRefusesArtifactRootWithWhitespace(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("bash script") + } + bash, err := exec.LookPath("bash") + if err != nil { + t.Skip("bash not available") + } + script := filepath.Join(repoRoot(t), "scripts", "testops-run-protocol-release-gate.sh") + for _, root := range []string{"/srv/test artifacts", "/srv/test\tartifacts"} { + artifacts := filepath.Join(t.TempDir(), "gate") + cmd := exec.Command(bash, script, t.TempDir()) + cmd.Env = append(os.Environ(), + "SW_BLOCK_SSH_KEY=/k", + "SW_BLOCK_NODE_HOST=192.0.2.10", + "SW_BLOCK_NODE_USER=tester", + "SW_BLOCK_NODE_ARTIFACT_ROOT="+root, + "SW_BLOCK_ARTIFACT_DIR="+artifacts, + "SWBLOCK_CMD=/nonexistent-swblock", + ) + out, err := cmd.CombinedOutput() + if err == nil { + t.Fatalf("artifact root %q accepted; output:\n%s", root, out) + } + if !strings.Contains(string(out), "must not contain whitespace") { + t.Fatalf("artifact root %q: unexpected output:\n%s", root, out) + } + if _, err := os.Stat(artifacts); !os.IsNotExist(err) { + t.Fatalf("artifact root %q: %s created before the check (stat err %v)", root, artifacts, err) + } + } + + ps, err := os.ReadFile(filepath.Join(repoRoot(t), "scripts", "testops-run-protocol-release-gate.ps1")) + if err != nil { + t.Fatal(err) + } + check := strings.Index(string(ps), `$NodeArtifactRoot -match '\s'`) + mkdir := strings.Index(string(ps), "New-Item -ItemType Directory") + if check < 0 || mkdir < 0 || check > mkdir { + t.Fatalf(".ps1 must refuse a NodeArtifactRoot with whitespace before it creates directories (check at %d, New-Item at %d)", check, mkdir) + } +} diff --git a/seaweed-block/scripts/testops-run-protocol-release-gate.ps1 b/seaweed-block/scripts/testops-run-protocol-release-gate.ps1 index 4cab226374..a6f8d42653 100644 --- a/seaweed-block/scripts/testops-run-protocol-release-gate.ps1 +++ b/seaweed-block/scripts/testops-run-protocol-release-gate.ps1 @@ -1,6 +1,6 @@ param( [string]$ProductRepoRoot = (Get-Location).Path, - [Parameter(Mandatory = $true)][string]$RunnerRoot, + [string]$RunnerRoot = "", [string]$RemoteProductRoot = "/tmp/seaweed-block-nvme-p4l", [Parameter(Mandatory = $true)][string]$SshKey, [Parameter(Mandatory = $true)][string]$NodeHost, @@ -12,6 +12,11 @@ param( $ErrorActionPreference = "Stop" +# The scenarios put artifact_root into shell commands unquoted. +if ($NodeArtifactRoot -match '\s') { + throw "NodeArtifactRoot must not contain whitespace: $NodeArtifactRoot" +} + if ([string]::IsNullOrWhiteSpace($RunId)) { $RunId = "protocol-release-gate-" + (Get-Date).ToUniversalTime().ToString("yyyyMMddTHHmmssZ") } @@ -26,7 +31,7 @@ $ProductCommit = "unknown" $RunnerCommit = "unknown" try { $ProductCommit = (& git -C $ProductRepoRoot rev-parse HEAD).Trim() } catch {} try { - if (Test-Path $RunnerRoot) { + if ($RunnerRoot -and (Test-Path $RunnerRoot)) { $RunnerCommit = (& git -C $RunnerRoot rev-parse HEAD).Trim() } } catch {} @@ -212,7 +217,7 @@ function Invoke-Chain { Set-Content -Path (Join-Path $stepDir "swblock.command.txt") -Value ("swblock " + ($swblockArgs -join " ")) $rc = 0 try { - if (Test-Path $RunnerRoot) { + if ($RunnerRoot -and (Test-Path $RunnerRoot)) { $rc = Invoke-NativeRedirect -FilePath "go" -Arguments (@("run", "./cmd/swblock") + $swblockArgs) -WorkingDirectory $RunnerRoot -StdoutPath $stdout -StderrPath $stderr } else { $rc = Invoke-NativeRedirect -FilePath "swblock" -Arguments $swblockArgs -WorkingDirectory $ProductRepoRoot -StdoutPath $stdout -StderrPath $stderr diff --git a/seaweed-block/scripts/testops-run-protocol-release-gate.sh b/seaweed-block/scripts/testops-run-protocol-release-gate.sh index ffd39292f1..230ab57859 100755 --- a/seaweed-block/scripts/testops-run-protocol-release-gate.sh +++ b/seaweed-block/scripts/testops-run-protocol-release-gate.sh @@ -11,6 +11,11 @@ SSH_KEY="${SW_BLOCK_SSH_KEY:?set SW_BLOCK_SSH_KEY to the private key for the tes 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)" diff --git a/seaweed-block/testops/README.md b/seaweed-block/testops/README.md index 13f8fdfe0d..7d09cc767a 100644 --- a/seaweed-block/testops/README.md +++ b/seaweed-block/testops/README.md @@ -18,8 +18,9 @@ not from this repository. Check a scenario before running it: swblock validate testops/scenarios/nvme-p5-protocol-component-gate.yaml ``` -No scenario names a host, user, key or share. Each one reads them from its `env` -block, where they are empty, so set every one on the command line: +Apart from `helm-multi-volume-rf3-app-spread-failover-chain.yaml`, which still targets +the project's lab, no scenario names a host, user, key or share. Each one reads them +from its `env` block, where they are empty, so set every one on the command line: | Setting | Meaning | | --- | --- | @@ -27,15 +28,15 @@ block, where they are empty, so set every one on the command line: | `node_host` | address of the test node | | `node_user` | ssh user on the test node | | `ssh_key` | private key for `node_user`, on the controller | -| `artifact_root` | shared directory for run artifacts, as the test node sees it | -| `import_nodes` | extra k3s nodes for the image import (the two NVMe/TCP status chains) | -| `node_ssh_key` | key path on the test node for the image import (the node-loss chain) | +| `artifact_root` | shared directory for run artifacts, as the test node sees it; no whitespace, since commands use it unquoted | +| `import_nodes` | every other k3s node, for the image import (`nvme-tcp-status-surface-evidence-chain`, `nvme-tcp-cross-node-multivolume-lifecycle-soak-chain`); without it only the test node gets the images | +| `node_ssh_key` | key path on the test node for the image import (those two chains and `node-loss-survival-rf3-reattach-chain`) | ```bash swblock run \ -env product_root=/path/to/seaweed-block \ - -env node_host= \ - -env node_user= \ + -env node_host=192.0.2.10 \ + -env node_user=tester \ -env ssh_key=/path/to/key \ -env artifact_root=/path/to/shared/artifacts \ testops/scenarios/nvme-p5-protocol-component-gate.yaml diff --git a/seaweed-block/testops/scenarios/activation-day1-install-chain.yaml b/seaweed-block/testops/scenarios/activation-day1-install-chain.yaml index a17ae14be2..bb216270c9 100644 --- a/seaweed-block/testops/scenarios/activation-day1-install-chain.yaml +++ b/seaweed-block/testops/scenarios/activation-day1-install-chain.yaml @@ -9,6 +9,9 @@ # swblock run \ # -env product_root=/path/to/seaweed_block/on/node-a \ # -env ssh_key=/path/to/ssh/key/on/controller \ +# -env node_host=192.0.2.10 \ +# -env node_user=tester \ +# -env artifact_root=/path/to/shared/artifacts \ # testops/scenarios/activation-day1-install-chain.yaml name: activation-day1-install-chain diff --git a/seaweed-block/testops/scenarios/iscsi-p6-alua-failover-chain.yaml b/seaweed-block/testops/scenarios/iscsi-p6-alua-failover-chain.yaml index c362a169c1..dfc25cfb16 100644 --- a/seaweed-block/testops/scenarios/iscsi-p6-alua-failover-chain.yaml +++ b/seaweed-block/testops/scenarios/iscsi-p6-alua-failover-chain.yaml @@ -9,6 +9,9 @@ # swblock run \ # -env product_root=/path/to/seaweed_block/on/node-a \ # -env ssh_key=/path/to/ssh/key/on/controller \ +# -env node_host=192.0.2.10 \ +# -env node_user=tester \ +# -env artifact_root=/path/to/shared/artifacts \ # testops/scenarios/iscsi-p6-alua-failover-chain.yaml name: iscsi-p6-alua-failover-chain diff --git a/seaweed-block/testops/scenarios/iscsi-p8-compat-soak-chain.yaml b/seaweed-block/testops/scenarios/iscsi-p8-compat-soak-chain.yaml index be42ab3230..18f7313571 100644 --- a/seaweed-block/testops/scenarios/iscsi-p8-compat-soak-chain.yaml +++ b/seaweed-block/testops/scenarios/iscsi-p8-compat-soak-chain.yaml @@ -8,6 +8,9 @@ # swblock run \ # -env product_root=/path/to/seaweed_block/on/node-a \ # -env ssh_key=/path/to/ssh/key/on/controller \ +# -env node_host=192.0.2.10 \ +# -env node_user=tester \ +# -env artifact_root=/path/to/shared/artifacts \ # testops/scenarios/iscsi-p8-compat-soak-chain.yaml name: iscsi-p8-compat-soak-chain diff --git a/seaweed-block/testops/scenarios/light-use-first-volume-failure-bundle-chain.yaml b/seaweed-block/testops/scenarios/light-use-first-volume-failure-bundle-chain.yaml index 698e799c9c..7757c6469e 100644 --- a/seaweed-block/testops/scenarios/light-use-first-volume-failure-bundle-chain.yaml +++ b/seaweed-block/testops/scenarios/light-use-first-volume-failure-bundle-chain.yaml @@ -9,6 +9,9 @@ # swblock run \ # -env product_root=/path/to/seaweed_block/on/node-a \ # -env ssh_key=/path/to/ssh/key/on/controller \ +# -env node_host=192.0.2.10 \ +# -env node_user=tester \ +# -env artifact_root=/path/to/shared/artifacts \ # testops/scenarios/light-use-first-volume-failure-bundle-chain.yaml name: light-use-first-volume-failure-bundle-chain diff --git a/seaweed-block/testops/scenarios/nvme-p4-multipath-failover-chain.yaml b/seaweed-block/testops/scenarios/nvme-p4-multipath-failover-chain.yaml index 6830c777ed..6bd603a33b 100644 --- a/seaweed-block/testops/scenarios/nvme-p4-multipath-failover-chain.yaml +++ b/seaweed-block/testops/scenarios/nvme-p4-multipath-failover-chain.yaml @@ -9,6 +9,9 @@ # swblock run \ # -env product_root=/path/to/seaweed_block/on/node-a \ # -env ssh_key=/path/to/ssh/key/on/controller \ +# -env node_host=192.0.2.10 \ +# -env node_user=tester \ +# -env artifact_root=/path/to/shared/artifacts \ # testops/scenarios/nvme-p4-multipath-failover-chain.yaml name: nvme-p4-multipath-failover-chain diff --git a/seaweed-block/testops/scenarios/nvme-p5-csi-protocol-chain.yaml b/seaweed-block/testops/scenarios/nvme-p5-csi-protocol-chain.yaml index 1b430a96d7..b44965dd0b 100644 --- a/seaweed-block/testops/scenarios/nvme-p5-csi-protocol-chain.yaml +++ b/seaweed-block/testops/scenarios/nvme-p5-csi-protocol-chain.yaml @@ -9,6 +9,9 @@ # swblock run \ # -env product_root=/path/to/seaweed_block/on/node-a \ # -env ssh_key=/path/to/ssh/key/on/controller \ +# -env node_host=192.0.2.10 \ +# -env node_user=tester \ +# -env artifact_root=/path/to/shared/artifacts \ # testops/scenarios/nvme-p5-csi-protocol-chain.yaml name: nvme-p5-csi-protocol-chain diff --git a/seaweed-block/testops/scenarios/nvme-p5-protocol-component-gate.yaml b/seaweed-block/testops/scenarios/nvme-p5-protocol-component-gate.yaml index 20d62b15b2..8a2d9039ee 100644 --- a/seaweed-block/testops/scenarios/nvme-p5-protocol-component-gate.yaml +++ b/seaweed-block/testops/scenarios/nvme-p5-protocol-component-gate.yaml @@ -9,6 +9,9 @@ # swblock run \ # -env product_root=/path/to/seaweed_block/on/node-a \ # -env ssh_key=/path/to/ssh/key/on/controller \ +# -env node_host=192.0.2.10 \ +# -env node_user=tester \ +# -env artifact_root=/path/to/shared/artifacts \ # testops/scenarios/nvme-p5-protocol-component-gate.yaml name: nvme-p5-protocol-component-gate diff --git a/seaweed-block/testops/scenarios/nvme-tcp-cross-node-multivolume-lifecycle-soak-chain.yaml b/seaweed-block/testops/scenarios/nvme-tcp-cross-node-multivolume-lifecycle-soak-chain.yaml index 261666de74..fe1b4d24eb 100644 --- a/seaweed-block/testops/scenarios/nvme-tcp-cross-node-multivolume-lifecycle-soak-chain.yaml +++ b/seaweed-block/testops/scenarios/nvme-tcp-cross-node-multivolume-lifecycle-soak-chain.yaml @@ -8,6 +8,7 @@ env: node_user: "" # ssh user on the test node; set with -env node_user= artifact_root: "" # shared artifact directory; set with -env artifact_root= import_nodes: "" # extra k3s nodes for the image import; set with -env import_nodes= + node_ssh_key: "" # key path on the test node for the image import; set with -env node_ssh_key= helm_release: "sw-block" helm_namespace: "kube-system" volume_count: "2" @@ -43,7 +44,7 @@ phases: env.SW_BLOCK_IMPORT_K3S: "1" env.SW_BLOCK_IMPORT_K3S_NODES: "{{ import_nodes }}" env.SW_BLOCK_IMPORT_K3S_SSH_USER: "{{ node_user }}" - env.SW_BLOCK_IMPORT_K3S_SSH_KEY: "{{ ssh_key }}" + env.SW_BLOCK_IMPORT_K3S_SSH_KEY: "{{ node_ssh_key }}" env.SW_BLOCK_ARTIFACT_DIR: "{{ artifact_root }}/g15d-k8s/{{ run_id }}-phase108-nvme-lifecycle/build" - action: grep_log node: node-a diff --git a/seaweed-block/testops/scenarios/nvme-tcp-status-surface-evidence-chain.yaml b/seaweed-block/testops/scenarios/nvme-tcp-status-surface-evidence-chain.yaml index b925bc30c0..8fde5d9e94 100644 --- a/seaweed-block/testops/scenarios/nvme-tcp-status-surface-evidence-chain.yaml +++ b/seaweed-block/testops/scenarios/nvme-tcp-status-surface-evidence-chain.yaml @@ -8,6 +8,7 @@ env: node_user: "" # ssh user on the test node; set with -env node_user= artifact_root: "" # shared artifact directory; set with -env artifact_root= import_nodes: "" # extra k3s nodes for the image import; set with -env import_nodes= + node_ssh_key: "" # key path on the test node for the image import; set with -env node_ssh_key= helm_release: "sw-block" helm_namespace: "kube-system" volume_count: "2" @@ -42,7 +43,7 @@ phases: env.SW_BLOCK_IMPORT_K3S: "1" env.SW_BLOCK_IMPORT_K3S_NODES: "{{ import_nodes }}" env.SW_BLOCK_IMPORT_K3S_SSH_USER: "{{ node_user }}" - env.SW_BLOCK_IMPORT_K3S_SSH_KEY: "{{ ssh_key }}" + env.SW_BLOCK_IMPORT_K3S_SSH_KEY: "{{ node_ssh_key }}" env.SW_BLOCK_ARTIFACT_DIR: "{{ artifact_root }}/g15d-k8s/{{ run_id }}-phase109-nvme-status/build" - action: grep_log node: node-a