Skip to content

feat(operations): add release soak test - #176

Open
elyasmnvidian wants to merge 1 commit into
mainfrom
emehtabuddin/soak-test
Open

feat(operations): add release soak test#176
elyasmnvidian wants to merge 1 commit into
mainfrom
emehtabuddin/soak-test

Conversation

@elyasmnvidian

@elyasmnvidian elyasmnvidian commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What

Adds a release soak tester as a Rust crate, crates/switchyard-soak. It sends sustained,
closed-loop traffic through a live Switchyard server long enough to surface failures that short
tests miss, and exits non-zero when a release gate fails.

Each run drives:

  • OpenAI Chat Completions (/v1/chat/completions), Anthropic Messages (/v1/messages), and
    OpenAI Responses (/v1/responses)
  • streaming and non-streaming responses, with per-response shape and SSE-framing checks
  • a periodic reporter that samples /health, /metrics, and (for a local server) process RSS/CPU
  • an invalid-request canary that expects HTTP 400 and confirms the server stays live

It writes config.json, intervals.csv, errors.jsonl, and summary.json to a timestamped
results directory, and the summary records the pass result and any failed release gates (error
rate, liveness, metrics, process, canary, counter resets, RSS growth). At the end of a run it also
prints an oha-style latency percentile table (p50 through p99.9) and an ASCII latency histogram to
the terminal.

For monitoring a run in progress, each interval prints a progress line
(progress=120s/300s(40%) reqs=... errors=...(0.00%) ... status=OK) and overwrites a status.json
live snapshot atomically, with a status token of ok/degraded/stalled — so a remote tail of
the log or a cat status.json gives an at-a-glance confidence check.

Run it with:

cargo build --release -p switchyard-soak
./target/release/switchyard-soak --base-url http://127.0.0.1:4000 --model RELEASE_MODEL_ID \
  --duration 48h --concurrency 16 --server-pid "$SERVER_PID" --max-rss-growth-mib 512

Why

A soak run is the pre-freeze check for changes to libsy, the Rust server, routing, streaming,
translation, or server lifecycle. Writing it in Rust keeps the release tooling on one toolchain and
shrinks the Python surface.

How tested

  • cargo test -p switchyard-soak — 10 unit tests (duration parsing, percentiles, metric parsing,
    request bodies, summary gates, timestamps) and 8 integration tests that drive the runner against a
    hermetic axum mock (full short run, preflight selection/rejection, streaming/non-streaming success,
    invalid-response/stream detection, HTTP-error and empty-stream handling, the canary).
  • Live-validated against the real switchyard-server pointed at the NVIDIA gateway (haiku): a short
    run across all three endpoints (streaming and non-streaming) completed with zero errors, and the
    liveness, metrics, process, and canary checks all passed.
  • Hermetically validated end to end through switchyard-server backed by
    VidaiMock (a mock LLM server): a clean run passes with zero
    errors, and a degraded backend (mock latency past the request timeout) trips the error-rate gate to
    a 100% timeout failure and exits non-zero. scripts/soak-rehearsal.sh wires this stack together.
  • cargo clippy -p switchyard-soak --all-targets and cargo fmt are clean.

Docs

docs/operations/soak_test.md covers preparing the server, building the tester, rehearsing against
a hermetic VidaiMock backend (scripts/soak-rehearsal.sh), an optional vegeta throughput probe, the
48-hour run, the pass criteria, and how to read the result files.

Checklist

  • Unit and integration tests for the runner, its gates, and the request/response paths.
  • New crate registered in the workspace; depends only on external crates.
  • Operations doc updated with the build and run commands.
  • Commit carries the DCO sign-off.

Notes for reviewers

The crate has no dependency on any internal Switchyard crate, so it builds in isolation from the
components/core refactor on main. This branch is not yet rebased onto latest main; the change is
additive (one new crate plus a workspace-member line, a .gitignore entry, and a docs-nav entry),
so the rebase is mechanical when wanted.

@elyasmnvidian
elyasmnvidian requested a review from a team as a code owner July 29, 2026 04:44
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

🚀 View preview at
https://NVIDIA-NeMo.github.io/Switchyard/pr-preview/pr-176/

Built to branch gh-pages at 2026-07-31 05:53 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Changes

Soak Test

Layer / File(s) Summary
Request contracts and result recording
scripts/soak_test.py, tests/test_soak_test.py
Adds endpoint payload construction, prompt and metric helpers, statistics tracking, bounded error recording, and corresponding unit tests.
Preflight and closed-loop traffic
scripts/soak_test.py, tests/test_soak_test.py
Adds model discovery, streaming and non-streaming request validation, concurrent endpoint workers, and request-path tests.
Monitoring, canary, and release gates
scripts/soak_test.py, tests/test_soak_test.py
Adds health, metrics, process, invalid-request, restart, and RSS checks with summary gating and failure-case coverage.
CLI orchestration and operational support
scripts/soak_test.py, tests/test_soak_test.py, docs/operations/soak_test.md, mkdocs.yml, .gitignore
Adds CLI lifecycle orchestration, integration coverage, the soak-test runbook and navigation entry, and ignores generated soak results.

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

Poem

I’m a rabbit with a workload to run,
Through streams and messages, one by one.
Health checks hop, metrics gleam,
Errors rest in a bounded stream.
Green gates bloom when the soak is done!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the addition of a release soak test, which is the main change in the pull request.

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

🧹 Nitpick comments (4)
scripts/soak_test.py (3)

132-149: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

process_sample blocks the event loop.

It's called from reporter (Line 442) on the running loop, so the ps fork/exec stalls all in-flight workers and skews the latency samples they're recording. Cheap to make non-blocking.

As per coding guidelines: "Use async-first Python APIs".

♻️ Proposed fix
-        rss_mib, cpu_percent = process_sample(server_pid)
+        rss_mib, cpu_percent = await asyncio.to_thread(process_sample, server_pid)
🤖 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 `@scripts/soak_test.py` around lines 132 - 149, Make process_sample
asynchronous and replace the blocking subprocess.run call with an async-first
subprocess API, awaiting completion while preserving the existing RSS/CPU
parsing and None-return behavior. Update reporter to await process_sample
wherever it samples process metrics.

Source: Coding guidelines


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

Add docstrings to the public writer methods.

write_interval, write_error, and close are public API entry points; note the MAX_ERROR_RECORDS drop invariant in write_error.

As per coding guidelines: "Add concise triple-quoted docstrings for public functions, classes, methods, and API entry points, documenting behavior, important invariants, and relevant errors."

🤖 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 `@scripts/soak_test.py` around lines 247 - 261, Add concise triple-quoted
docstrings to the public methods write_interval, write_error, and close in the
writer class, documenting their behavior; explicitly note that write_error drops
records after MAX_ERROR_RECORDS and tracks the dropped count.

Source: Coding guidelines


876-903: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Task failure discards summary.json for the whole run.

Raising here exits before the summary block, so a single failed worker after 47 hours leaves only intervals.csv/errors.jsonl and a stderr line. Consider recording the failure into the summary (completed_duration is already false, so it will be marked FAIL) and returning 1/2 instead of skipping artifact generation.

🤖 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 `@scripts/soak_test.py` around lines 876 - 903, Update the task-result handling
loop around run_tasks and worker_results/background_results so failed tasks are
recorded for the run and do not raise before the build_summary and summary.json
artifact generation. Preserve the failure details in the summary’s
failure_reasons, ensure the resulting summary is marked failed, and return the
appropriate nonzero status after writing the summary.
tests/test_soak_test.py (1)

96-147: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Byte-matching the serialized body is brittle; prefer respx per guidelines.

request.read().find(b'"stream":true') depends on httpx's compact JSON separators; a serializer change silently flips these tests to the wrong branch without failing. Decode the body instead. Separately, these handlers are the case respx is meant for.

As per coding guidelines: "Use respx for HTTP mocking".

♻️ Sturdier branch condition
     def handler(request: httpx.Request) -> httpx.Response:
