Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions tests/v1/engine/test_async_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,32 @@ async def test_dp_rank_argument(monkeypatch: pytest.MonkeyPatch):
sampling_params=sampling_params,
data_parallel_rank=1):
pass


@pytest.mark.asyncio
async def test_check_health(monkeypatch: pytest.MonkeyPatch):
"""Test that check_health returns normally for healthy engine
and raises EngineDeadError when the engine is dead.
"""
from unittest.mock import patch

from vllm.v1.engine.exceptions import EngineDeadError

with monkeypatch.context() as m, ExitStack() as after:
m.setenv("VLLM_USE_V1", "1")

engine = AsyncLLM.from_engine_args(TEXT_ENGINE_ARGS)
after.callback(engine.shutdown)

# Test 1: Healthy engine should not raise any exception
await engine.check_health()

# Test 2: Mock the errored property to simulate a dead engine
with patch.object(type(engine),
'errored',
new_callable=lambda: property(lambda self: True)
), pytest.raises(EngineDeadError):
await engine.check_health()

# Test 3: Verify healthy engine still works after mock
await engine.check_health()
2 changes: 2 additions & 0 deletions vllm/v1/engine/async_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ async def do_log_stats(

async def check_health(self) -> None:
logger.debug("Called check_health.")
if self.errored:
raise self.dead_error

async def start_profile(self) -> None:
await self.engine_core.profile_async(True)
Expand Down