Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
33 changes: 29 additions & 4 deletions test/e2e/test-onboard-repair.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,22 @@ pass "Exported NVIDIA_API_KEY for the repair run (host writes nothing to disk; O
# Phase 2: Create interrupted resumable state
# ══════════════════════════════════════════════════════════════════
section "Phase 2: Create interrupted state"
info "Running onboard with an invalid policy mode to create resumable state..."
info "Running onboard with POLICY_MODE=custom but no POLICY_PRESETS to force a policy-step failure..."

# Use NEMOCLAW_POLICY_MODE=custom without NEMOCLAW_POLICY_PRESETS — this is a
# real validation path that exits 1 at the policy step after the sandbox is
# already created, leaving resumable session state.
#
# Note: the previous approach (NEMOCLAW_POLICY_MODE=invalid) stopped working
# after PR #2434 changed invalid modes from process.exit(1) to a graceful
# fallback with console.warn(). See #2573 for details.
FIRST_LOG="$(mktemp)"
NEMOCLAW_NON_INTERACTIVE=1 \
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 \
NEMOCLAW_SANDBOX_NAME="$SANDBOX_NAME" \
NEMOCLAW_RECREATE_SANDBOX=1 \
NEMOCLAW_POLICY_MODE=invalid \
NEMOCLAW_POLICY_MODE=custom \
NEMOCLAW_POLICY_PRESETS="" \
node "$REPO/bin/nemoclaw.js" onboard --non-interactive >"$FIRST_LOG" 2>&1
first_exit=$?
first_output="$(cat "$FIRST_LOG")"
Expand All @@ -159,7 +167,7 @@ else
fail "Onboard session file missing after interrupted run"
fi

if echo "$first_output" | grep -q "Unsupported NEMOCLAW_POLICY_MODE: invalid"; then
if echo "$first_output" | grep -q "NEMOCLAW_POLICY_PRESETS is required when NEMOCLAW_POLICY_MODE=custom"; then
pass "First run failed at policy setup as intended"
else
fail "First run did not fail at the expected policy step"
Expand Down Expand Up @@ -223,7 +231,8 @@ else
fail "Repair resume did not report missing sandbox recreation"
fi

if echo "$repair_output" | grep -q "\[5/7\] Creating sandbox"; then
# The step numbering is [6/8] in the current onboard flow.
if echo "$repair_output" | grep -q "Creating sandbox"; then
pass "Repair resume recreated sandbox"
else
fail "Repair resume did not rerun sandbox creation"
Expand All @@ -239,6 +248,22 @@ fi
# Phase 4: Reject conflicting sandbox
# ══════════════════════════════════════════════════════════════════
section "Phase 4: Reject conflicting sandbox"

# Phase 3 completed the session (resumable=false). Re-create interrupted state
# so the conflict detection path is exercised (it runs before the "no resumable
# session" early-exit).
info "Re-creating interrupted state for conflict testing..."
REINJECT_LOG="$(mktemp)"
NEMOCLAW_NON_INTERACTIVE=1 \
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 \
NEMOCLAW_SANDBOX_NAME="$SANDBOX_NAME" \
NEMOCLAW_RECREATE_SANDBOX=1 \
NEMOCLAW_POLICY_MODE=custom \
NEMOCLAW_POLICY_PRESETS="" \
node "$REPO/bin/nemoclaw.js" onboard --non-interactive >"$REINJECT_LOG" 2>&1 || true
rm -f "$REINJECT_LOG"
pass "Re-created interrupted session for conflict tests"

info "Attempting resume with a different sandbox name..."

SANDBOX_CONFLICT_LOG="$(mktemp)"
Expand Down
23 changes: 18 additions & 5 deletions test/e2e/test-onboard-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,22 @@ pass "Exported NVIDIA_API_KEY for the resume run (host writes nothing to disk; O
# Phase 2: First onboard (forced failure after sandbox creation)
# ══════════════════════════════════════════════════════════════════
section "Phase 2: First onboard (interrupted)"
info "Running onboard with an invalid policy mode to create resumable state..."
info "Running onboard with POLICY_MODE=custom but no POLICY_PRESETS to force a policy-step failure..."

# Use NEMOCLAW_POLICY_MODE=custom without NEMOCLAW_POLICY_PRESETS — this is a
# real validation path that exits 1 at the policy step after the sandbox is
# already created, leaving resumable session state.
#
# Note: the previous approach (NEMOCLAW_POLICY_MODE=invalid) stopped working
# after PR #2434 changed invalid modes from process.exit(1) to a graceful
# fallback with console.warn(). See #2573 for details.
FIRST_LOG="$(mktemp)"
NEMOCLAW_NON_INTERACTIVE=1 \
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 \
NEMOCLAW_SANDBOX_NAME="$SANDBOX_NAME" \
NEMOCLAW_RECREATE_SANDBOX=1 \
NEMOCLAW_POLICY_MODE=invalid \
NEMOCLAW_POLICY_MODE=custom \
NEMOCLAW_POLICY_PRESETS="" \
node "$REPO/bin/nemoclaw.js" onboard --non-interactive >"$FIRST_LOG" 2>&1
first_exit=$?
first_output="$(cat "$FIRST_LOG")"
Expand All @@ -169,7 +177,7 @@ else
fail "Sandbox creation not confirmed in first run output"
fi

if echo "$first_output" | grep -q "Unsupported NEMOCLAW_POLICY_MODE: invalid"; then
if echo "$first_output" | grep -q "NEMOCLAW_POLICY_PRESETS is required when NEMOCLAW_POLICY_MODE=custom"; then
pass "First run failed at policy setup as intended"
else
fail "First run did not fail at the expected policy step"
Expand Down Expand Up @@ -261,10 +269,15 @@ else
pass "Resume did not rerun sandbox creation"
fi

# The first onboard completed through openclaw (step 7) before failing at
# policies (step 8). Inference was already configured during that run, so
# the resume path detects it is ready (isInferenceRouteReady) and skips it.
if echo "$resume_output" | grep -q "\[4/7\] Setting up inference provider"; then
pass "Resume continued with inference setup"
pass "Resume re-ran inference setup"
elif echo "$resume_output" | grep -q "\[resume\] Skipping inference\|\[reuse\] Skipping inference"; then
pass "Resume skipped inference (already configured)"
else
fail "Resume did not continue with inference setup"
fail "Resume neither ran nor skipped inference setup"
fi

if run_nemoclaw "$SANDBOX_NAME" status >/dev/null 2>&1; then
Expand Down
Loading