Skip to content

Add E2E tests for hermes_cli adapter - #18

Merged
AjayThorve merged 9 commits into
NVIDIA:mainfrom
dagardner-nv:david-hermes_cli-e2e-tests
Jun 25, 2026
Merged

Add E2E tests for hermes_cli adapter#18
AjayThorve merged 9 commits into
NVIDIA:mainfrom
dagardner-nv:david-hermes_cli-e2e-tests

Conversation

@dagardner-nv

@dagardner-nv dagardner-nv commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator
  • Add a skill for writing Python tests
  • Add a mock LLM API server for performing E2E test without needing an API key.
    • Defined at tests/_utils/mock_api_server.py
    • Exposed as api_server fixture in tests/conftest.py
    • Added fastapi and uvicorn to the test dependency group
  • Add TestHermesE2E test class in tests/test_hermes_cli.py containing the following related tests:
    • test_artifacts
    • test_atof_artifacts
    • test_atif_artifacts

Summary by CodeRabbit

  • New Features

    • Added a reusable mock API server for testing chat-completions behavior, including deterministic responses, configurable error status codes, and streaming support.
    • Added end-to-end coverage for the Hermes CLI relay flow, including artifact generation and validation.
  • Tests

    • Added new test utilities and fixtures to run isolated sessions with per-test API endpoints and mock credentials.
    • Expanded assertions for relay configuration, adapter invocation outputs, and artifact record contents.
  • Documentation

    • Added documentation covering Python/pytest conventions, async handling, mocking guidance, and common test commands.
  • Chores

    • Updated CI dependency syncing to include the relay extras.

Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
@dagardner-nv dagardner-nv added the enhancement New feature or request label Jun 25, 2026
@dagardner-nv
dagardner-nv marked this pull request as ready for review June 25, 2026 18:04
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

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: 249c500d-a477-4a64-b34d-92163fc53bc1

📥 Commits

Reviewing files that changed from the base of the PR and between 6efe7df and f4b2577.

📒 Files selected for processing (1)
  • .github/workflows/ci_python.yml

📝 Walkthrough

Walkthrough

Adds a Python test skill doc, new FastAPI/Uvicorn test dependencies, a mock chat-completions server utility, shared pytest fixtures, and a Hermes CLI relay end-to-end test suite that rewrites relay config and validates generated artifacts.

Changes

Hermes CLI relay test coverage

Layer / File(s) Summary
Test tooling and guidance
.agents/skills/python-tests/SKILL.md, pyproject.toml
Adds pytest-style guidance, common test commands, references, and FastAPI/Uvicorn test dependencies.
Mock server and profile helper
tests/_utils/mock_api_server.py, tests/_utils/utils.py
Adds a FastAPI mock chat-completions server with request capture, configurable response status, and SSE streaming, plus a helper that rewrites the Hermes relay base URL in profile YAML.
Shared pytest fixtures
tests/conftest.py
Adds fixtures for the copied code-review agent tree, per-test mock API server access, optional relay imports, and a test NVIDIA API key.
Hermes CLI end-to-end assertions
tests/test_hermes_cli.py
Adds an autouse relay-run fixture and tests that validate Hermes relay output fields, artifact layout, atof records, and atif trajectory contents.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • AjayThorve
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 34.78% 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 accurately summarizes the main change: adding Hermes CLI end-to-end tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ 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

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
tests/test_hermes_cli.py (2)

189-189: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Hardcoded record/step counts are brittle.

len(atof_records) == 6 and len(steps) == 5 will break on any benign change to the relay's emitted telemetry volume, with a failure that points here rather than at the cause. Consider asserting >= a minimum, or anchoring on the named boundary records (which you already check) instead of exact totals.

Also applies to: 218-218

🤖 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 `@tests/test_hermes_cli.py` at line 189, The assertions in the Hermes CLI tests
are too brittle because they hardcode exact telemetry record and step counts.
Update the checks around the test cases using atof_records and steps to avoid
fixed totals, either by asserting a minimum threshold or by relying on the
already-validated boundary records in the relevant test functions. Keep the
named boundary assertions intact and adjust the total-count expectations so they
remain stable as telemetry volume changes.

74-98: 🚀 Performance & Scalability | 🔵 Trivial | ⚖️ Poor tradeoff

Autouse fixture re-runs the relay once per test method.

pytest instantiates the class per test method, so this function-scoped autouse fixture executes the full FabricClient().run(...) relay invocation for each of test_artifacts, test_atof_artifacts, and test_atif_artifacts — three end-to-end runs to assert on one set of outputs. If the run is deterministic, computing it once and sharing the result would cut E2E time significantly.

One option: move the run into a class- or module-scoped fixture that returns the result dict, and have each test read from it instead of self.

🤖 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 `@tests/test_hermes_cli.py` around lines 74 - 98, The autouse fixture
run_hermes_cli_relay is doing the full FabricClient.run relay invocation
separately for every test method, which repeats the same expensive end-to-end
setup. Refactor this so the execution happens once in a wider-scoped fixture
(class- or module-scoped) that returns the result/artifact data, then have
test_artifacts, test_atof_artifacts, and test_atif_artifacts consume that shared
fixture instead of relying on self state.
pyproject.toml (1)

26-31: 📐 Maintainability & Code Quality | 🔵 Trivial

Consider tightening the FastAPI/Uvicorn pins. ~=0.138 and ~=0.49 still admit later 0.x minors (~=0.138 allows 0.139.*, ~=0.49 allows 0.50.*). Use ~=0.138.0 and ~=0.49.0 if patch-line reproducibility matters.

Suggested pin
-    "fastapi~=0.138",
+    "fastapi~=0.138.0",
     "pytest>=8",
     "pytest-asyncio>=0.26",
     "pytest-cov~=7.0",
     "pyyaml>=6.0",
-    "uvicorn~=0.49",
+    "uvicorn~=0.49.0",
🤖 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 `@pyproject.toml` around lines 26 - 31, The dependency pins in pyproject.toml
are too loose for FastAPI and Uvicorn because `~=0.138` and `~=0.49` still allow
later minor releases. Tighten the version specifiers in the dependency list to
the patch-level form for `fastapi` and `uvicorn` so only patch updates within
the same minor line are accepted.
🤖 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 `@tests/conftest.py`:
- Around line 122-126: The mock_nvidia_api_key fixture is mutating os.environ
directly, which leaves NVIDIA_API_KEY set after the fixture finishes. Update
mock_nvidia_api_key_fixture to use monkeypatch.setenv so the temporary value is
scoped to the test and automatically restored at teardown; keep the fixture name
and return value the same so existing tests continue to use it.

---

Nitpick comments:
In `@pyproject.toml`:
- Around line 26-31: The dependency pins in pyproject.toml are too loose for
FastAPI and Uvicorn because `~=0.138` and `~=0.49` still allow later minor
releases. Tighten the version specifiers in the dependency list to the
patch-level form for `fastapi` and `uvicorn` so only patch updates within the
same minor line are accepted.

In `@tests/test_hermes_cli.py`:
- Line 189: The assertions in the Hermes CLI tests are too brittle because they
hardcode exact telemetry record and step counts. Update the checks around the
test cases using atof_records and steps to avoid fixed totals, either by
asserting a minimum threshold or by relying on the already-validated boundary
records in the relevant test functions. Keep the named boundary assertions
intact and adjust the total-count expectations so they remain stable as
telemetry volume changes.
- Around line 74-98: The autouse fixture run_hermes_cli_relay is doing the full
FabricClient.run relay invocation separately for every test method, which
repeats the same expensive end-to-end setup. Refactor this so the execution
happens once in a wider-scoped fixture (class- or module-scoped) that returns
the result/artifact data, then have test_artifacts, test_atof_artifacts, and
test_atif_artifacts consume that shared fixture instead of relying on self
state.
🪄 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: 13e76d1d-648f-4cc3-9924-34552354bff2

📥 Commits

Reviewing files that changed from the base of the PR and between 22b8aff and 6efe7df.

📒 Files selected for processing (6)
  • .agents/skills/python-tests/SKILL.md
  • pyproject.toml
  • tests/_utils/mock_api_server.py
  • tests/_utils/utils.py
  • tests/conftest.py
  • tests/test_hermes_cli.py

Comment thread tests/conftest.py
Signed-off-by: David Gardner <dagardner@nvidia.com>

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

Looks good!

@AjayThorve
AjayThorve merged commit 21c27cf into NVIDIA:main Jun 25, 2026
4 checks passed
@dagardner-nv
dagardner-nv deleted the david-hermes_cli-e2e-tests branch July 9, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants