Skip to content

fastapi and streaming tests use get applications api#53949

Merged
zcin merged 1 commit intomasterfrom
SERVE-825-abrar-tests
Jun 19, 2025
Merged

fastapi and streaming tests use get applications api#53949
zcin merged 1 commit intomasterfrom
SERVE-825-abrar-tests

Conversation

@abrarsheikh
Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: abrar <abrar@anyscale.com>
@abrarsheikh abrarsheikh added the go add ONLY when ready to merge, run all tests label Jun 19, 2025
@abrarsheikh abrarsheikh marked this pull request as ready for review June 19, 2025 14:55
Copilot AI review requested due to automatic review settings June 19, 2025 14:55
@abrarsheikh abrarsheikh requested a review from a team as a code owner June 19, 2025 14:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates various tests for FastAPI and streaming responses to use dynamic URL retrieval via the get_application_url(s) API instead of hard-coded localhost URLs.

  • Update streaming requester and response tests to use get_application_url.
  • Update FastAPI and API tests to build URLs dynamically and remove trailing slashes for consistency.
  • Refactor URL construction in the test utilities and adjust message processing in HTTP utilities.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/ray/serve/tests/test_streaming_response.py Updated streaming tests to construct URLs using get_application_url and support multiple URLs.
python/ray/serve/tests/test_fastapi.py Modified FastAPI and related endpoint tests to use dynamic URL retrieval.
python/ray/serve/tests/test_api.py Revised URL assertions to remove trailing slashes for consistency.
python/ray/serve/_private/test_utils.py Adjusted URL creation logic by trimming trailing slashes.
python/ray/serve/_private/http_util.py Updated message handling logic for processing pickled messages in streamed responses.

Comment on lines +308 to +315
if isinstance(pickled_messages, bytes):
messages = pickle.loads(pickled_messages)
else:
messages = (
pickled_messages
if isinstance(pickled_messages, list)
else [pickled_messages]
)
Copy link

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

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

Consider extracting the message processing logic (handling bytes, list, or single item) into a dedicated helper function to improve readability and maintainability.

Suggested change
if isinstance(pickled_messages, bytes):
messages = pickle.loads(pickled_messages)
else:
messages = (
pickled_messages
if isinstance(pickled_messages, list)
else [pickled_messages]
)
messages = self._process_pickled_messages(pickled_messages)

Copilot uses AI. Check for mistakes.
url = f"{target.ip}:{target.port}"
else:
raise ValueError(f"Unsupported protocol: {protocol}")
url = url.rstrip("/")
Copy link

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

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

Removing the trailing slash can affect URL consistency when route_prefix is empty; consider adding explicit unit tests to ensure expected behavior under all conditions.

Suggested change
url = url.rstrip("/")
if route_prefix:
url = url.rstrip("/")

Copilot uses AI. Check for mistakes.

r = httpx.get(f"http://localhost:8000{expected_route_prefix}openapi.json")
url = get_application_url("HTTP")
assert expected_route_prefix.rstrip("/") in url
Copy link

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

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

[nitpick] Using a substring assertion on the URL may lead to false positives if the URL structure changes; consider validating the complete URL format to ensure accuracy.

Copilot uses AI. Check for mistakes.
@zcin zcin merged commit 3ca2c41 into master Jun 19, 2025
5 checks passed
@zcin zcin deleted the SERVE-825-abrar-tests branch June 19, 2025 17:02
minerharry pushed a commit to minerharry/ray that referenced this pull request Jun 27, 2025
update serve fastapi and streaming tests

Signed-off-by: abrar <abrar@anyscale.com>
elliot-barn pushed a commit that referenced this pull request Jul 2, 2025
update serve fastapi and streaming tests

Signed-off-by: abrar <abrar@anyscale.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
snorkelopstesting3-bot pushed a commit to snorkel-marlin-repos/ray-project_ray_pr_53949_c2fd26f9-40af-409d-a8b3-21ac5455fce7 that referenced this pull request Oct 22, 2025
snorkelopstesting4-web pushed a commit to snorkel-marlin-repos/ray-project_ray_pr_53949_ae2b5fd2-b893-47c0-ae5a-e13119d93f41 that referenced this pull request Oct 22, 2025
snorkelopstesting4-web pushed a commit to snorkel-marlin-repos/ray-project_ray_pr_53949_a0461bee-24df-42ee-b0b3-6f86e1e7a62f that referenced this pull request Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants