88import time
99import urllib .error
1010import urllib .request
11+ from collections .abc import Generator
1112
1213import pytest
1314
2627
2728
2829@pytest .fixture (scope = "session" )
29- def container_runtime ():
30+ def container_runtime () -> str :
3031 """Detect available container runtime (podman or docker).
3132
3233 Returns
@@ -52,7 +53,7 @@ def container_runtime():
5253
5354
5455@pytest .fixture (scope = "class" )
55- def managed_container (container_runtime ) :
56+ def managed_container (container_runtime : str ) -> Generator [ str , None , None ] :
5657 """Start container once for entire test class with strict cleanup.
5758
5859 Parameters
@@ -100,7 +101,9 @@ def managed_container(container_runtime):
100101class TestContainerBuild :
101102 """Test container image building with idempotency checks."""
102103
103- def _get_image_id (self , runtime , image_name = "lightspeed-llama-stack:local" ):
104+ def _get_image_id (
105+ self , runtime : str , image_name : str = "lightspeed-llama-stack:local"
106+ ) -> str :
104107 """Get the unique, immutable Image ID (SHA256).
105108
106109 Parameters
@@ -121,7 +124,7 @@ def _get_image_id(self, runtime, image_name="lightspeed-llama-stack:local"):
121124 )
122125 return result .stdout .strip ()
123126
124- def test_build_llama_stack_image (self , container_runtime ) :
127+ def test_build_llama_stack_image (self , container_runtime : str ) -> None :
125128 """Test that llama-stack image builds successfully and exists.
126129
127130 Parameters
@@ -152,7 +155,7 @@ def test_build_llama_stack_image(self, container_runtime):
152155 "lightspeed-llama-stack" in result .stdout
153156 ), "Image not found in image list"
154157
155- def test_build_is_idempotent_via_image_id (self , container_runtime ) :
158+ def test_build_is_idempotent_via_image_id (self , container_runtime : str ) -> None :
156159 """Test that rebuilding without changes yields the exact same Image ID.
157160
158161 Parameters
@@ -187,7 +190,9 @@ def test_build_is_idempotent_via_image_id(self, container_runtime):
187190class TestLlamaStackDeployment :
188191 """Consolidated lifecycle, networking, and configuration verification."""
189192
190- def test_container_is_running (self , container_runtime , managed_container ):
193+ def test_container_is_running (
194+ self , container_runtime : str , managed_container : str
195+ ) -> None :
191196 """Verify container appears in the runtime's active process list.
192197
193198 Parameters
@@ -212,7 +217,9 @@ def test_container_is_running(self, container_runtime, managed_container):
212217 managed_container in result .stdout
213218 ), f"Container { managed_container } not found in running containers"
214219
215- def test_container_becomes_healthy (self , container_runtime , managed_container ):
220+ def test_container_becomes_healthy (
221+ self , container_runtime : str , managed_container : str
222+ ) -> None :
216223 """Poll engine internal health state until status is healthy.
217224
218225 Parameters
@@ -241,7 +248,7 @@ def test_container_becomes_healthy(self, container_runtime, managed_container):
241248 f"(attempts: { HEALTH_CHECK_MAX_ATTEMPTS } )."
242249 )
243250
244- def test_health_endpoint_responds_on_host (self ):
251+ def test_health_endpoint_responds_on_host (self ) -> None :
245252 """Verify HTTP API accessibility from host without container-side curl."""
246253 url = "http://localhost:8321/v1/health"
247254
@@ -267,7 +274,9 @@ def test_health_endpoint_responds_on_host(self):
267274 )
268275 time .sleep (1 )
269276
270- def test_default_port_mapping (self , container_runtime , managed_container ):
277+ def test_default_port_mapping (
278+ self , container_runtime : str , managed_container : str
279+ ) -> None :
271280 """Verify internal port 8321 binds properly.
272281
273282 Parameters
@@ -296,8 +305,8 @@ def test_default_port_mapping(self, container_runtime, managed_container):
296305 ],
297306 )
298307 def test_required_volumes_mounted (
299- self , container_runtime , managed_container , file_path
300- ):
308+ self , container_runtime : str , managed_container : str , file_path : str
309+ ) -> None :
301310 """Parametrized verification of all critical configuration and script mounts.
302311
303312 Parameters
@@ -319,7 +328,7 @@ def test_required_volumes_mounted(
319328class TestContainerCustomConfiguration :
320329 """Isolates tests that require distinct runtime configurations."""
321330
322- def test_custom_port_mapping (self , container_runtime ) :
331+ def test_custom_port_mapping (self , container_runtime : str ) -> None :
323332 """Verify alternative port bindings parameterize correctly.
324333
325334 Parameters
@@ -363,7 +372,7 @@ def test_custom_port_mapping(self, container_runtime):
363372class TestContainerTeardown :
364373 """Test container cleanup and resource management."""
365374
366- def test_stop_container_gracefully (self , container_runtime ) :
375+ def test_stop_container_gracefully (self , container_runtime : str ) -> None :
367376 """Test that container stops gracefully within timeout.
368377
369378 Parameters
@@ -424,7 +433,7 @@ def test_stop_container_gracefully(self, container_runtime):
424433 timeout = 10 ,
425434 )
426435
427- def test_remove_container_saves_logs (self , container_runtime ) :
436+ def test_remove_container_saves_logs (self , container_runtime : str ) -> None :
428437 """Test that removing container saves logs to a clean, unique file path.
429438
430439 Parameters
@@ -479,7 +488,7 @@ def test_remove_container_saves_logs(self, container_runtime):
479488
480489 @pytest .mark .order ("last" )
481490 @pytest .mark .destructive
482- def test_clean_removes_image_and_container (self , container_runtime ) :
491+ def test_clean_removes_image_and_container (self , container_runtime : str ) -> None :
483492 """Test that clean target removes assets. Runs last to avoid deleting dev images.
484493
485494 Parameters
@@ -550,7 +559,7 @@ def test_clean_removes_image_and_container(self, container_runtime):
550559class TestContainerErrorScenarios :
551560 """Test error handling and edge cases."""
552561
553- def test_double_start_replaces_container (self , container_runtime ) :
562+ def test_double_start_replaces_container (self , container_runtime : str ) -> None :
554563 """Test that starting container twice replaces the first instance.
555564
556565 Parameters
0 commit comments