Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/e2e-vitest-scenarios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,45 @@ jobs:
path: e2e-artifacts/vitest/${{ matrix.id }}/
include-hidden-files: false
if-no-files-found: ignore

# Free-standing live tests under test/e2e-scenario/live/ that don't fit the
# registry-driven steady-state probe model. Each gets a discrete job here
# because the matrix above only runs registry-scenarios.test.ts. Modeled on
# #5049's free-standing pattern.
openshell-version-pin-vitest:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
E2E_ARTIFACT_DIR: ${{ github.workspace }}/e2e-artifacts/vitest/openshell-version-pin
NEMOCLAW_RUN_E2E_SCENARIOS: "1"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false

- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.0.0
with:
node-version: 22
cache: npm

- name: Install root dependencies
run: npm ci --ignore-scripts

- name: Run OpenShell version-pin live test
# Migrated from test/e2e/test-openshell-version-pin.sh. Hermetic
# installer-script behavioral test — no real network, no real install.
run: |
set -euo pipefail
npx vitest run --project e2e-scenarios-live \
test/e2e-scenario/live/openshell-version-pin.test.ts \
--silent=false --reporter=default

- name: Upload OpenShell version-pin artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-vitest-scenarios-openshell-version-pin
path: e2e-artifacts/vitest/openshell-version-pin/
include-hidden-files: false
if-no-files-found: ignore
284 changes: 284 additions & 0 deletions test/e2e-scenario/live/openshell-version-pin.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { spawnSync } from "node:child_process";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";

import { expect, test } from "../framework/e2e-test.ts";

// Migrated from test/e2e/test-openshell-version-pin.sh (regression guard for
// #3474). The legacy bash script is a hermetic installer-script behavioral
// test: it runs scripts/install-openshell.sh under a stubbed PATH where the
// already-installed openshell reports a too-new version (0.0.45) and the
// downloaded archives produce a binary that reports the pinned 0.0.44.
//
// This is a free-standing live test (per #5049's pattern) — it does not exercise
// the registry-driven steady-state probe model. There is no OpenClaw instance,
// no environment phase, no lifecycle. The test consumes only the `artifacts`
// fixture from e2e-test.ts so failures attach the per-scenario artifact root.

const REPO_ROOT = path.resolve(import.meta.dirname, "../../..");
const INSTALL_SCRIPT = path.join(REPO_ROOT, "scripts", "install-openshell.sh");

function writeExecutable(target: string, contents: string): void {
fs.writeFileSync(target, contents, { mode: 0o755 });
}

