Skip to content

test(cli): reduce slow test hotspots - #8715

Merged
cv merged 4 commits into
mainfrom
codex/reduce-slow-cli-tests
Aug 10, 2026
Merged

test(cli): reduce slow test hotspots#8715
cv merged 4 commits into
mainfrom
codex/reduce-slow-cli-tests

Conversation

@cv

@cv cv commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Replace redundant full CLI fixtures in the slowest test cases with focused source tests. Retain spawned-CLI checks for interactive cancellation and the LangChain Deep Agents Code HTTP 401 failure path, plus real boundaries for local Ollama sandbox connection, public OpenClaw runtime inspection, and aggregate BuildKit artifact import. This reduces runtime without changing supported behavior or lowering coverage for the affected source modules.

Related Issue

Fixes #8669.

Changes

  • Move rebuild agent selection, stale recovery, credential preflight, and Shields window coverage to focused source tests.
  • Split WSL inference routing into host-selection and route-lifecycle tests while retaining the sandbox connection boundary.
  • Reuse the pinned OpenClaw runtime with read-only fixture mounts and retain a public runtime-inspection command.
  • Build one aggregate reviewed-runtime target per OpenClaw and Hermes context, compare all four artifacts byte for byte, and require the exact third-party-license copy.
  • Inspect and compose 257 current managed MCP policies without dropping entries, and remove the deleted slow-test timing hint.

Performance Evidence

The before values come from the issue's 8-shard baseline run 31348939543. Run 31375057176 recorded the after values in the cli-vitest-results artifact for the commit under review, 5d417b39c. Split rows sum the named replacement assertions.

Rank Before After Contract and boundary
1 32.971 s 0.018 s Split Shields window selection, notice, and relock controls into focused tests.
2 21.264 s 0.016 s Preserve Hermes registry-target selection after OpenClaw onboarding.
3 19.702 s 0.014 s Preserve stale-recreate rollback and retryable registry metadata.
4 19.662 s 38.970 s Retain public openclaw plugins inspect --runtime --json. The runtime check covers the executable, generated configuration, and plugin loader. Keep the direct managed Google Gemini routing and tool-round assertion separate.
5 18.967 s 4.046 s Split WSL host order and route lifecycle; retain one local Ollama CLI and sandbox-connect process boundary.
6 17.037 s 0.019 s Move exported Hermes API key registration and redaction to a focused source test; retain CLI cancellation and nonzero exit behavior.
7 14.959 s 7.324 s Retain one aggregate BuildKit import because generated Dockerfiles and byte-for-byte artifacts are the contract.
8 14.837 s 12.853 s Retain the complete Shields state-model source boundary.
9 14.681 s 12.163 s Retain the real Shields snapshot, policy, unlock, and persistence flow.
10 13.844 s 0.061 s Preserve OpenClaw registry-target selection after Hermes onboarding.

The issue total fell from 187.924 seconds to 75.484 seconds: 112.440 seconds, or 59.8%, lower. The same 12-shard method measured 175.351 seconds in pre-change run 31367710334. Its cli-vitest-results artifact records the comparison data. The selected tests on the commit under review took 99.867 seconds less, a reduction of 57.0%. Each merged 12-shard artifact records every test duration, so the ranking can be refreshed without reading job logs.

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)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: This changes tests, test support, and one CI timing hint. It does not change a supported product surface.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: Independent Codex Desktop review covered all nine security categories and reported no findings.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Documentation Writer Review

  • Documentation writer subagent reviewed the completed changes
  • Result: no-docs-needed
  • Evidence: Reviewed all 19 paths through 5d417b39c and the updated PR body. The commits change tests, test harnesses, and one CI timing hint. They do not change user-facing behavior or documentation source. No blocking wording findings remain.
  • Agent: Codex Desktop

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit: Not applicable
  • Station profile/scenario: Not applicable; scripts/prepare-dgx-station-host.sh is unchanged.
  • Result: Not applicable
  • Supporting evidence: Not applicable

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run validate:pr passed after refreshing origin/main when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification: The 16-file focused Vitest selection passed 249 tests with one environment-gated skip; shuffle seed 8669 passed the same set; leak diagnostics passed all assertions. The final npx vitest run --project integration test/sandbox-build-context.test.ts --maxWorkers=1 run passed 15 tests with one environment-gated skip. The review repairs initially passed 104 focused source tests and 9 integration tests. After main advanced, the 119 affected focused source tests and all 8 Shields-window integration cases passed again. Biome and the 2,268-file test-conditional scan passed.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result: PR CI run 31375057176 passed all 12 CLI shards and the aggregate cli-tests gate on commit 5d417b39c.
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run 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: Carlos Villela cvillela@nvidia.com

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv cv self-assigned this Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds focused Ollama, rebuild, Shields, MCP policy, BuildKit, and OpenClaw runtime test coverage. It replaces several end-to-end fixtures with shared harnesses and removes one deleted test’s timing entry.

Changes

Sandbox and runtime test coverage

Layer / File(s) Summary
Ollama route discovery and repair
src/lib/inference/local.test.ts, src/lib/actions/sandbox/connect-route-lifecycle.test.ts, test/support/connect-flow-test-harness.ts, test/sandbox-connect-inference/route-swap-repair.test.ts
Tests cover WSL host fallback, probe-only route repair, provider health probing, DNS proxy setup, and connect output.
Rebuild-flow harness and recovery coverage
test/helpers/rebuild-flow-test-harness.ts, test/helpers/rebuild-flow-test-support.ts, src/lib/actions/sandbox/rebuild-flow-credential-preflight.test.ts, test/rebuild-credential-preflight.test.ts, test/rebuild-stale-recovery.test.ts, test/repro-2201.test.ts
The harness models Hermes provider registration. Rebuild tests cover credential preflight, stale recovery, registry synchronization, messaging-plan cleanup, and custom Dockerfile forwarding.
Shields lifecycle and MCP policy coverage
src/lib/actions/sandbox/rebuild-flow-shields-window.test.ts, src/lib/actions/sandbox/rebuild-shields-phase.test.ts, test/rebuild-shields-window.test.ts, src/lib/shields/flow.test.ts, src/lib/shields/mcp-policy-transition.test.ts, ci/cli-test-timing-hints.json
Tests cover Shields window and relock behavior, managed MCP policy reconciliation, and cleanup of timing data for the deleted auto-unlock test.
Runtime compatibility and reviewed artifacts
test/openclaw-gemini-inference-compat-runtime.test.ts, test/sandbox-build-context.test.ts
Runtime validation stages the plugin into a pinned container. BuildKit validation checks combined reviewed-runtime artifacts, licenses, and plugin files.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: refactor, area: ci, area: e2e, area: sandbox, area: onboarding

Suggested reviewers: jyaunches

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Linked Issues check ✅ Passed The changes replace slow fixtures with focused tests while preserving required process, Docker, BuildKit, and runtime coverage [#8669].
Out of Scope Changes check ✅ Passed The changes remain within the issue scope by optimizing slow CLI tests and preserving or relocating their behavior coverage.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: reducing slow CLI test hotspots through focused test coverage and fixture simplification.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/reduce-slow-cli-tests

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

@github-code-quality

github-code-quality Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit 5d417b3 in the codex/reduce-slow-cl... branch remains at 96%, unchanged from commit bf81b95 in the main branch.

TypeScript / code-coverage/cli

The overall coverage in commit 5d417b3 in the codex/reduce-slow-cl... branch remains at 82%, unchanged from commit bf81b95 in the main branch.

Show a code coverage summary of the most impacted files.
File main bf81b95 codex/reduce-slow-cl... 5d417b3 +/-
src/lib/onboard...icy-tier-env.ts 82% 45% -37%
src/lib/actions...e-classifier.ts 75% 69% -6%
src/lib/onboard...mo-lifecycle.ts 88% 84% -4%
src/lib/onboard...age/contract.ts 93% 89% -4%
src/lib/adapter...et-authority.ts 82% 79% -3%
src/lib/actions...flow-helpers.ts 89% 87% -2%
src/lib/inference/local.ts 81% 82% +1%
src/lib/actions...ateway-state.ts 77% 79% +2%
src/lib/policy/...ne-exclusion.ts 87% 92% +5%
src/lib/actions...al-preflight.ts 63% 81% +18%

Updated August 10, 2026 09:42 UTC

@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: 5

🧹 Nitpick comments (1)
test/openclaw-gemini-inference-compat-runtime.test.ts (1)

28-46: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Replace compiled-bundle discovery with a versioned runtime adapter.

ROUTING_PROBE scans dist for hashed chunks, reads source text, and finds exports by function name. It also imports private loader, resolver, and transport paths. Packaging changes can break the test without changing behavior. Use a supported OpenClaw entrypoint for observable assertions. If none exists, isolate the pinned-version imports behind one compatibility adapter.

🤖 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/openclaw-gemini-inference-compat-runtime.test.ts` around lines 28 - 46,
Replace the dist-directory scan and function-name lookup around
refreshPluginRegistry with a versioned runtime adapter that uses OpenClaw’s
supported entrypoint for the observable routing assertions. Keep all
pinned-version loader, resolver, and transport imports inside that single
adapter, and update ROUTING_PROBE to call the adapter without depending on
hashed chunks or private paths.

Source: Path instructions

🤖 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 `@src/lib/actions/sandbox/connect-route-lifecycle.test.ts`:
- Around line 101-104: Update the test using createConnectHarness so the
local-provider health path executes the real probe implementation instead of the
mock’s unconditional { ok: true } result. Configure the harness or add a focused
case that exercises skipOllamaAuthProxySubprobe: true, while preserving
assertions that the local probe receives this option and
probeOllamaAuthProxyHealth is not called.

In `@src/lib/actions/sandbox/rebuild-flow-credential-preflight.test.ts`:
- Around line 570-584: The test should also verify registration order: compare
registerHermesInferenceProviderSpy.mock.invocationCallOrder with
backupSandboxStateSpy.mock.invocationCallOrder and assert the Hermes
registration call occurs first, while preserving the existing call and logging
assertions.

In `@src/lib/inference/local.test.ts`:
- Around line 131-141: Update the findReachableOllamaHost test to capture each
probe command and assert that every command includes --connect-timeout 3 and
--max-time 5, while preserving the existing endpoint order assertions.

In `@test/rebuild-credential-preflight.test.ts`:
- Around line 10-18: Restore a process-boundary test in the credential-preflight
suite that invokes bin/nemoclaw.js through the existing process-execution setup
and verifies a nonzero exit status when preflight fails. Keep the focused
rebuildSandbox test, but add back separate CLI exit coverage for this failure
path using the existing timeout and filesystem helpers.

In `@test/rebuild-shields-window.test.ts`:
- Around line 23-29: Add an afterEach hook in the “rebuild Shields window” test
suite that calls vi.restoreAllMocks(), ensuring the console spies created in
beforeEach are restored after every test while preserving the existing mock
reset behavior.

---

Nitpick comments:
In `@test/openclaw-gemini-inference-compat-runtime.test.ts`:
- Around line 28-46: Replace the dist-directory scan and function-name lookup
around refreshPluginRegistry with a versioned runtime adapter that uses
OpenClaw’s supported entrypoint for the observable routing assertions. Keep all
pinned-version loader, resolver, and transport imports inside that single
adapter, and update ROUTING_PROBE to call the adapter without depending on
hashed chunks or private paths.
🪄 Autofix

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: 0194361c-6e35-4e0c-a77c-408a80904112

📥 Commits

Reviewing files that changed from the base of the PR and between 3ac3a77 and 1a696d9.

📒 Files selected for processing (19)
  • ci/cli-test-timing-hints.json
  • src/lib/actions/sandbox/connect-route-lifecycle.test.ts
  • src/lib/actions/sandbox/rebuild-flow-credential-preflight.test.ts
  • src/lib/actions/sandbox/rebuild-flow-shields-window.test.ts
  • src/lib/actions/sandbox/rebuild-shields-phase.test.ts
  • src/lib/inference/local.test.ts
  • src/lib/shields/flow.test.ts
  • src/lib/shields/mcp-policy-transition.test.ts
  • test/helpers/rebuild-flow-test-harness.ts
  • test/helpers/rebuild-flow-test-support.ts
  • test/openclaw-gemini-inference-compat-runtime.test.ts
  • test/rebuild-credential-preflight.test.ts
  • test/rebuild-shields-auto-unlock.test.ts
  • test/rebuild-shields-window.test.ts
  • test/rebuild-stale-recovery.test.ts
  • test/repro-2201.test.ts
  • test/sandbox-build-context.test.ts
  • test/sandbox-connect-inference/route-swap-repair.test.ts
  • test/support/connect-flow-test-harness.ts
💤 Files with no reviewable changes (2)
  • test/rebuild-shields-auto-unlock.test.ts
  • ci/cli-test-timing-hints.json

Comment thread src/lib/actions/sandbox/connect-route-lifecycle.test.ts
Comment thread src/lib/actions/sandbox/rebuild-flow-credential-preflight.test.ts
Comment thread src/lib/inference/local.test.ts
Comment thread test/rebuild-credential-preflight.test.ts
Comment thread test/rebuild-shields-window.test.ts
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings reported

Advisor assessment: No blocking advisor findings reported
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Failed after a partial review · low confidence · 0 blockers · 0 warnings · 0 suggestions

Second-opinion terminology and E2E selections are advisory. Live E2E does not run automatically for pull requests.

2 semantic terminology decisions

Terminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.

  • justified — rebuild Shields window at src/lib/actions/sandbox/rebuild-flow-shields-window.test.ts:21: Keep `rebuild Shields window` when the rebuild-specific controls are relevant; use `shields-down window` for the general bounded state.
  • justified — reviewed runtime artifacts at test/sandbox-build-context.test.ts:963: Keep `reviewed runtime artifacts` when referring to the imported outputs; use `reviewed runtime bundle` for the source bundle.

E2E guidance

Advisory only. A maintainer can dispatch the default E2E suite against this exact revision.

Recommended E2E: None

4 optional E2E recommendations
  • rebuild-openclaw
  • shields-config
  • inference-routing
  • openclaw-plugin-runtime-exdev

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@copy-pr-bot

copy-pr-bot Bot commented Aug 10, 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.

@cv
cv merged commit b414e22 into main Aug 10, 2026
98 of 99 checks passed
@cv
cv deleted the codex/reduce-slow-cli-tests branch August 10, 2026 09:59
@wscurran wscurran added chore Build, CI, dependency, or tooling maintenance area: ci CI workflows, checks, release automation, or GitHub Actions labels Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci CI workflows, checks, release automation, or GitHub Actions chore Build, CI, dependency, or tooling maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: reduce slow CLI test hotspots

2 participants