-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Add more refactored openai test & in CI #7284
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8b23fbb
Add more tests for refactored oai server
jhinpan 5a2617d
Add openai server test in CI
jhinpan 384e107
Add other testing script to CI
jhinpan 0452b66
Typo Fix
jhinpan 33a695f
Merge branch 'main' into test/oai-server-test
jhinpan f0f32cd
Remove Pytest && Use Unittest instead
jhinpan 6f13490
Merge branch 'main' into test/oai-server-test
jhinpan e5b6d00
Remove left pytest dependency
jhinpan 426d5d9
Merge branch 'main' into test/oai-server-test
jhinpan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,52 @@ | ||
| # sglang/test/srt/openai/test_server.py | ||
| import pytest | ||
| import requests | ||
|
|
||
| from sglang.test.test_utils import DEFAULT_SMALL_MODEL_NAME_FOR_TEST as MODEL_ID | ||
|
|
||
|
|
||
| def test_health(openai_server: str): | ||
| r = requests.get(f"{openai_server}/health") | ||
| assert r.status_code == 200, r.text | ||
| assert r.status_code == 200 | ||
| # FastAPI returns an empty body → r.text == "" | ||
| assert r.text == "" | ||
|
|
||
|
|
||
| @pytest.mark.xfail(reason="Endpoint skeleton not implemented yet") | ||
| def test_models_endpoint(openai_server: str): | ||
| r = requests.get(f"{openai_server}/v1/models") | ||
| # once implemented this should be 200 | ||
| assert r.status_code == 200 | ||
| assert r.status_code == 200, r.text | ||
| payload = r.json() | ||
|
|
||
| # Basic contract | ||
| assert "data" in payload and isinstance(payload["data"], list) and payload["data"] | ||
|
|
||
| # Validate fields of the first model card | ||
| first = payload["data"][0] | ||
| for key in ("id", "root", "max_model_len"): | ||
| assert key in first, f"missing {key} in {first}" | ||
|
|
||
| # max_model_len must be positive | ||
| assert isinstance(first["max_model_len"], int) and first["max_model_len"] > 0 | ||
|
|
||
| # The server should report the same model id we launched it with | ||
| ids = {m["id"] for m in payload["data"]} | ||
| assert MODEL_ID in ids | ||
|
|
||
|
|
||
| def test_get_model_info(openai_server: str): | ||
| r = requests.get(f"{openai_server}/get_model_info") | ||
| assert r.status_code == 200, r.text | ||
| info = r.json() | ||
|
|
||
| expected_keys = {"model_path", "tokenizer_path", "is_generation"} | ||
| assert expected_keys.issubset(info.keys()) | ||
|
|
||
| # model_path must end with the one we passed on the CLI | ||
| assert info["model_path"].endswith(MODEL_ID) | ||
|
|
||
| # is_generation is documented as a boolean | ||
| assert isinstance(info["is_generation"], bool) | ||
|
|
||
|
|
||
| def test_unknown_route_returns_404(openai_server: str): | ||
| r = requests.get(f"{openai_server}/definitely-not-a-real-route") | ||
| assert r.status_code == 404 |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.