test(
"openshell-version-pin: replaces sticky too-new openshell with pinned 0.0.44 end-to-end",
async ({ artifacts }) => {
await artifacts.writeJson("scenario.json", {
id: "openshell-version-pin",
runner: "vitest",
boundary: "installer-script-unit",
regressionTarget: "#3474",
});

const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-openshell-version-pin-"));
try {
const fakeBin = path.join(tmp, "bin");
const downloadLog = path.join(tmp, "downloads.log");
fs.mkdirSync(fakeBin);
fs.writeFileSync(downloadLog, "");

// Force Linux/x86_64 asset selection regardless of host arch (legacy
// script is dispatched on ubuntu-latest via regression-e2e.yaml).
writeExecutable(
path.join(fakeBin, "uname"),
`#!/usr/bin/env bash
if [ "\${1:-}" = "-m" ]; then echo "x86_64"; else echo "Linux"; fi`,
);

// Sticky openshell at the too-new version we expect the installer to replace.
writeExecutable(
path.join(fakeBin, "openshell"),
`#!/usr/bin/env bash
if [ "\${1:-}" = "--version" ]; then echo "openshell 0.0.45"; exit 0; fi
# request-body-credential-rewrite websocket-credential-rewrite
exit 0`,
);

// Helper binaries exist so the only reason to reinstall is the too-new
// version, not missing Docker-driver helpers.
writeExecutable(
path.join(fakeBin, "openshell-gateway"),
`#!/usr/bin/env bash
exit 0`,
);
writeExecutable(
path.join(fakeBin, "openshell-sandbox"),
`#!/usr/bin/env bash
exit 0`,
);

// gh succeeds and writes fake archives + matching sha256 checksum files
// into the requested --dir. The checksums are real digests of the fake
// archives so install-openshell.sh's `sha256sum -c` step passes.
writeExecutable(
path.join(fakeBin, "gh"),
`#!/usr/bin/env bash
set -euo pipefail
write_asset() {
local asset_name="$1"
local asset_path="$2"
printf 'fake OpenShell release asset: %s\\n' "$asset_name" >"$asset_path"
}
sha256_digest() {
if [ -x /usr/bin/sha256sum ]; then
/usr/bin/sha256sum "$1" | awk '{print $1}'
elif [ -x /bin/sha256sum ]; then
/bin/sha256sum "$1" | awk '{print $1}'
elif [ -x /usr/bin/shasum ]; then
/usr/bin/shasum -a 256 "$1" | awk '{print $1}'
else
exit 3
fi
}
write_checksum() {
local checksum_file="$1"
local asset_name="$2"
local asset_path="$3"
[ -f "$asset_path" ] || write_asset "$asset_name" "$asset_path"
printf '%s %s\\n' "$(sha256_digest "$asset_path")" "$asset_name" >"$checksum_file"
}
if [ "\${1:-}" = "release" ] && [ "\${2:-}" = "download" ]; then
tag="\${3:-}"
pattern=""
dir=""
while [ "$#" -gt 0 ]; do
case "$1" in
--pattern) shift; pattern="\${1:-}" ;;
--dir) shift; dir="\${1:-}" ;;
esac
shift || true
done
[ -n "$tag" ] && [ -n "$pattern" ] && [ -n "$dir" ] || exit 2
printf 'gh download %s %s\\n' "$tag" "$pattern" >> ${JSON.stringify(downloadLog)}
mkdir -p "$dir"
case "$pattern" in
openshell-checksums-sha256.txt)
asset_name="openshell-x86_64-unknown-linux-musl.tar.gz"
write_checksum "$dir/$pattern" "$asset_name" "$dir/$asset_name"
;;
openshell-gateway-checksums-sha256.txt)
asset_name="openshell-gateway-x86_64-unknown-linux-gnu.tar.gz"
write_checksum "$dir/$pattern" "$asset_name" "$dir/$asset_name"
;;
openshell-sandbox-checksums-sha256.txt)
asset_name="openshell-sandbox-x86_64-unknown-linux-gnu.tar.gz"
write_checksum "$dir/$pattern" "$asset_name" "$dir/$asset_name"
;;
*)
write_asset "$pattern" "$dir/$pattern"
;;
esac
exit 0
fi
exit 1`,
);

// curl mirror of the gh stub for the curl fallback download path. Logs
// every invocation to DOWNLOAD_LOG so we can assert which release tag
// was requested.
writeExecutable(
path.join(fakeBin, "curl"),
`#!/usr/bin/env bash
set -euo pipefail
write_asset() {
local asset_name="$1"
local asset_path="$2"
printf 'fake OpenShell release asset: %s\\n' "$asset_name" >"$asset_path"
}
sha256_digest() {
if [ -x /usr/bin/sha256sum ]; then
/usr/bin/sha256sum "$1" | awk '{print $1}'
elif [ -x /bin/sha256sum ]; then
/bin/sha256sum "$1" | awk '{print $1}'
elif [ -x /usr/bin/shasum ]; then
/usr/bin/shasum -a 256 "$1" | awk '{print $1}'
else
exit 3
fi
}
write_checksum() {
local checksum_file="$1"
local asset_name="$2"
local asset_path="$3"
[ -f "$asset_path" ] || write_asset "$asset_name" "$asset_path"
printf '%s %s\\n' "$(sha256_digest "$asset_path")" "$asset_name" >"$checksum_file"
}
printf 'curl %s\\n' "$*" >> ${JSON.stringify(downloadLog)}
out=""
while [ "$#" -gt 0 ]; do
if [ "$1" = "-o" ]; then
shift
out="\${1:-}"
fi
shift || true
done
[ -n "$out" ] || exit 0
case "$(basename "$out")" in
openshell-checksums-sha256.txt)
asset_name="openshell-x86_64-unknown-linux-musl.tar.gz"
write_checksum "$out" "$asset_name" "$(dirname "$out")/$asset_name"
;;
openshell-gateway-checksums-sha256.txt)
asset_name="openshell-gateway-x86_64-unknown-linux-gnu.tar.gz"
write_checksum "$out" "$asset_name" "$(dirname "$out")/$asset_name"
;;
openshell-sandbox-checksums-sha256.txt)
asset_name="openshell-sandbox-x86_64-unknown-linux-gnu.tar.gz"
write_checksum "$out" "$asset_name" "$(dirname "$out")/$asset_name"
;;
*)
write_asset "$(basename "$out")" "$out"
;;
esac`,
);

// tar stub: write the corresponding binary into the -C outdir. Each
// binary reports 0.0.44 + carries the messaging-rewrite capability
// marker so the post-install feature probe passes.
writeExecutable(
path.join(fakeBin, "tar"),
`#!/usr/bin/env bash
set -euo pipefail
outdir=""
prev=""
for arg in "$@"; do
if [ "$prev" = "-C" ]; then
outdir="$arg"
break
fi
prev="$arg"
done
[ -n "$outdir" ] || exit 1
case "$*" in
*openshell-gateway*) name="openshell-gateway" ;;
*openshell-sandbox*) name="openshell-sandbox" ;;
*) name="openshell" ;;
esac
cat > "$outdir/$name" <<'EOS'
#!/usr/bin/env bash
if [ "\${1:-}" = "--version" ]; then echo "openshell 0.0.44"; exit 0; fi
# request-body-credential-rewrite websocket-credential-rewrite
exit 0
EOS
chmod 755 "$outdir/$name"`,
);

// The capability probe shells out to `strings` against the installed
// openshell binary. Our fake openshell binaries are scripts whose
// contents already include the marker comments, so cat-ing them
// satisfies the probe.
writeExecutable(
path.join(fakeBin, "strings"),
`#!/usr/bin/env bash
cat "$@" 2>/dev/null || true`,
);

const result = spawnSync("bash", [INSTALL_SCRIPT], {
env: {
...process.env,
NEMOCLAW_OPENSHELL_CHANNEL: "stable",
PATH: `${fakeBin}:/usr/bin:/bin`,
},
encoding: "utf8",
});

// Persist the install transcript so failures can be diagnosed without
// re-running the test.
await artifacts.writeText("install-openshell.stdout", result.stdout ?? "");
await artifacts.writeText("install-openshell.stderr", result.stderr ?? "");
await artifacts.writeText("downloads.log", fs.readFileSync(downloadLog, "utf-8"));

// Assertion 1: installer-exits-zero — the happy path completes (no
// "above the maximum" hard-fail before download).
expect(result.status, `${result.stdout}\n${result.stderr}`).toBe(0);

// Assertion 2: download-log-contains-v0.0.44 — pinned release tag was
// requested from the release host.
const downloads = fs.readFileSync(downloadLog, "utf-8");
expect(downloads).toContain("v0.0.44");

// Assertion 3: download-log-excludes-v0.0.45 — the too-new sticky
// version is never re-fetched.
expect(downloads).not.toContain("v0.0.45");

// Assertion 4: replaced-openshell-reports-0.0.44 — the binary on disk in
// the active install dir (== fakeBin, since ACTIVE_OPENSHELL_BIN
// resolved there and it is writable) was overwritten with the pinned
// 0.0.44 build.
const replacedVersion = spawnSync(path.join(fakeBin, "openshell"), ["--version"], {
encoding: "utf8",
});
expect(replacedVersion.status).toBe(0);
expect(replacedVersion.stdout).toContain("0.0.44");
expect(replacedVersion.stdout).not.toContain("0.0.45");
} finally {
fs.rmSync(tmp, { recursive: true, force: true });
}
},
);
28 changes: 22 additions & 6 deletions test/e2e-scenario/migration/legacy-inventory.json
Original file line number Diff line number Diff line change
Expand Up @@ -611,12 +611,28 @@
"legacyScript": "test/e2e/test-openshell-version-pin.sh",
"domain": "sandbox-lifecycle",
"ownerIssue": "#4355",
"status": "not-migrated",
"targetVitestScenarios": [],
"bridgeProbes": [],
"retiredReason": "",
"deletionReady": false,
"notes": "Initial completeness row; classify detailed coverage and deletion evidence in the owning migration issue before deleting."
"status": "covered",
"targetVitestScenarios": ["test/e2e-scenario/live/openshell-version-pin.test.ts"],
"bridgeProbes": [],
"retiredReason": "",
"deletionReady": false,
"notes": "Covered by free-standing live test (PR #5107). Hermetic installer-script behavioral test — stubs PATH binaries, runs scripts/install-openshell.sh, asserts the four [PASS] outcomes from the legacy bash guard. Not registry-driven; dispatched as a discrete openshell-version-pin-vitest job in e2e-vitest-scenarios.yaml. Bash guard retained in regression-e2e.yaml; deletion is a follow-up PR with #4357 approval.",
"frozenAtSha": "3d9c01931f598cf2450bd88028cb3b44bcf367b0",
"convergenceEvidence": {
"redRunUrl": null,
"greenRunUrlA": "https://github.com/NVIDIA/NemoClaw/actions/runs/27252871283/job/80480862915",
"greenRunUrlB": "https://github.com/NVIDIA/NemoClaw/actions/runs/27253022534/job/80481579156",
"totalPasses": 2,
"assertionsResolvedInOrder": [
"installer-exits-zero",
"download-log-contains-v0.0.44",
"download-log-excludes-v0.0.45",
"replaced-openshell-reports-0.0.44"
],
"convergedAtSha": "3d9c01931f598cf2450bd88028cb3b44bcf367b0",
"firstDispatchPassed": true,
"firstDispatchPassNote": "Framework already covered the regression target; legacy script was duplicative beyond the entry-point assertions. Post-pivot verification dispatch confirmed reproducibility on the correct architectural home (test/e2e-scenario/live/)."
}
},
{
"legacyScript": "test/e2e/test-overlayfs-autofix.sh",
Expand Down
Loading