Skip to content

refactor(e2e): consolidate fake provider protocol utilities - #6368

Merged
cv merged 2 commits into
NVIDIA:mainfrom
jyaunches:refactor/e2e-fake-provider-protocol
Jul 7, 2026
Merged

cv merged 2 commits into
NVIDIA:mainfrom
jyaunches:refactor/e2e-fake-provider-protocol

Conversation

@jyaunches

@jyaunches jyaunches commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Consolidate shared fake-provider HTTP mechanics—request bodies, JSON/SSE responses, and deterministic server listen/close—without changing mock-versus-hosted inference selection (#5745).

Closes #6349
Parent epic: #6346
Related: #5745

Changes

Verification

  • Signed/Verified commit and all hooks passed
  • npm run build:cli
  • npm run typecheck:cli
  • npm run lint
  • Protocol and migrated-helper support tests: 23 passed
  • No production provider behavior or inference-mode policy changed

Signed-off-by: Julie Yaunches [email protected]

Summary by CodeRabbit

  • Tests
    • Added shared HTTP test helpers for reading request bodies, writing JSON responses, and sending SSE streams.
    • Updated end-to-end tests to use the shared helpers for server setup, response handling, and cleanup.
    • Added coverage for HTTP request/response behavior, including JSON and streaming event responses.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Introduces a shared HTTP protocol test-fixture module (test/e2e/fixtures/http-protocol.ts) providing request-body reading, JSON/SSE response writing, and server listen/close helpers. Three existing live e2e test files are refactored to import these helpers instead of duplicating local implementations. A new support test suite validates the fixture.

Changes

HTTP protocol fixture consolidation

Layer / File(s) Summary
New shared HTTP protocol fixture helpers
test/e2e/fixtures/http-protocol.ts
Adds exported readRequestBody, writeJsonResponse, writeSseBody, writeSseEvents, listenServer, and closeServer helpers for HTTP test scaffolding.
Migrate hermes-inference-switch-helpers to shared fixture
test/e2e/live/hermes-inference-switch-helpers.ts
Removes local Server import and SSE/JSON/close implementations; sseResponse and openAiSseResponse now delegate to writeSseEvents.
Migrate mcp-bridge-servers to shared fixture
test/e2e/live/mcp-bridge-servers.ts
Removes local jsonResponse, readRequestBody, closeServer, listenOnRandomPort implementations in favor of imported/aliased fixture functions.
Migrate messaging-compatible-endpoint test to shared fixture
test/e2e/live/messaging-compatible-endpoint.test.ts
Reworks imports, removes local jsonResponse/sseResponse/readRequestBody, and updates startCompatibleMock to use listenServer/closeServer.
Add support test suite for fixture
test/e2e/support/e2e-http-protocol.test.ts
New Vitest suite validating request body reading, JSON responses, and SSE event output including the [DONE] marker.

Estimated code review effort: 2 (Simple) | ~15 minutes

Suggested labels: refactor

Suggested reviewers: brandonpelfrey, ericksoa

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive Core helper extraction and test migrations are present, but [#6349] can't be fully verified for shared-shape parsing and boundary docs from the summary. Provide the full diff or add the missing shared-shape parsing and boundary documentation so the remaining criteria can be confirmed.
✅ 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 concisely matches the main change: consolidating shared E2E protocol utilities.
Out of Scope Changes check ✅ Passed All changes stay within E2E protocol utilities and support tests, with no unrelated production or feature work introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@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.

🧹 Nitpick comments (1)
test/e2e/fixtures/http-protocol.ts (1)

56-72: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Consider defaulting to loopback instead of all interfaces.

listenServer defaults host to "0.0.0.0", binding the test server to every network interface rather than just loopback. For local/CI e2e test servers, 127.0.0.1 is sufficient and reduces exposure (e.g., other hosts/containers on a shared network reaching the ephemeral test port).

🔒 Suggested default
 export async function listenServer(
   server: http.Server,
   port = 0,
-  host = "0.0.0.0",
+  host = "127.0.0.1",
 ): Promise<number> {

If any downstream test genuinely needs cross-container reachability, that call site can pass "0.0.0.0" explicitly.

🤖 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/fixtures/http-protocol.ts` around lines 56 - 72, The listenServer
helper currently defaults the host argument to 0.0.0.0, which binds the test
server to all interfaces instead of loopback. Update the default host in
listenServer so local e2e tests listen on 127.0.0.1 by default, and keep 0.0.0.0
available only when a caller explicitly passes it. Use the listenServer function
signature and its server.listen call to make the change without altering the
port-binding behavior.
🤖 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.

Nitpick comments:
In `@test/e2e/fixtures/http-protocol.ts`:
- Around line 56-72: The listenServer helper currently defaults the host
argument to 0.0.0.0, which binds the test server to all interfaces instead of
loopback. Update the default host in listenServer so local e2e tests listen on
127.0.0.1 by default, and keep 0.0.0.0 available only when a caller explicitly
passes it. Use the listenServer function signature and its server.listen call to
make the change without altering the port-binding behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f1b522d3-785b-4741-96a9-714b8d6a6518

📥 Commits

Reviewing files that changed from the base of the PR and between b435598 and a5e1457.

📒 Files selected for processing (5)
  • test/e2e/fixtures/http-protocol.ts
  • test/e2e/live/hermes-inference-switch-helpers.ts
  • test/e2e/live/mcp-bridge-servers.ts
  • test/e2e/live/messaging-compatible-endpoint.test.ts
  • test/e2e/support/e2e-http-protocol.test.ts

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maintainer review: the shared fake-provider protocol helpers preserve the existing HTTP/SSE contracts and failure semantics with focused E2E coverage. Current-main synchronization cleared the stale growth artifact and the unrelated timeout did not recur; all exact-head checks, DCO, signatures, and review threads are clean.

@cv
cv merged commit d3db55c into NVIDIA:main Jul 7, 2026
37 checks passed
@wscurran wscurran added area: ci CI workflows, checks, release automation, or GitHub Actions area: e2e End-to-end tests, nightly failures, or validation infrastructure integration: hermes Hermes integration behavior refactor PR restructures code without intended behavior change labels Jul 7, 2026
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
)

## Summary

Consolidate shared fake-provider HTTP mechanics—request bodies, JSON/SSE
responses, and deterministic server listen/close—without changing
mock-versus-hosted inference selection (NVIDIA#5745).

Closes NVIDIA#6349
Parent epic: NVIDIA#6346
Related: NVIDIA#5745

## Changes

- Add reusable request-body, JSON response, raw/named SSE, listen, and
close primitives.
- Migrate messaging-compatible, MCP bridge, and Hermes inference-switch
mock servers.
- Preserve scenario-specific request logs, streaming shapes, auth
checks, and cleanup.
- Document the protocol-only boundary with NVIDIA#5745.
- Add focused real-server protocol tests.

## Verification

- [x] Signed/Verified commit and all hooks passed
- [x] `npm run build:cli`
- [x] `npm run typecheck:cli`
- [x] `npm run lint`
- [x] Protocol and migrated-helper support tests: 23 passed
- [x] No production provider behavior or inference-mode policy changed

---
Signed-off-by: Julie Yaunches <[email protected]>


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

## Summary by CodeRabbit

* **Tests**
* Added shared HTTP test helpers for reading request bodies, writing
JSON responses, and sending SSE streams.
* Updated end-to-end tests to use the shared helpers for server setup,
response handling, and cleanup.
* Added coverage for HTTP request/response behavior, including JSON and
streaming event responses.

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

Co-authored-by: Carlos Villela <[email protected]>
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 area: e2e End-to-end tests, nightly failures, or validation infrastructure integration: hermes Hermes integration behavior refactor PR restructures code without intended behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(e2e): consolidate fake provider protocol utilities

3 participants