Repository navigation
[doc][serve] Document unit and integration testing patterns - #67288
Merged
abrarsheikh merged 1 commit intoNov 5, 2026
Merged
abrarsheikh merged 1 commit into
abrarsheikh merged 1 commit into
Conversation
dstrodtman
marked this pull request as ready for review
October 22, 2026 16:43
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new section to the Ray Serve development workflow documentation on writing unit and integration tests, along with a supporting Python file containing the code examples. The review feedback suggests clarifying that for deployments not using @serve.ingress, the handle is called directly via handle.remote(...) instead of handle.<method>.remote(...).
|
|
||
| ### Integration test with `serve.run` | ||
|
|
||
| To test the deployed application, call `serve.run` from a `pytest` fixture. `serve.run` deploys the application and returns a `DeploymentHandle` to the ingress deployment. Call a method with `handle.<method>.remote(...)`, which returns a `DeploymentResponse`, and call `.result()` on the response to wait for the return value. To test the HTTP interface, send requests with an HTTP client such as `requests`. Shut down Serve and Ray when the tests finish: |
Contributor
There was a problem hiding this comment.
dstrodtman
force-pushed
the
doc-1547-serve-prose-advanced-guides
branch
from
October 30, 2026 16:56
fe41edd to
1b80286
Compare
Add a "Write unit and integration tests" section to the Serve development workflow page: keep business logic in a plain base class for Ray-free unit tests, use the func_or_class property, and test with serve.run through a DeploymentHandle and over HTTP. Examples live in doc_code/testing_patterns.py. Closes #44464 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
dstrodtman
force-pushed
the
doc-1010-serve-testing-patterns
branch
from
November 3, 2026 19:09
4e48a0c to
8a9df0d
Compare
abrarsheikh
approved these changes
Nov 5, 2026
abrarsheikh
merged commit Nov 5, 2026
2e2842e
into
doc-1547-serve-prose-advanced-guides
6 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Stacked on #67069 (Serve advanced guides style pass), because both edit
dev-workflow.md. Merge #67069 first, then retarget this PR tomaster.Adds a "Write unit and integration tests" section to the Ray Serve development workflow page. It follows the testing approach that Ray Serve maintainers lay out in #44464 and its duplicate #34477:
func_or_class.serve.run, then calling the app through the returnedDeploymentHandle(handle.method.remote(...).result()) and over HTTP withrequests.The examples live in a new tested file,
doc/source/serve/doc_code/testing_patterns.py, which the existingsource/serve/doc_code/**/*.pyglob indoc/BUILD.bazelalready picks up. FastAPI'sTestClientis left out, because the issue says it's untested with Serve. Theserve.status()polling pattern is covered separately by #65868 in the contributor guide.Sources: #44464 and #34477,
python/ray/serve/deployment.py(func_or_class),python/ray/serve/api.py(serve.runreturns aDeploymentHandle),python/ray/serve/handle.py(DeploymentResponse.result()).Related issues
Closes #44464
Review notes
from summarizer import .... The test file makes that import work by registeringsys.modules["summarizer"]outside the include markers. Is that acceptable, or should the snippets drop the import lines?doc_codetargets are taggedexclusive.Not a duplicate
gh pr list --state open --search "44464 in:body"returns nothing. #65868 is related but documents a different pattern.Testing
python doc/source/serve/doc_code/testing_patterns.pywithray[serve]==2.59.0: 4 passed (test_doubler_class,test_summarize_truncates_text,test_summarize_with_handle,test_summarize_with_http).make -C doc rtd-build:build succeeded.with exit code 0 and no Sphinx warnings.dev-workflow.md: no errors.ruff checkon the new file: clean.AI assistance
Drafted with AI assistance (Claude Code). The API usage was checked against the Serve source and the example was run locally.
🤖 Generated with Claude Code