-        if request.read().find(b'"stream":true') >= 0:
+        if json.loads(request.read())["stream"]:
🤖 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_soak_test.py` around lines 96 - 147, Replace the byte-level
request-body checks in the handlers for
test_send_request_accepts_json_and_streaming_success and
test_send_request_rejects_missing_fields_and_non_sse_stream with decoded JSON
inspection of the stream field, and migrate these HTTP mocks to respx as
required by the project guidelines. Preserve the existing JSON-success,
SSE-success, invalid-response, and invalid-stream outcomes for stream=False and
stream=True.

Source: Coding guidelines

🤖 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 `@docs/operations/soak_test.md`:
- Line 44: Update the health readiness instruction in the soak test
documentation to require both HTTP 200 and a JSON response containing
{"status":"ok"} from GET /health. Make clear that both conditions must be
satisfied before proceeding.
- Around line 45-46: Update the soak-test instructions to select and pass the
model id returned in each `/v1/models` response, rather than a release route
identifier. Apply this correction to all referenced command examples and
preserve the existing `--model` usage.
- Around line 97-110: Update the pass-criteria checklist in the soak test
documentation to replace the “no inference request fails” requirement with a
requirement that the inference error rate is at or below --max-error-rate, whose
default is 0. Keep the remaining criteria unchanged and align the wording with
the runner’s configured error-budget gate.

In `@scripts/soak_test.py`:
- Around line 403-407: Update the health-check logic around the response JSON
parsing so non-dict JSON bodies are treated as unhealthy rather than calling
.get() on them. Validate that the parsed body is a mapping before reading its
"status" field, while preserving the existing healthy condition and failure
handling in the surrounding try/except.

In `@tests/test_soak_test.py`:
- Around line 179-204: Increase the live soak duration configured in the test
invocation around soak_test.run, and adjust the report and invalid-canary
intervals if needed to preserve multiple metric and canary checks. Keep the
existing success, endpoint, and invalid_request_canaries assertions unchanged
while providing sufficient timing headroom for slower CI runners.

---

Nitpick comments:
In `@scripts/soak_test.py`:
- Around line 132-149: Make process_sample asynchronous and replace the blocking
subprocess.run call with an async-first subprocess API, awaiting completion
while preserving the existing RSS/CPU parsing and None-return behavior. Update
reporter to await process_sample wherever it samples process metrics.
- Around line 247-261: Add concise triple-quoted docstrings to the public
methods write_interval, write_error, and close in the writer class, documenting
their behavior; explicitly note that write_error drops records after
MAX_ERROR_RECORDS and tracks the dropped count.
- Around line 876-903: Update the task-result handling loop around run_tasks and
worker_results/background_results so failed tasks are recorded for the run and
do not raise before the build_summary and summary.json artifact generation.
Preserve the failure details in the summary’s failure_reasons, ensure the
resulting summary is marked failed, and return the appropriate nonzero status
after writing the summary.

In `@tests/test_soak_test.py`:
- Around line 96-147: Replace the byte-level request-body checks in the handlers
for test_send_request_accepts_json_and_streaming_success and
test_send_request_rejects_missing_fields_and_non_sse_stream with decoded JSON
inspection of the stream field, and migrate these HTTP mocks to respx as
required by the project guidelines. Preserve the existing JSON-success,
SSE-success, invalid-response, and invalid-stream outcomes for stream=False and
stream=True.
🪄 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: c51ae66a-bea9-400b-b5b3-fb971f696e24

📥 Commits

Reviewing files that changed from the base of the PR and between 61f41ff and eaa62d7.

📒 Files selected for processing (5)
  • .gitignore
  • docs/operations/soak_test.md
  • mkdocs.yml
  • scripts/soak_test.py
  • tests/test_soak_test.py

Comment thread docs/operations/soak_test.md Outdated
Comment thread docs/operations/soak_test.md Outdated
Comment thread docs/operations/soak_test.md
Comment thread scripts/soak_test.py Outdated
Comment thread tests/test_soak_test.py Outdated
@elyasmnvidian
elyasmnvidian force-pushed the emehtabuddin/soak-test branch 3 times, most recently from 1dbec57 to 73fab95 Compare July 30, 2026 17:16
Signed-off-by: Elyas Mehtabuddin <emehtabuddin@nvidia.com>
@elyasmnvidian
elyasmnvidian force-pushed the emehtabuddin/soak-test branch from 73fab95 to 1ddc528 Compare July 31, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant