Skip to content

Conversation

@ezhoureal
Copy link
Contributor

@ezhoureal ezhoureal commented Jun 12, 2025

Overview:

Adding unit tests for select_worker function.

Details:

Where should the reviewer start?

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • closes GitHub issue: #xxx

Summary by CodeRabbit

  • Tests
    • Added comprehensive unit tests for worker selection logic, covering selection correctness, error handling when no endpoints are available, fallback behavior without overlap scores, and custom weight configurations. No changes to user-facing features.

Signed-off-by: Tianer Zhou <ezhoureal@gmail.com>
@copy-pr-bot
Copy link

copy-pr-bot bot commented Jun 12, 2025

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.

@github-actions
Copy link

👋 Hi ezhoureal! Thank you for contributing to ai-dynamo/dynamo.

Just a reminder: The NVIDIA Test Github Validation CI runs an essential subset of the testing framework to quickly catch errors.Your PR reviewers may elect to test the changes comprehensively before approving your changes.

🚀

@github-actions github-actions bot added external-contribution Pull request is from an external contributor test labels Jun 12, 2025
Signed-off-by: Tianer Zhou <ezhoureal@gmail.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 12, 2025

Walkthrough

A new test module was added to kv_router/scheduler.rs under a conditional compilation flag. This module introduces multiple unit tests for the DefaultWorkerSelector, covering scenarios such as worker selection correctness, error handling, absence of overlap scores, and custom weight configurations. No production logic was changed.

Changes

File(s) Change Summary
lib/llm/src/kv_router/scheduler.rs Added a tests module with helper functions and multiple unit tests for DefaultWorkerSelector

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Function
    participant Selector as DefaultWorkerSelector
    participant Endpoints as Mocked Endpoints
    participant Request as SchedulingRequest

    Test->>Endpoints: Create mock endpoints
    Test->>Request: Create scheduling request
    Test->>Selector: Call select_worker(endpoints, request)
    alt Endpoints available
        Selector->>Endpoints: Evaluate each endpoint
        Selector->>Request: Use overlap scores and weights
        Selector-->>Test: Return selected worker and scores
    else No endpoints
        Selector-->>Test: Return NoEndpoints error
    end
Loading

Possibly related PRs

Poem

In the warren, tests now bloom,
Selector's logic faced its doom—
Tie-breaks, weights, and errors caught,
Edge-case bunnies never fraught.
No code was changed, just peace ensured,
With every path now well secured!
🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cfef625 and db8ddb0.

📒 Files selected for processing (1)
  • lib/llm/src/kv_router/scheduler.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/llm/src/kv_router/scheduler.rs
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pre-merge-rust (.)
  • GitHub Check: pre-merge-rust (lib/bindings/python)
  • GitHub Check: pre-merge-rust (lib/runtime/examples)
  • GitHub Check: Build and Test - vllm

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 (2)
lib/llm/src/kv_router/scheduler.rs (2)

466-478: Probabilistic tie-breaker ⇒ flaky test

test_tie_breaker_randomness relies on random choice and asserts that both
workers are chosen at least once over 10 runs.
With two workers the chance of picking the same worker ten times is 1 / 1024,
small but non-zero – CI flakes are painful.

Consider either:

  1. Injecting a deterministic RNG via DI so the test can control the seed.
  2. Raising the iteration count and/or using assert!(results.iter().any(|…|))
    with statistical tolerance.

387-395: Unused resp_tx sender – small leak / warning

create_request builds a oneshot::channel() and drops the receiver.
While harmless here, dropping the receiver causes the send in
SchedulingRequest::respond to return Err, which pollutes trace logs for
any future use of this helper.

If the response isn’t needed, create the struct with tokio::sync::oneshot::channel().0
and explicitly ignore the error inside tests, or add a #[allow(dead_code)]
dummy receiver to keep the channel alive.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0d364e and 880854b.

📒 Files selected for processing (1)
  • lib/llm/src/kv_router/scheduler.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build and Test - vllm
  • GitHub Check: pre-merge-rust (lib/runtime/examples)
  • GitHub Check: pre-merge-rust (lib/bindings/python)
  • GitHub Check: pre-merge-rust (.)

Signed-off-by: Tianer Zhou <ezhoureal@gmail.com>
Signed-off-by: Tianer Zhou <ezhoureal@gmail.com>
Signed-off-by: Tianer Zhou <ezhoureal@gmail.com>
Signed-off-by: Tianer Zhou <ezhoureal@gmail.com>
@ezhoureal ezhoureal requested a review from PeaBrane June 12, 2025 13:13
@PeaBrane PeaBrane enabled auto-merge (squash) June 12, 2025 18:06
@PeaBrane PeaBrane merged commit cb71be9 into ai-dynamo:main Jun 12, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contribution Pull request is from an external contributor size/L test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants