Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(e2e): match layout_row exit codes as a list, not a case pattern

Alfredo Lopez924f68af38ef
diff --git a/scripts/e2e/e2e-825-lib.sh b/scripts/e2e/e2e-825-lib.sh
index 81598d242..561ac7bab 100755
--- a/scripts/e2e/e2e-825-lib.sh
+++ b/scripts/e2e/e2e-825-lib.sh
@@ -424,17 +424,18 @@ read_seed_file() { # HOST NAME EXPECTED
# ─── Operator script ──────────────────────────────────────────────────
# layout_row inventory|verify HOST EXITS: runs deploy/scripts/host-layout-merge.sh
-# on this profile and prints the result of the Host's PVC row. EXITS is a case
-# pattern; the fleet verdict is left alone because other Hosts on the profile
-# decide it, and exit 2 (read failure) never matches.
+# on this profile and prints the result of the Host's PVC row. EXITS is a
+# space-separated list of accepted exit codes (a `|` inside an expanded case
+# pattern is matched literally, not as alternation); the fleet verdict is left
+# alone because other Hosts on the profile decide it, and exit 2 (read failure)
+# never matches.
layout_row() {
local cmd=$1 host=$2 exits=$3 rc=0 out row
out="$(mktemp "${SCRATCH}/layout-${cmd}-${host}.XXXXXX")"
log "host-layout-merge.sh ${cmd} for ${HOST_NS}/${host}-workspace" >&2
bash "$LAYOUT_SCRIPT" "$cmd" --context "$E2E_KUBECONTEXT" >"$out" 2>"${out}.err" || rc=$?
- # shellcheck disable=SC2254 # EXITS is a case pattern on purpose
- case "$rc" in
- $exits) ;;
+ case " ${exits} " in
+ *" ${rc} "*) ;;
*)
fail "${host}: host-layout-merge.sh ${cmd} exited ${rc} (expected ${exits}): $(tail -n 3 "${out}.err" | tr '\n' ' ') $(tail -n 3 "$out" | tr '\n' ' ')" >&2
return 1
diff --git a/scripts/e2e/e2e-hcc-storage-layout-switch.sh b/scripts/e2e/e2e-hcc-storage-layout-switch.sh
index 8a5534f9c..69335eaf2 100755
--- a/scripts/e2e/e2e-hcc-storage-layout-switch.sh
+++ b/scripts/e2e/e2e-hcc-storage-layout-switch.sh
@@ -280,7 +280,7 @@ scenario_S5() {
fail "S5: seeded tree is not split: ${listing}"
return 1
fi
- row="$(layout_row inventory "$name" '0|1')" || return 1
+ row="$(layout_row inventory "$name" '0 1')" || return 1
[ "$row" = WILL_MERGE ] || { fail "S5: inventory reads ${name}-workspace as '${row}', expected WILL_MERGE"; return 1; }
# A split tree is a blocker for turning the flag off, whatever the rest of the fleet.
row="$(layout_row verify "$name" 1)" || return 1
@@ -298,7 +298,7 @@ scenario_S5() {
return 1
fi
ok "S5: split tree merged to the root"
- row="$(layout_row verify "$name" '0|1')" || return 1
+ row="$(layout_row verify "$name" '0 1')" || return 1
[ "$row" = POD_OK ] || { fail "S5: verify reads ${name}-workspace as '${row}' after the merge, expected POD_OK"; return 1; }
ok "S5: host-layout-merge.sh verify reads the merged Host as POD_OK"
assert_history "$name" 'suspend->wake(split-tree-merged)' || return 1
diff --git a/scripts/e2e/e2e-hcc-storage-layout-switch.test.mjs b/scripts/e2e/e2e-hcc-storage-layout-switch.test.mjs
index a8e524c91..9116fb454 100644
--- a/scripts/e2e/e2e-hcc-storage-layout-switch.test.mjs
+++ b/scripts/e2e/e2e-hcc-storage-layout-switch.test.mjs
@@ -250,3 +250,45 @@ test('no curl call in the #825 scripts puts a Cookie or Authorization header in
const uses = SOURCE.match(/auth_header (admin|session|rpc) /g) ?? []
assert.ok(uses.length >= 4, `auth_header uses: ${uses.length}`)
})
+
+function runLayoutRow(dir, exits, rc) {
+ const script = path.join(dir, 'host-layout-merge.sh')
+ writeFileSync(script, `echo "PVC e2e/h1-workspace host=h1 result=WILL_MERGE"\nexit ${rc}\n`)
+ const body = `
+fail() { echo "FAIL — $*"; }
+log() { :; }
+SCRATCH="$DIR" LAYOUT_SCRIPT="$DIR/host-layout-merge.sh" E2E_KUBECONTEXT=ctx HOST_NS=e2e
+${helper('layout_row')}
+row="$(layout_row inventory h1 "$EXITS")"; rc=$?
+printf 'RC=%s ROW=[%s]\\n' "$rc" "$row"
+`
+ return bash(body, { DIR: dir, EXITS: exits })
+}
+
+test('layout_row accepts every exit code in its list and refuses the others', () => {
+ const dir = mkdtempSync(path.join(tmpdir(), 'e2e-825-layout-row-'))
+ try {
+ for (const [exits, rc, expected] of [
+ ['0 1', 0, 'RC=0 ROW=[WILL_MERGE]'],
+ ['0 1', 1, 'RC=0 ROW=[WILL_MERGE]'],
+ ['1', 1, 'RC=0 ROW=[WILL_MERGE]'],
+ ['1', 0, 'RC=1 ROW=[]'],
+ ['0 1', 2, 'RC=1 ROW=[]'],
+ ['0 1', 10, 'RC=1 ROW=[]'],
+ ]) {
+ const run = runLayoutRow(dir, exits, rc)
+ assert.equal(run.status, 0, run.stderr)
+ assert.equal(run.stdout.trim().split('\n').at(-1), expected, `exits=[${exits}] rc=${rc}: ${run.stdout}`)
+ if (expected.startsWith('RC=1')) assert.match(run.stderr, new RegExp(`exited ${rc} \\(expected ${exits}\\)`))
+ }
+ } finally {
+ rmSync(dir, { recursive: true, force: true })
+ }
+})
+
+test('layout_row callers pass exit codes as a space-separated list', () => {
+ const calls = SOURCE.match(/layout_row (inventory|verify) "\$name" \S+/g) ?? []
+ // Witness: S5 and S6 call it five times.
+ assert.equal(calls.length, 5, calls.join('\n'))
+ for (const call of calls) assert.doesNotMatch(call, /\|/, call)
+})