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