Skip to content

test(router): hang guards instead of 5 s budgets around the PD router's round trips - #2660

Merged
slin1237 merged 1 commit into
mainfrom
test/pd-router-hang-guards
Sep 24, 2026
Merged

slin1237 merged 1 commit into
mainfrom
test/pd-router-hang-guards

Conversation

@hello-alexmcc

Copy link
Copy Markdown
Collaborator

Description

Problem

From the reviews of #2638 and #2639: check_prefill_drain (four timeouts) and messages_count_tokens_tracks_load_auth_and_body_failure (one) wrap real HTTP round trips through stub servers in 5 s tokio::time::timeouts, and fail under parallel load (reproduced 4/4 on a busy machine, passing in isolation). The tests assert on outcomes, not on latency; the timeouts only exist so a hang cannot wedge the suite.

Solution

One ROUND_TRIP_GUARD of 60 s for the tests module, used by all five sites. Test-only change.

Test Plan

  • cargo test -p smg --lib -- pd_router: 27 passed. cargo +nightly fmt --all -- --check clean; cargo clippy -p smg --all-targets -- -D warnings clean (without --all-features, no OpenCV here).
Checklist
  • cargo +nightly fmt passes
  • cargo clippy --all-targets -- -D warnings passes (without --all-features, see above)
  • (Optional) Documentation updated
  • (Optional) Please join us on Slack #sig-smg to discuss, review, and merge PRs

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 3d2489bf-e029-4217-9d07-1a77603fea80

📥 Commits

Reviewing files that changed from the base of the PR and between 478cf1c and 4b9b9ac.

📒 Files selected for processing (1)
  • model_gateway/src/routers/http/pd_router.rs

Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 6 reviews per hour.


📝 Summary

Summary by CodeRabbit

  • Tests
    • Extended the timeout ceiling for token-counting and streaming tests from 5 to 60 seconds. This gives slower test runs more time to complete while retaining a limit to catch hangs; the timeout is not a performance target. No runtime behavior changed.

Walkthrough

PD router tests define a shared 60-second timeout guard. Count-tokens, streaming, and prefill-drain tests use the guard instead of 5-second timeouts. Router runtime logic is unchanged.

Changes

PD router test timeouts

Layer / File(s) Summary
Shared timeout guard
model_gateway/src/routers/http/pd_router.rs
The tests define a 60-second guard and use it for count-tokens, streaming, and prefill-drain operations.

Estimated code review effort: 1 (Trivial) | ~4 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the test-only change from 5-second timeouts to a shared 60-second hang guard and provides validation results.
Title check ✅ Passed The title clearly identifies the main test change: replacing 5-second round-trip budgets with hang guards in the PD router 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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

@claude

claude Bot commented Sep 23, 2026

Copy link
Copy Markdown

👋 The PR description doesn't fully follow
PULL_REQUEST_TEMPLATE.md:

  • Missing header: ## Changes

Please update the PR description so reviewers have the context they need.

@github-actions github-actions Bot added the model-gateway Model gateway crate changes label Sep 23, 2026
Comment on lines +2275 to +2277
/// Ceiling on a real HTTP round trip in these tests: a guard against a
/// hang, not a budget, since a loaded machine can take seconds.
const ROUND_TRIP_GUARD: std::time::Duration = std::time::Duration::from_secs(60);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Nit: The const is declared above the module's use statements, which is unconventional item ordering for Rust (imports first, then items). Moving it below the use block at line 2287 would match the usual layout — purely cosmetic, no functional difference.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 4b9b9ac (also rebased onto main): the const sits below the module's use block now.

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

Reviewed the full diff: a test-only change replacing five 5-second timeouts with a shared 60-second ROUND_TRIP_GUARD in the PD router tests. All five sites are converted, the guard semantics preserve what the tests actually verify (the prefill stub blocks until explicitly released, so a real regression still trips the guard rather than passing slowly), and no timeout sites in the module were missed. One 🟡 nit posted (item ordering); no blocking issues.

…'s round trips

check_prefill_drain and
messages_count_tokens_tracks_load_auth_and_body_failure wrap real HTTP
round trips in 5 s timeouts and time out under parallel load (4/4 on a
busy machine, passing in isolation). The timeouts are a 60 s guard
against a hang now, one constant for the module, rather than a budget
the tests were never about.

Signed-off-by: Alex McC <319643551+hello-alexmcc@users.noreply.github.com>
@hello-alexmcc
hello-alexmcc force-pushed the test/pd-router-hang-guards branch from 478cf1c to 4b9b9ac Compare September 23, 2026 18:38
@slin1237
slin1237 merged commit 4cbe4e8 into main Sep 24, 2026
104 of 108 checks passed
@slin1237
slin1237 deleted the test/pd-router-hang-guards branch September 24, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

model-gateway Model gateway crate changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants