Repository navigation
fix: standardize timeout/gtimeout handling - #2162
Conversation
#2149) ## Summary Fix 4 nightly failures in `test/e2e/test-network-policy.sh` caused by PR #2070 changing `nemoclaw policy-add` to require a preset name in non-interactive mode. ## Related Issue Fixes #2148 ## Changes - **Replace expect-based preset application with direct CLI calls:** `apply_preset` now calls `nemoclaw <sandbox> policy-add <preset> --yes` directly instead of capturing the interactive list, grepping for a number, and automating prompts with `expect`. This works with the new non-interactive mode from #2070. - **Add interactive mode coverage (TC-NET-03):** New `apply_preset_interactive` function unsets `NEMOCLAW_NON_INTERACTIVE` and uses `expect` to exercise the interactive prompt path. TC-NET-03 tries interactive first, falls back to non-interactive. Both CLI code paths are now tested. - **Fix TC-NET-03 reachability assertion:** After applying the telegram preset, `api.telegram.org` returns HTTP 403 (unauthenticated — no bot token). This is correct: the proxy lets the request through, Telegram rejects the bare request. Changed assertion to accept any HTTP status (2xx-4xx) as "reachable" — only `ERROR_` responses (proxy blocks) count as failure. - **Remove expect as hard dependency:** `expect` is installed with a warning if missing (only needed for TC-NET-03 interactive test). Non-interactive tests work without it. ## Type of Change - Code change (feature, bug fix, or refactor) ## Verification - `npx prek run --all-files` passes - Tests added or updated for new or changed behavior - No secrets, API keys, or credentials committed - Verified on CI: 10/10 PASS on ubuntu-latest ## AI Disclosure - AI-assisted — tool: Cursor --- Signed-off-by: Truong Nguyen <[email protected]> Made with [Cursor](https://cursor.com) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Tests now tolerate missing interactive tooling and log a warning instead of aborting. * Added non-interactive and interactive preset-application flows with automatic fallback when interactive tooling is unavailable. * Simplified one preset workflow to a direct dry-run path that checks for "would be opened" output. * Improved result classification to better distinguish success, proxy-blocked, and unexpected responses. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Truong Nguyen <[email protected]> Co-authored-by: Carlos Villela <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughDetects an available Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@test/e2e/test-inference-routing.sh`:
- Around line 40-49: Introduce a small wrapper function (e.g., timeout_run) that
checks NEMOCLAW_E2E_NO_TIMEOUT and whether TIMEOUT_CMD is non-empty and then
either prefixes the invocation with "$TIMEOUT_CMD" -s TERM "$TIMEOUT_SECONDS" or
runs the command directly; replace all direct expansions of $TIMEOUT_CMD in the
script with calls to this wrapper so every timed invocation uses the safe,
quoted execution path and the wrapper forwards arguments and preserves exit
status (search for usages of TIMEOUT_CMD in the file to update every call).
In `@test/e2e/test-sandbox-operations.sh`:
- Around line 30-38: The bypass leaves TIMEOUT_CMD empty so callsites using the
pattern "$TIMEOUT_CMD <seconds> ..." end up running "<seconds> ..." and fail;
fix by ensuring TIMEOUT_CMD is always a callable (either the real timeout binary
or a small shell function) — e.g., define a NOOP_TIMEOUT_CMD function (name
referenced as NOOP_TIMEOUT_CMD) that accepts the seconds arg, shifts it off and
then execs the remaining command, and set TIMEOUT_CMD to that function whenever
NEMOCLAW_E2E_NO_TIMEOUT=1 or no timeout binary is found; update the wrapper
logic around TIMEOUT_CMD/TIMEOUT_SECONDS (symbols TIMEOUT_CMD,
NEMOCLAW_E2E_NO_TIMEOUT, TIMEOUT_SECONDS) so downstream "$TIMEOUT_CMD <seconds>
..." invocations continue to work safely.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3ae8cb79-2b75-4260-a329-46e818728533
📒 Files selected for processing (10)
test/e2e/test-deployment-services.shtest/e2e/test-double-onboard.shtest/e2e/test-inference-routing.shtest/e2e/test-network-policy.shtest/e2e/test-onboard-resume.shtest/e2e/test-sandbox-operations.shtest/e2e/test-sandbox-survival.shtest/e2e/test-shields-config.shtest/e2e/test-skip-permissions-policy.shtest/e2e/test-token-rotation.sh
|
✨ Thanks for submitting this PR that proposes a fix for an issue with NemoClaw scripts crashing on macOS — the changes and test plan will help us review this further. Related open issues: Possibly related open issues: |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
test/e2e/test-network-policy.sh (1)
53-56: Consider makingrun_with_timeouthonor the explicit no-timeout bypass flag.Right now, if
NEMOCLAW_E2E_NO_TIMEOUT=1is set and a timeout binary exists, per-call timeouts still apply. If the intent is “disable all timeouts,” gate on the flag inside the helper too.♻️ Proposed tweak
run_with_timeout() { local seconds="$1" shift - if [ -n "$TIMEOUT_CMD" ]; then + if [ "${NEMOCLAW_E2E_NO_TIMEOUT:-0}" = "1" ] || [ -z "$TIMEOUT_CMD" ]; then + "$@" + else "$TIMEOUT_CMD" "$seconds" "$@" - else - "$@" fi }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/e2e/test-network-policy.sh` around lines 53 - 56, The helper run_with_timeout currently calls "$TIMEOUT_CMD" if set, ignoring the global NEMOCLAW_E2E_NO_TIMEOUT flag; update run_with_timeout to first check if NEMOCLAW_E2E_NO_TIMEOUT is set/non-empty and, when true, run the command directly with "$@" (bypassing any timeout binary) otherwise preserve the existing behavior of using TIMEOUT_CMD when available; refer to the variables and helper name run_with_timeout, TIMEOUT_CMD and NEMOCLAW_E2E_NO_TIMEOUT to locate the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@test/e2e/test-token-rotation.sh`:
- Around line 38-48: The script reduces the default TIMEOUT_SECONDS to 900
causing flaky runs; update the TIMEOUT_SECONDS assignment so it uses the
standardized 1800-second default (respecting NEMOCLAW_E2E_TIMEOUT_SECONDS if
set) instead of 900. Edit the TIMEOUT_SECONDS line in test-token-rotation.sh to
set the default to 1800 and keep the existing logic that honors
NEMOCLAW_E2E_TIMEOUT_SECONDS and NEMOCLAW_E2E_NO_TIMEOUT unchanged.
- Around line 50-61: The run_with_timeout helper incorrectly honors the
NEMOCLAW_E2E_NO_TIMEOUT bypass because it checks TIMEOUT_CMD first; change
run_with_timeout to first check whether NEMOCLAW_E2E_NO_TIMEOUT is set/true and,
if so, run the command directly, otherwise detect TIMEOUT_CMD and use it;
alternatively introduce an internal flag (e.g., USE_TIMEOUT or
WRAPPED_BY_TIMEOUT) that is set only when you actually wrap the call so
subsequent invocations respect the user bypass — update the run_with_timeout
function and any places that set/inspect TIMEOUT_CMD to use the new order/flag
(referencing run_with_timeout, TIMEOUT_CMD, and NEMOCLAW_E2E_NO_TIMEOUT).
---
Nitpick comments:
In `@test/e2e/test-network-policy.sh`:
- Around line 53-56: The helper run_with_timeout currently calls "$TIMEOUT_CMD"
if set, ignoring the global NEMOCLAW_E2E_NO_TIMEOUT flag; update
run_with_timeout to first check if NEMOCLAW_E2E_NO_TIMEOUT is set/non-empty and,
when true, run the command directly with "$@" (bypassing any timeout binary)
otherwise preserve the existing behavior of using TIMEOUT_CMD when available;
refer to the variables and helper name run_with_timeout, TIMEOUT_CMD and
NEMOCLAW_E2E_NO_TIMEOUT to locate the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0760ceaf-1627-4237-b93c-d96378c7b806
📒 Files selected for processing (2)
test/e2e/test-network-policy.shtest/e2e/test-token-rotation.sh
…sh (#2368) # Summary Centralize the duplicated timeout/gtimeout detection, self-wrap, and run_with_timeout() code from 10 E2E test scripts into a single shared helper (test/e2e/e2e-timeout.sh). PR #2162 introduced ~31 identical lines in every script; this extracts them into one place and replaces each copy with a 4-line source stanza, removing ~210 lines of boilerplate with no behavioral changes. # Related Issue Follow-up to #2162. # Changes - New file test/e2e/e2e-timeout.sh — shared helper containing: - timeout / gtimeout binary detection - Self-wrap logic (exec $TIMEOUT_CMD -s TERM … "$0" "$@") gated on NEMOCLAW_E2E_TIMEOUT_WRAPPED - Fail-fast with exit 127 and remediation guidance when neither binary is found - run_with_timeout() per-command helper - Updated 10 E2E scripts to source the helper instead of inlining the block: - test-deployment-services.sh (default 3600s) - test-double-onboard.sh (900s) - test-inference-routing.sh (1200s) - test-network-policy.sh (3600s) - test-onboard-resume.sh (600s) - test-sandbox-operations.sh (1800s) - test-sandbox-survival.sh (900s) - test-shields-config.sh (900s) - test-skip-permissions-policy.sh (900s) - test-token-rotation.sh (2400s) - Each script sets export NEMOCLAW_E2E_DEFAULT_TIMEOUT=<seconds> before sourcing, preserving per-script defaults - All environment knobs unchanged: NEMOCLAW_E2E_NO_TIMEOUT, NEMOCLAW_E2E_TIMEOUT_SECONDS, NEMOCLAW_E2E_TIMEOUT_WRAPPED - Used SCRIPT_DIR_TIMEOUT to avoid collisions with existing SCRIPT_DIR variables # Type of Change - Code change (feature, bug fix, or refactor) # Verification - npx prek run --all-files passes - npm test passes - Tests added or updated for new or changed behavior - No secrets, API keys, or credentials committed # AI Disclosure - AI-assisted — tool: Claude Code ──────────────────────────────────────────────────────────────────────────────── Signed-off-by: Brandon Pelfrey <[email protected]> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Extracted timeout management logic from multiple end-to-end test scripts into a centralized shared utility module. This consolidates platform-specific timeout command detection, configuration handling, and helper utility functions to eliminate code duplication and ensure consistent, reliable timeout behavior across all test suites and environments. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Standardize the
timeout/gtimeoutdetection preamble across all 10 e2e test scripts. Fixes a hard crash on macOS without GNU coreutils (exec: timeout: not found) by detecting both binaries up-front, failing fast with actionable remediation when neither is available, and consolidating ad-hoc per-file patterns into a single shared shape.Related Issue
Closes #2160
Changes
timeout/gtimeoutdetection above the self-wrap block soTIMEOUT_CMDis set on every invocation — including the re-execed run afterexec timeout … "$0" "$@". Previously the variable was scoped inside the wrap block; on the re-execed run it was unset, causingset -ucrashes (test-sandbox-operations.sh,test-inference-routing.sh) or silent loss of per-call timeouts (test-network-policy.sh,test-deployment-services.sh).timeoutnorgtimeoutis available, instead of crashing withexec: not foundor silently dropping the timeout protection:Type of Change
Verification
npx prek run --all-filespassesnpm testpassesSigned-off-by: Hung Le [email protected]
Summary by CodeRabbit