-
Notifications
You must be signed in to change notification settings - Fork 674
test: create a helper function to send request directly to mocker instances #3269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
create a new helper function named send_request_to_specified_mocker_instence to send request directly to the specified mocker instance by moving up and enhancing the old wait_for_mocker_ready function nested in test_kv_push_router_bindings. The function is used by test_kv_push_router_bindings replacing the old one and will be reused by new test functions. Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
|
👋 Hi zhixiongli2011! Thank you for contributing to ai-dynamo/dynamo. Just a reminder: The 🚀 |
WalkthroughIntroduces an async helper to send a request to a specified mocker via KvPushRouter with exponential backoff and optional overrides. Updates two tests to use this helper for readiness/verification. Removes the prior inline readiness-wait loop. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Test
participant Helper as Helper Function
participant Router as KvPushRouter
participant Worker as Mocker Instance
Test->>Helper: send_request_to_specified_mocker_instance(opts, worker_id)
Helper->>Helper: Build KvRouterConfig + validate worker_id
loop up to max_retries (8)
Helper->>Router: generate(request, config override)
Router->>Worker: route to specified worker
Worker-->>Router: stream chunks
Router-->>Helper: stream chunks
alt stream completes successfully
Helper->>Helper: consume stream, verify success
Helper-->>Test: return True
else error/timeout
Helper->>Helper: exponential backoff wait
end
end
Helper-->>Test: raise RuntimeError on exhaustion
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks✅ Passed checks (3 passed)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
tests/router/test_router_e2e_with_mockers.py (2)
348-349: Rename unused stream itemThe iterator variable isn’t used; renaming it to
_keeps the intent clear and satisfies Ruff’s B007 warning.- async for response in stream: + async for _ in stream: pass
360-362: Preserve original exception contextChaining the original exception retains the traceback, which makes failures easier to diagnose and addresses Ruff’s B904 warning.
- raise RuntimeError( - f"Failed to connect to mockers after {max_retries + 1} attempts: {e}" - ) + raise RuntimeError( + f"Failed to connect to mockers after {max_retries + 1} attempts" + ) from e
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/router/test_router_e2e_with_mockers.py(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/router/test_router_e2e_with_mockers.py (2)
lib/bindings/python/src/dynamo/_core.pyi (9)
namespace(37-41)component(63-67)endpoint(82-86)KvRouterConfig(739-741)KvPushRouter(1126-1225)block_size(497-501)block_size(520-524)block_size(1117-1124)generate(1147-1179)lib/bindings/python/rust/llm/kv.rs (4)
block_size(437-439)block_size(498-500)block_size(962-964)generate(1077-1144)
🪛 Ruff (0.13.1)
tests/router/test_router_e2e_with_mockers.py
325-327: Avoid specifying long messages outside the exception class
(TRY003)
348-348: Loop control variable response not used within loop body
Rename unused response to _response
(B007)
352-352: Consider moving this statement to an else block
(TRY300)
354-354: Do not catch blind exception: Exception
(BLE001)
360-362: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling
(B904)
360-362: Avoid specifying long messages outside the exception class
(TRY003)
🪛 GitHub Actions: Pre Merge Validation of (ai-dynamo/dynamo/refs/pull/3269/merge) by zhixiongli2011.
tests/router/test_router_e2e_with_mockers.py
[error] 1-1: Black formatting check failed. reformatted tests/router/test_router_e2e_with_mockers.py.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build and Test - dynamo
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
|
@PeaBrane The pre-merg test failed at the below step in test_kv_push_router_bindings when trying to call the new helper however test_kv_push_router_bindings runs successfully on my VM. Any ideas please. asyncio.run(send_request_to_specified_mocker_instance(mockers=mockers)) |
|
@zhixiongli2011 thanks, can you check the CIs? I think it may just be linting. You may need to run the black linter |
|
@PeaBrane Thank you very much for the review and suggestions. I will check them out and let you know. I will use this PR to accommodate changes related to the new helper like remove overwrite, add pass in parameters (max_retries, router instance), verify token count, etc. and create another 1-2 PR to simply other test functions by using the new helper, and, of course, new PR for new tests, trying not to make big PR. Does this sound a good plan? |
|
@zhixiongli2011 sure that sounds good. On my end, I don't really mind the PR being too big. If you can have the current tests using your helper function it would actually include some code deletions which is always good. But it's up to you. And yea the new tests can be in a separate PR either way. Thanks! |
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
|
@PeaBrane Good afternoon, all recommended changes have been applied with test_kv_push_router_bindings being fully simplified and tested successfully. Attached is the test output log file. Once this PR is reviewed and approved by you, I will open another PR to simplify test_indexers_sync test_kv_push_router_bindings.test.log.txt One issue encountered during the test is KvPushRouter.generate() doesn't take the 'worker_id" argument. |
|
@zhixiongli2011 hmm that is very strange, what version/release of dynamo are you running? I think you may need to rebuild dynamo from main (with maturin) probably, instructions here. Is this an actual runtime error, or just some mypy error? But either way, I'm fine with this for now, and will try to merge it. Thanks. (Edit: added a few more comments) |
|
/ok to test f703fd3 |
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
Signed-off-by: Paul Li <[email protected]>
|
/ok to test abfda5a |
…tances (#3269) Signed-off-by: Paul Li <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

Overview:
Create a helper function in tests/router/test_router_e2e_with_mockers.py to send request directly to mocker instances. It will be used by the coming test functions to send dummy request to check the readiness of the mockers and to send good test request for testing.
Details:
Where should the reviewer start?
File: tests/router/test_router_e2e_with_mockers.py
Functions: send_request_to_specified_mocker_instance() and test_kv_push_router_bindings()
Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit