3737# Import the application and classes
3838from launcher import ( # noqa: E402
3939 MAX_LOG_RESPONSE_BYTES ,
40+ HalfMade ,
4041 LogRangeNotAvailable ,
4142 VllmConfig ,
4243 VllmInstance ,
@@ -147,7 +148,7 @@ def test_instance_creation(self, vllm_config, gpu_translator, tmp_log_dir):
147148
148149 @patch ("launcher.multiprocessing.Process" )
149150 def test_instance_start (
150- self , mock_process_class , vllm_config , gpu_translator , tmp_log_dir
151+ self , mock_process_class , vllm_config : VllmConfig , gpu_translator , tmp_log_dir
151152 ):
152153 """Test starting a vLLM instance"""
153154 mock_process = MockProcess ()
@@ -160,11 +161,13 @@ def test_instance_start(
160161
161162 assert result ["status" ] == "started"
162163 assert result ["instance_id" ] == "test-id"
164+ for key , val in vllm_config .model_dump (exclude_none = True ).items ():
165+ assert result [key ] == val
163166 assert os .path .exists (instance ._log_file_path )
164167
165168 @patch ("launcher.multiprocessing.Process" )
166169 def test_instance_start_already_running (
167- self , mock_process_class , vllm_config , gpu_translator , tmp_log_dir
170+ self , mock_process_class , vllm_config : VllmConfig , gpu_translator , tmp_log_dir
168171 ):
169172 """Test starting an instance that's already running"""
170173 mock_process = MockProcess ()
@@ -178,10 +181,12 @@ def test_instance_start_already_running(
178181
179182 assert result ["status" ] == "already_running"
180183 assert result ["instance_id" ] == "test-id"
184+ for key , val in vllm_config .model_dump (exclude_none = True ).items ():
185+ assert result [key ] == val
181186
182187 @patch ("launcher.multiprocessing.Process" )
183188 def test_instance_stop (
184- self , mock_process_class , vllm_config , gpu_translator , tmp_log_dir
189+ self , mock_process_class , vllm_config : VllmConfig , gpu_translator , tmp_log_dir
185190 ):
186191 """Test stopping a running instance"""
187192 mock_process = MockProcess ()
@@ -195,6 +200,8 @@ def test_instance_stop(
195200
196201 assert result ["status" ] == "terminated"
197202 assert result ["instance_id" ] == "test-id"
203+ for key , val in vllm_config .model_dump (exclude_none = True ).items ():
204+ assert result [key ] == val
198205 assert mock_process .terminated is True
199206
200207 @patch ("launcher.multiprocessing.Process" )
@@ -203,10 +210,11 @@ def test_instance_stop_not_running(self, vllm_config, gpu_translator, tmp_log_di
203210 instance = VllmInstance (
204211 "test-id" , vllm_config , gpu_translator , log_dir = tmp_log_dir
205212 )
206- result = instance .stop ()
207-
208- assert result ["status" ] == "not_running"
209- assert result ["instance_id" ] == "test-id"
213+ try :
214+ _ = instance .stop ()
215+ assert False
216+ except HalfMade :
217+ assert True
210218
211219 @patch ("launcher.os.killpg" )
212220 @patch ("launcher.multiprocessing.Process" )
@@ -244,7 +252,7 @@ def join_side_effect(timeout=None):
244252
245253 @patch ("launcher.multiprocessing.Process" )
246254 def test_instance_get_status (
247- self , mock_process_class , vllm_config , gpu_translator , tmp_log_dir
255+ self , mock_process_class , vllm_config : VllmConfig , gpu_translator , tmp_log_dir
248256 ):
249257 """Test getting instance status"""
250258 mock_process = MockProcess ()
@@ -258,14 +266,15 @@ def test_instance_get_status(
258266 instance .start ()
259267 status = instance .get_status ()
260268 assert status ["status" ] == "running"
261- assert status [ "options" ] == vllm_config .options
262- assert status ["env_vars" ] == vllm_config . env_vars
269+ for key , val in vllm_config .model_dump ( exclude_none = True ). items ():
270+ assert status [key ] == val
263271
264272 # Stopped
265273 mock_process ._is_alive = False
266274 status = instance .get_status ()
267275 assert status ["status" ] == "stopped"
268- assert status ["options" ] == vllm_config .options
276+ for key , val in vllm_config .model_dump (exclude_none = True ).items ():
277+ assert status [key ] == val
269278
270279 @patch ("launcher.multiprocessing.Process" )
271280 def test_instance_uuid_to_index_translation (
@@ -466,7 +475,7 @@ def test_stop_all_instances(self, mock_process_class, manager, vllm_config):
466475 assert len (manager .instances ) == 0
467476
468477 @patch ("launcher.multiprocessing.Process" )
469- def test_get_instance_status (self , mock_process_class , manager , vllm_config ):
478+ def test_get_instance_status (self , mock_process_class , manager , vllm_config : VllmConfig ):
470479 """Test getting status of specific instance"""
471480 mock_process = MockProcess ()
472481 mock_process_class .return_value = mock_process
@@ -476,8 +485,8 @@ def test_get_instance_status(self, mock_process_class, manager, vllm_config):
476485
477486 assert status ["status" ] == "running"
478487 assert status ["instance_id" ] == "test-id"
479- assert status [ "options" ] == vllm_config .options
480- assert status ["env_vars" ] == vllm_config . env_vars
488+ for key , val in vllm_config .model_dump ( exclude_none = True ). items ():
489+ assert status [key ] == val
481490
482491 @patch ("launcher.multiprocessing.Process" )
483492 def test_get_instance_status_nonexistent (self , mock_process_class , manager ):
@@ -500,8 +509,8 @@ def test_get_all_instances_status(self, mock_process_class, manager, vllm_config
500509 assert status ["running_instances" ] == 2
501510 assert len (status ["instances" ]) == 2
502511 for inst in status ["instances" ]:
503- assert inst [ "options" ] == vllm_config .options
504- assert inst ["env_vars" ] == vllm_config . env_vars
512+ for key , val in vllm_config .model_dump ( exclude_none = True ). items ():
513+ assert inst [key ] == val
505514
506515 @patch ("launcher.multiprocessing.Process" )
507516 def test_list_instances (self , mock_process_class , manager , vllm_config ):
@@ -1073,19 +1082,6 @@ def test_stop_terminated_cleans_up_log_file(
10731082 instance .stop ()
10741083 assert not os .path .exists (instance ._log_file_path )
10751084
1076- @patch ("launcher.multiprocessing.Process" )
1077- def test_stop_not_running_cleans_up_log_file (
1078- self , mock_process_class , gpu_translator , tmp_log_dir
1079- ):
1080- """Test that stop() removes the log file when process is not running"""
1081- instance = self ._make_instance (gpu_translator , tmp_log_dir )
1082- # Create a log file manually
1083- open (instance ._log_file_path , "wb" ).close ()
1084- assert os .path .exists (instance ._log_file_path )
1085-
1086- instance .stop ()
1087- assert not os .path .exists (instance ._log_file_path )
1088-
10891085 def test_cleanup_missing_file_no_error (self , gpu_translator , tmp_log_dir ):
10901086 """Test that _cleanup_log_file does not raise if file doesn't exist"""
10911087 instance = self ._make_instance (gpu_translator , tmp_log_dir )
0 commit comments