Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
83004020
Unverified
Commit
83004020
authored
Oct 18, 2025
by
dongbo910220
Committed by
GitHub
Oct 18, 2025
Browse files
[Test] Add test for /health endpoint on engine failure (#26074)
Signed-off-by:
dongbo910220
<
1275604947@qq.com
>
parent
12e21701
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
tests/entrypoints/openai/test_basic.py
tests/entrypoints/openai/test_basic.py
+24
-0
No files found.
tests/entrypoints/openai/test_basic.py
View file @
83004020
...
@@ -3,12 +3,15 @@
...
@@ -3,12 +3,15 @@
import
asyncio
import
asyncio
from
http
import
HTTPStatus
from
http
import
HTTPStatus
from
unittest.mock
import
AsyncMock
,
Mock
import
openai
import
openai
import
pytest
import
pytest
import
pytest_asyncio
import
pytest_asyncio
import
requests
import
requests
from
fastapi
import
Request
from
vllm.v1.engine.exceptions
import
EngineDeadError
from
vllm.version
import
__version__
as
VLLM_VERSION
from
vllm.version
import
__version__
as
VLLM_VERSION
from
...utils
import
RemoteOpenAIServer
from
...utils
import
RemoteOpenAIServer
...
@@ -224,3 +227,24 @@ async def test_server_load(server: RemoteOpenAIServer):
...
@@ -224,3 +227,24 @@ async def test_server_load(server: RemoteOpenAIServer):
response
=
requests
.
get
(
server
.
url_for
(
"load"
))
response
=
requests
.
get
(
server
.
url_for
(
"load"
))
assert
response
.
status_code
==
HTTPStatus
.
OK
assert
response
.
status_code
==
HTTPStatus
.
OK
assert
response
.
json
().
get
(
"server_load"
)
==
0
assert
response
.
json
().
get
(
"server_load"
)
==
0
@
pytest
.
mark
.
asyncio
async
def
test_health_check_engine_dead_error
():
# Import the health function directly to test it in isolation
from
vllm.entrypoints.openai.api_server
import
health
# Create a mock request that simulates what FastAPI would provide
mock_request
=
Mock
(
spec
=
Request
)
mock_app_state
=
Mock
()
mock_engine_client
=
AsyncMock
()
mock_engine_client
.
check_health
.
side_effect
=
EngineDeadError
()
mock_app_state
.
engine_client
=
mock_engine_client
mock_request
.
app
.
state
=
mock_app_state
# Test the health function directly with our mocked request
# This simulates what would happen if the engine dies
response
=
await
health
(
mock_request
)
# Assert that it returns 503 Service Unavailable
assert
response
.
status_code
==
503
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment