Repository navigation
fix(test): update connect tests for readiness poll behavior from #466 - #2198
Conversation
PR #466 changed `nemoclaw <name> connect` to poll `openshell sandbox list` for readiness instead of exiting immediately when the sandbox phase isn't Ready. Three pre-existing test files still encoded the old behavior and are now failing on every PR that rebases onto main: - test/sandbox-connect-inference.test.ts - test/sandbox-stuck-recovery.test.ts - test/reboot-identity-drift.test.ts Root cause: the fake openshell mocks emit `sandbox list` output with only a name column (`process.stdout.write("<name>\\n")`). The new readiness poll calls `parseSandboxStatus(output, name)` which needs at least `[name, status, age]` to parse a status — so it always returns null, falls back to "unknown", and the connect loop hangs until the test's 15s spawnSync timeout kills the child (exit status: null). Changes: 1. All three files: update the fake `openshell sandbox list` mock to emit a proper status column, e.g. `"${name} Ready 2m ago"`. - connect-inference + reboot-identity-drift always return Ready (they test the happy path; nothing about phase transitions). - sandbox-stuck-recovery uses the parameterized `${phase}` since its setupFixture already takes a phase argument. 2. sandbox-stuck-recovery.test.ts: the "stuck in Provisioning" connect test was asserting the old pre-#466 message chain ("stuck in 'Provisioning' phase" + "process crash inside the sandbox" + "rebuild --yes"). Those messages no longer fire for `connect` because ensureLiveSandboxOrExit is now called with {allowNonReadyPhase: true}. Rewrote the test to: - Set NEMOCLAW_CONNECT_TIMEOUT=3 so the readiness poll exits quickly instead of waiting the 120s default. - Assert the new timeout path: "Waiting for sandbox 'X' to be ready" + "Timed out" + "NEMOCLAW_CONNECT_TIMEOUT" override hint. 3. sandbox-stuck-recovery.test.ts: added a companion test for the terminal-state exit path that #466 introduced but wasn't covered — Failed phase should exit immediately (no timeout wait) with the `logs --follow` and `status` recovery hints in both branches of the terminal-state check. Also extended runCli() with an optional extraEnv param to pass NEMOCLAW_CONNECT_TIMEOUT cleanly. The `status` subcommand's recovery-hint assertion is unchanged: `status` still exits on non-Ready phases; #466 only changed `connect`. Verified: - `npm test` — 2061 passed, 12 skipped (was failing on these 3 files against main post-#466). - Targeted run on the three files: 13 tests, 13 passed.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThree test files updated to enhance mock output for the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
## Summary Fixes the lingering `sandbox-stuck-recovery.test.ts > connect times out with guidance when sandbox is stuck in Provisioning` failure on `wsl-e2e` that has been red on `main` since #466 merged. My earlier #2198 fixed the sibling tests but this one kept hitting the CI test-budget ceiling. Fixes #2204. ## Root cause Not a mock-script bug — the mocks for `sandbox list` already return the phase string that `parseSandboxStatus` expects, and the tests pass cleanly on macOS and the Linux `checks` job. The failure is WSL-specific timing: - `NEMOCLAW_EXEC_TIMEOUT=30000` caps each outer `spawnSync` to the CLI at 30 seconds. - WSL process-spawn overhead is high: each mocked `openshell` invocation is a fresh Node.js child process, and the CLI makes 4+ of these (`sandbox get`, `policy get --full`, `inference get`, first `sandbox list`) before the readiness poll loop from #466 starts. - The 3 sibling tests in `sandbox-stuck-recovery.test.ts` that skip the poll loop were passing at **26–28s** on WSL — already within a few seconds of the ceiling. - The failing test is the only one that sets `NEMOCLAW_CONNECT_TIMEOUT=3`, so it actually enters the poll loop (pre-poll + 3s sleep + final poll + "Timed out" print). That pushes total runtime past 30s on WSL runners, so the outer `spawnSync` kills the CLI before the "Timed out" guidance prints. The `Status: unknown` artifact mentioned in #2204 is the CLI's display fallback `parseSandboxStatus(poll, ...) || "unknown"` kicking in after the child was killed mid-poll — not a missing subcommand in the mocks. ## Changes - `.github/workflows/wsl-e2e.yaml`: bump `NEMOCLAW_EXEC_TIMEOUT` from `30000` to `60000`, aligned with the existing `NEMOCLAW_TEST_TIMEOUT=60000`. Short comment explains why WSL needs the larger ceiling. ## Why this is the right fix - **Zero impact on fast runners.** Tests that finish in a few seconds on macOS/Linux return early; they don't pay for the larger ceiling. - **No product-code change.** Only the WSL CI outer-spawn budget moves. - **Targeted to the actual bottleneck.** The CLI isn't hanging — it's slow on WSL spawn. Bumping the budget matches the structural overhead. ## Considered and rejected - **Patching the mocks** (the #2204 hypothesis). No new subcommand is invoked; the mocks are correct. - **Reducing pre-poll overhead in product code** (e.g. skipping `policy get --full` on connect). Out of scope, risks regressing real behavior. - **Dropping `NEMOCLAW_CONNECT_TIMEOUT` from the test.** The test asserts timeout behavior — it must enter the poll. - **Bumping `macos-e2e`.** Not needed; those jobs pass comfortably. ## Type of Change - [x] Code change (bug fix — CI config only) ## Verification - [x] Local \`npx vitest run test/sandbox-stuck-recovery.test.ts test/sandbox-connect-inference.test.ts --project cli\` — 7/7 pass in 7.6s - [x] \`npx prek run --files .github/workflows/wsl-e2e.yaml\` — clean - [ ] **Real validation: this PR's \`wsl-e2e\` check must go green.** ## AI Disclosure - [x] AI-assisted — tool: Claude Code 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Improved Windows Subsystem for Linux (WSL) test reliability by adjusting execution timeout settings to account for system overhead. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Prekshi Vyas <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
PR #466 (merged today at 19:01 UTC) changed
nemoclaw <name> connectto pollopenshell sandbox listfor readiness instead of exiting immediately when the sandbox phase isn't Ready. Three pre-existing test files still encoded the old behavior and are now failing on every PR rebased onto main — including post-merge CI on main itself.Observable in CI by:
test/sandbox-connect-inference.test.ts— 2 assertions expectingresult.status === 0getnull(child process hits 15s spawnSync timeout)test/sandbox-stuck-recovery.test.ts— 2 failures (same timeout symptom + stale message assertions)test/reboot-identity-drift.test.ts— 4 failures (same timeout symptom)Root cause
The fake
openshellbinaries in these tests emitsandbox listoutput with only a name column:The new readiness poll (src/nemoclaw.ts) calls
parseSandboxStatus(output, name)which needs[name, status, age]columns to extract a status. With only a name, it returnsnull→ loop treats as"unknown"→ polls until the test's spawnSync timeout kills the child.Changes
1.
sandbox listmocks updated in all three files to emit a proper status column.sandbox-connect-inference.test.tsandreboot-identity-drift.test.tsalways return"${name} Ready 2m ago"(they test the happy path).sandbox-stuck-recovery.test.tsuses the parameterized${phase}itssetupFixturealready accepts.2.
sandbox-stuck-recovery.test.ts: "stuck in Provisioning" test rewritten for the new behavior.The old assertions checked for
"stuck in 'Provisioning' phase"+"process crash inside the sandbox"+"rebuild --yes"— messages that came fromensureLiveSandboxOrExit's non-Ready branch. #466 bypasses that forconnectvia{ allowNonReadyPhase: true }, so those messages no longer fire. New assertions:NEMOCLAW_CONNECT_TIMEOUT=3via newextraEnvparam onrunCliso the readiness poll times out in 3s instead of 120s"Waiting for sandbox '…' to be ready"+"Timed out"+"NEMOCLAW_CONNECT_TIMEOUT"override hint3.
sandbox-stuck-recovery.test.ts: companion test added for the terminal-state exit path that #466 introduced but lacked a behavioral test. Failed phase should exit immediately withlogs --followandstatusrecovery hints (covers the second branch of the TERMINAL check).The
statussubcommand test insandbox-stuck-recovery.test.tsis untouched —statusstill exits on non-Ready phases; #466 only changedconnect.Testing
npx vitest run test/reboot-identity-drift.test.ts test/sandbox-stuck-recovery.test.ts test/sandbox-connect-inference.test.ts→ 13 passednpm test→ 2061 passed, 12 skipped (was 4 failing on main post-fix(connect): add readiness poll with timeout before connecting (Fixes #430) #466)Type of Change
Checklist
Signed-off-by: Prekshi Vyas [email protected]
Summary by CodeRabbit