File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -369,3 +369,32 @@ async def test_dp_rank_argument(monkeypatch: pytest.MonkeyPatch):
369
369
sampling_params = sampling_params ,
370
370
data_parallel_rank = 1 ):
371
371
pass
372
+
373
+
374
+ @pytest .mark .asyncio
375
+ async def test_check_health (monkeypatch : pytest .MonkeyPatch ):
376
+ """Test that check_health returns normally for healthy engine
377
+ and raises EngineDeadError when the engine is dead.
378
+ """
379
+ from unittest .mock import patch
380
+
381
+ from vllm .v1 .engine .exceptions import EngineDeadError
382
+
383
+ with monkeypatch .context () as m , ExitStack () as after :
384
+ m .setenv ("VLLM_USE_V1" , "1" )
385
+
386
+ engine = AsyncLLM .from_engine_args (TEXT_ENGINE_ARGS )
387
+ after .callback (engine .shutdown )
388
+
389
+ # Test 1: Healthy engine should not raise any exception
390
+ await engine .check_health ()
391
+
392
+ # Test 2: Mock the errored property to simulate a dead engine
393
+ with patch .object (type (engine ),
394
+ 'errored' ,
395
+ new_callable = lambda : property (lambda self : True )
396
+ ), pytest .raises (EngineDeadError ):
397
+ await engine .check_health ()
398
+
399
+ # Test 3: Verify healthy engine still works after mock
400
+ await engine .check_health ()
Original file line number Diff line number Diff line change @@ -552,6 +552,8 @@ async def do_log_stats(
552
552
553
553
async def check_health (self ) -> None :
554
554
logger .debug ("Called check_health." )
555
+ if self .errored :
556
+ raise self .dead_error
555
557
556
558
async def start_profile (self ) -> None :
557
559
await self .engine_core .profile_async (True )
You can’t perform that action at this time.
0 commit comments