Skip to content

test(e2e): channels add/remove lifecycle - #3673

Closed
hunglp6d wants to merge 15 commits into
mainfrom
test/e2e-channels-add-remove
Closed

test(e2e): channels add/remove lifecycle#3673
hunglp6d wants to merge 15 commits into
mainfrom
test/e2e-channels-add-remove

Conversation

@hunglp6d

@hunglp6d hunglp6d commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add Test 2 from #3462 — end-to-end coverage for the onboard empty → channels add → channels remove lifecycle. The test asserts against the baked sandbox image (openclaw.json) and the gateway (provider attachment, policy presets) so regressions cannot hide behind a correct host-side registry. Companion to Test 1 (test-channels-stop-start.sh) shipped via #3532.

Related Issue

Closes #3462

Changes

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

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
  • Docs updated for user-facing behavior changes
  • make docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Hung Le hple@nvidia.com

Summary by CodeRabbit

  • Tests

    • Added a comprehensive end-to-end test covering add→rebuild→remove→rebuild lifecycle for the Telegram channel, including egress checks and pass/fail summary.
    • Adds 44 new parity assertions tracking lifecycle, readiness, wiring, presets, rebuild outcomes, and egress behavior (marked deferred).
  • Documentation

    • Updated parity map/inventory to include the new test entry and aggregate totals.

Review Change Stack

@copy-pr-bot

copy-pr-bot Bot commented May 18, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 53407805-787f-4d9d-8823-e83ef0a30856

📥 Commits

Reviewing files that changed from the base of the PR and between 105d8f5 and 9f2e6e2.

📒 Files selected for processing (1)
  • test/e2e/test-channels-add-remove.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/e2e/test-channels-add-remove.sh

📝 Walkthrough

Walkthrough

Added a new end-to-end test script exercising the Telegram channel add/remove lifecycle in an empty sandbox, with supporting parity-tracking YAML and JSON files documenting 44 new assertions covering prerequisites, baseline absence, add+rebuild, egress validation via L7 proxy, removal, and cleanup.

Changes

Telegram Channel Add/Remove E2E Test

Layer / File(s) Summary
Parity test mapping and inventory
test/e2e/docs/parity-map.yaml, test/e2e/docs/parity-inventory.generated.json
Introduces a new test mapping entry for test-channels-add-remove.sh with scenario/bucket metadata and 44 new assertions (C0–C6c) all marked deferred pending scenario-framework migration. Aggregate test totals updated: scripts 52 → 53, assertions 2040 → 2084.
E2E test script: setup and helpers
test/e2e/test-channels-add-remove.sh (setup, line 1–185)
Bash test initialization with strict settings, global pass/fail/skip counters, result/format/summary helpers, environment setup (repo root, sandbox defaults, teardown registration), and reusable helper functions: sandbox_exec for SSH-backed command execution, openclaw_has_telegram for JSON parsing, print_policy_list for policy snapshots, run_rebuild_with_live_log for parallel log tailing, and telegram_egress_open for in-sandbox HTTP probe classification.
E2E test script: lifecycle phases
test/e2e/test-channels-add-remove.sh (phases, line 187–453)
Six sequential test phases: Phase 0 validates NVIDIA_API_KEY and NEMOCLAW_NON_INTERACTIVE environment; Phase 1 provisions sandbox via install.sh; Phase 2 asserts Telegram baseline absence; Phase 3 runs nemoclaw channels add telegram with rebuild; Phase 4 verifies telegram preset applied, channel block in openclaw.json, provider wired, and egress to Telegram API succeeds; Phase 5 runs nemoclaw channels remove telegram with rebuild; Phase 6 verifies Telegram fully removed from all three signals (policy, baked image, gateway) and prints a final summary.

Sequence Diagram(s)

N/A — This is a test script verifying existing functionality; no new API flows or multi-component interactions are being introduced.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • NVIDIA/NemoClaw#3452: The main PR’s new e2e “channels add/remove” Telegram lifecycle assertions (including verifying the telegram preset is applied after add+rebuild and probing egress to api.telegram.org) directly cover the exact behavior fixed in the retrieved PR.
  • NVIDIA/NemoClaw#3448: Both PRs touch the channels add/remove flow for the telegram channel; this test exercises the same add→rebuild→remove behavior validated by that PR.

Suggested labels

NemoClaw CLI, enhancement: messaging

Suggested reviewers

  • cv

Poem

🐰 I hopped into a sandbox bright,
Added Telegram, watched the logs at night.
A probe to api.telegram made with care,
Then removed the channel, tidy and fair.
Pass or fail, the rabbit cheers—regressions beware!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test(e2e): channels add/remove lifecycle' clearly and specifically summarizes the main change: adding an end-to-end test for the channels add/remove workflow.
Linked Issues check ✅ Passed The PR implements Test 2 from issue #3462, covering the onboard-empty → channels add telegram → verify policy/network/baked image → channels remove → verify cleanup flow with all required assertions.
Out of Scope Changes check ✅ Passed All changes are within scope: the test script, parity documentation updates, and generated inventory reflect only the addition of the channels add/remove lifecycle test.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/e2e-channels-add-remove

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: None
Optional E2E: channels-stop-start-e2e, messaging-providers-e2e

Dispatch hint: channels-stop-start-e2e,messaging-providers-e2e

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • None. No required E2E is recommended because all changed files are E2E test/parity documentation assets. They cannot affect runtime user flows, installer/onboarding behavior, sandbox lifecycle implementation, credentials handling, network policy enforcement, inference routing, or deployment behavior.

Optional E2E

  • channels-stop-start-e2e (high): Optional adjacent confidence for the existing channel lifecycle CI path. It covers the same messaging/provider/policy area, but this PR is tests-only and does not affect product runtime behavior.
  • messaging-providers-e2e (high): Optional adjacent confidence for Telegram/Discord/Slack provider creation, credential isolation, openclaw.json patching, and L7 proxy behavior. Not merge-blocking because the PR only changes E2E test assets.

New E2E recommendations

  • providers-messaging (high): The PR introduces test/e2e/test-channels-add-remove.sh, but .github/workflows/nightly-e2e.yaml does not currently define a dispatchable job for it. Without workflow wiring, this new regression test will not run in CI/nightly selective dispatch.
    • Suggested test: Add a dispatchable nightly workflow job for the new channel add/remove lifecycle test that runs bash test/e2e/test-channels-add-remove.sh with NVIDIA_API_KEY, NEMOCLAW_NON_INTERACTIVE=1, NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1, and the fake Telegram token environment used by the script.

Dispatch hint

  • Workflow: nightly-e2e.yaml
  • jobs input: channels-stop-start-e2e,messaging-providers-e2e

@hunglp6d hunglp6d self-assigned this May 18, 2026
@hunglp6d hunglp6d added E2E VRDC Issues and PRs submitted by NVIDIA VRDC test team. labels May 18, 2026
@hunglp6d
hunglp6d marked this pull request as ready for review May 18, 2026 08:15

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/e2e/test-channels-add-remove.sh`:
- Around line 174-179: The grep pattern in the test (the if condition that
checks "$body" in test/e2e/test-channels-add-remove.sh) wrongly treats the
generic string "fetch failed" as a policy denial; remove "fetch failed" from the
regex (keep explicit tokens like "policy_denied", "engine:ssrf", "forbidden by
policy", and "CONNECT.*40[0-9]") so transient DNS/TCP errors are not classified
as policy rejections and the script only returns 1 for concrete policy-related
signatures.
- Around line 193-198: Add an early validation for the
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE env var similar to the existing
NEMOCLAW_NON_INTERACTIVE check: if [ "${NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE:-}"
!= "1" ]; then call fail "C?: NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 is
required" and print_summary, else call pass "C?:
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 is set"; place this check near the top of
test/e2e/test-channels-add-remove.sh before any long install or setup steps so
the script fails fast (use the same fail, print_summary, and pass helpers as in
the existing block).
- Around line 121-124: The case branch is too permissive because the pattern
"*no*" can match substrings like "not known"; update the parsing of $out (from
openclaw_has_telegram) to normalize and compare exact tokens: trim
leading/trailing whitespace and convert to lowercase, then test explicitly (e.g.
if [ "$out" = "yes" ] return 0; elif [ "$out" = "no" ] return 1; else return 2)
so only exact "yes" or "no" succeed and all other outputs are treated as
unreadable.
🪄 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: Enterprise

Run ID: 209faf8d-58d7-46db-b834-47a723225612

📥 Commits

Reviewing files that changed from the base of the PR and between 32dbdc5 and 105d8f5.

📒 Files selected for processing (3)
  • test/e2e/docs/parity-inventory.generated.json
  • test/e2e/docs/parity-map.yaml
  • test/e2e/test-channels-add-remove.sh

Comment thread test/e2e/test-channels-add-remove.sh Outdated
Comment thread test/e2e/test-channels-add-remove.sh
Comment on lines +193 to +198
if [ "${NEMOCLAW_NON_INTERACTIVE:-}" != "1" ]; then
fail "C0: NEMOCLAW_NON_INTERACTIVE=1 is required"
print_summary
fi
pass "C0: NEMOCLAW_NON_INTERACTIVE=1 is set"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Validate NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 up front.

The script documents this prerequisite but doesn’t enforce it early, which can defer failure into the long install phase.

Suggested fix
 if [ "${NEMOCLAW_NON_INTERACTIVE:-}" != "1" ]; then
   fail "C0: NEMOCLAW_NON_INTERACTIVE=1 is required"
   print_summary
 fi
 pass "C0: NEMOCLAW_NON_INTERACTIVE=1 is set"
+
+if [ "${NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE:-}" != "1" ]; then
+  fail "C0: NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 is required"
+  print_summary
+fi
+pass "C0: NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 is set"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ "${NEMOCLAW_NON_INTERACTIVE:-}" != "1" ]; then
fail "C0: NEMOCLAW_NON_INTERACTIVE=1 is required"
print_summary
fi
pass "C0: NEMOCLAW_NON_INTERACTIVE=1 is set"
if [ "${NEMOCLAW_NON_INTERACTIVE:-}" != "1" ]; then
fail "C0: NEMOCLAW_NON_INTERACTIVE=1 is required"
print_summary
fi
pass "C0: NEMOCLAW_NON_INTERACTIVE=1 is set"
if [ "${NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE:-}" != "1" ]; then
fail "C0: NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 is required"
print_summary
fi
pass "C0: NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 is set"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/e2e/test-channels-add-remove.sh` around lines 193 - 198, Add an early
validation for the NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE env var similar to the
existing NEMOCLAW_NON_INTERACTIVE check: if [
"${NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE:-}" != "1" ]; then call fail "C?:
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 is required" and print_summary, else call
pass "C?: NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 is set"; place this check near
the top of test/e2e/test-channels-add-remove.sh before any long install or setup
steps so the script fails fast (use the same fail, print_summary, and pass
helpers as in the existing block).

cv and others added 10 commits May 18, 2026 17:28
## Summary
Harden the high-reward/low-risk code scanning findings by redacting
logged values, replacing predictable temp/random patterns, and
tightening URL/search validation paths. This targets the first
remediation bucket from the code scanning risk/reward tracker.

## Related Issue
Refs #3654

## Changes
- Add recursive log redaction for JSON command output and remove
credential/env names from user-facing diagnostics.
- Replace `Math.random()` session/temp suffixes with
`crypto.randomUUID()`.
- Move temp config/SSH files into private `mkdtemp` directories and
write service PID files via secured file descriptors.
- Parse Slack and Cloudflare hosts via URL/anchored host validation
instead of broad substring URL checks.
- Sanitize docs search terms before passing user input into Lunr query
strategies.
- Update affected tests for redacted messages and OpenShell error
wording.

## Type of Change
- [x] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Verification
<!-- Check each item you ran and confirmed. Leave unchecked items you
skipped. Doc-only changes do not require npm test unless you ran it. -->
- [ ] `npx prek run --all-files` passes
- Ran twice; the full hook suite reached the CLI test phase but failed
on existing 5s timeout/flaky host-environment tests unrelated to this
patch. Plugin tests passed in the hook output.
- [ ] `npm test` passes
- [x] Tests added or updated for new or changed behavior
- [x] No secrets, API keys, or credentials committed
- [ ] Docs updated for user-facing behavior changes
- [ ] `make docs` builds without warnings (doc changes only)
- [ ] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

Additional checks run:
- [x] `npm run typecheck:cli` passes
- [x] `cd nemoclaw && npm run build` passes
- [x] Targeted Vitest suite passes: `src/lib/security/redact.test.ts`,
`src/lib/adapters/openshell/client.test.ts`,
`src/lib/onboard/summary.test.ts`, `src/lib/onboard/preflight.test.ts`,
`src/lib/tunnel/services.test.ts`,
`src/lib/state/onboard-session.test.ts`,
`src/lib/diagnostics/debug.test.ts`,
`src/lib/actions/dev/npm-link-or-shim.test.ts`,
`test/rebuild-credential-preflight.test.ts`
- [x] `npx vitest run test/nemoclaw-start.test.ts -t "Slack channel
guard"` passes
- [x] `cd nemoclaw && npm test -- src/onboard/config.test.ts` passes

---
<!-- DCO sign-off required by CI. Run: git config user.name && git
config user.email -->
Signed-off-by: Carlos Villela <cvillela@nvidia.com>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Release Notes

* **New Features**
* Enhanced security redaction for sensitive data in logs and JSON output

* **Bug Fixes**
  * Improved detection of Slack-related connection errors
  * Better DNS probing for container connectivity validation

* **Improvements**
* Cleaner onboarding messages that avoid exposing environment variable
names and technical paths
* More secure temporary file and directory handling with restrictive
permissions
* Generic error messages that provide clarity without revealing
sensitive system information
  * Hardened sandbox rebuild logging with automatic redaction

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/NVIDIA/NemoClaw/pull/3657?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Summary

Fixes #3578.

This makes GPU-enabled onboarding recover from a healthy reusable
gateway that was previously started without GPU passthrough, instead of
aborting with a full `nemoclaw uninstall && nemoclaw onboard --gpu`
recovery path.

The recovery is intentionally conservative:

- Reuse is unchanged when GPU is not requested, when the reusable
gateway is already a confirmed Docker-driver gateway, or when a legacy
gateway already has Docker GPU DeviceRequests.
- A CPU-only legacy gateway is automatically retired only when no local
sandboxes are registered, or when `NEMOCLAW_RECREATE_SANDBOX=1` is
recreating the one registered sandbox with the same name.
- If other registered sandboxes depend on the gateway, onboarding still
aborts non-destructively and prints targeted `destroy --cleanup-gateway`
guidance.
- Unknown Docker/container state remains non-destructive.
- `--no-gpu` / `NEMOCLAW_SANDBOX_GPU=0` remain explicit opt-outs; this
does not silently downshift GPU-selected onboarding to CPU.

I also tightened the manual recovery message so the empty-registry
fallback no longer recommends full uninstall first.

## Testing for reviewers

The focused unit coverage exercises the issue decision matrix:

- GPU requested + healthy CPU-only legacy gateway + empty registry =>
restart/recreate path.
- GPU requested + healthy CPU-only legacy gateway + the one registered
sandbox being recreated => restart/recreate path.
- GPU requested + healthy CPU-only legacy gateway + shared/different
registered sandboxes => abort with targeted recovery.
- GPU not requested => reuse path unchanged.
- Confirmed Docker-driver gateway => reuse path unchanged.
- Unknown legacy Docker inspection state => non-destructive abort.
- Empty-registry recovery wording recommends targeted gateway cleanup,
not full uninstall.

Local validation run:

```text
npm run build:cli
npm test -- src/lib/onboard/gateway-gpu-passthrough.test.ts src/lib/onboard/gpu-recovery.test.ts src/lib/onboard/sandbox-gpu-create.test.ts src/lib/onboard/docker-gpu-patch.test.ts
npm run typecheck
npm run source-shape:check
git diff --check
npx prek run --all-files
```

All of the above passed locally.

I did not run live GPU UAT on Ubuntu GPU, DGX Spark, or DGX Station
hardware. That is still the end-to-end validation needed for the exact
reporter scenario: first create a CPU/no-GPU gateway, leave the stale
gateway behind, then rerun GPU-default onboarding with
`NEMOCLAW_RECREATE_SANDBOX=1` and verify the new sandbox gets GPU
access.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Improved GPU passthrough detection and reuse logic to avoid unsafe
reuse and to perform safer restart or abort-with-recovery when needed
* Updated recovery guidance for GPU passthrough issues with clearer
cleanup and re-onboarding instructions

* **New Features**
* Added explicit GPU inspection and decision flow to better handle
legacy gateway GPU states and restart safety checks

* **Tests**
* Expanded and hardened tests around GPU inspection, reuse decisions,
recovery messaging, and CLI timeouts/robustness

* **Chores**
* Hardened pre-commit test hook execution (serialized runs and cleanup
before build)

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/NVIDIA/NemoClaw/pull/3670?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@hunglp6d hunglp6d closed this May 18, 2026
@wscurran wscurran added area: e2e End-to-end tests, nightly failures, or validation infrastructure chore Build, CI, dependency, or tooling maintenance and removed E2E labels Jun 3, 2026
@cv
cv deleted the test/e2e-channels-add-remove branch June 28, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: e2e End-to-end tests, nightly failures, or validation infrastructure chore Build, CI, dependency, or tooling maintenance VRDC Issues and PRs submitted by NVIDIA VRDC test team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(messaging): add E2E coverage for channels stop/start and channels add/remove rebuild flows

4 participants