-
Notifications
You must be signed in to change notification settings - Fork 94
Speed up local dev loop by reusing llama-stack containers #1895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Jazzcort
wants to merge
1
commit into
lightspeed-core:main
Choose a base branch
from
Jazzcort:speed-up-dev-build
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+82
−55
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -148,9 +148,9 @@ def test_build_llama_stack_image(self, container_runtime): | |
| timeout=PORT_QUERY_TIMEOUT, | ||
| ) | ||
| assert result.returncode == 0, "Failed to list images" | ||
| assert ( | ||
| "lightspeed-llama-stack" in result.stdout | ||
| ), "Image not found in image list" | ||
| assert "lightspeed-llama-stack" in result.stdout, ( | ||
| "Image not found in image list" | ||
| ) | ||
|
|
||
| def test_build_is_idempotent_via_image_id(self, container_runtime): | ||
| """Test that rebuilding without changes yields the exact same Image ID. | ||
|
|
@@ -161,7 +161,13 @@ def test_build_is_idempotent_via_image_id(self, container_runtime): | |
| """ | ||
| # Trigger the first build | ||
| subprocess.run( | ||
| ["make", "build-llama-stack-image"], | ||
| [ | ||
| container_runtime, | ||
| "build", | ||
| "-f", | ||
| "deploy/llama-stack/test.containerfile", | ||
| "lightspeed-llama-stack", | ||
| ], | ||
|
Comment on lines
-164
to
+170
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using make targets ensures we test what users use - there's a chance in the future that the make target could deviate from what's in here, so if we don't test the make targets directly, we'll miss something. |
||
| check=True, | ||
| timeout=CONTAINER_BUILD_TIMEOUT, | ||
| ) | ||
|
|
@@ -170,7 +176,13 @@ def test_build_is_idempotent_via_image_id(self, container_runtime): | |
|
|
||
| # Trigger the second build (should be 100% cached) | ||
| subprocess.run( | ||
| ["make", "build-llama-stack-image"], | ||
| [ | ||
| container_runtime, | ||
| "build", | ||
| "-f", | ||
| "deploy/llama-stack/test.containerfile", | ||
| "lightspeed-llama-stack", | ||
| ], | ||
| check=True, | ||
| timeout=CONTAINER_BUILD_TIMEOUT, | ||
| ) | ||
|
|
@@ -208,9 +220,9 @@ def test_container_is_running(self, container_runtime, managed_container): | |
| text=True, | ||
| timeout=PORT_QUERY_TIMEOUT, | ||
| ) | ||
| assert ( | ||
| managed_container in result.stdout | ||
| ), f"Container {managed_container} not found in running containers" | ||
| assert managed_container in result.stdout, ( | ||
| f"Container {managed_container} not found in running containers" | ||
| ) | ||
|
|
||
| def test_container_becomes_healthy(self, container_runtime, managed_container): | ||
| """Poll engine internal health state until status is healthy. | ||
|
|
@@ -252,12 +264,12 @@ def test_health_endpoint_responds_on_host(self): | |
| url, timeout=HEALTH_CHECK_TIMEOUT | ||
| ) as response: | ||
| body = response.read().decode("utf-8").lower() | ||
| assert ( | ||
| response.status == 200 | ||
| ), f"Health endpoint returned status {response.status}" | ||
| assert ( | ||
| "status" in body | ||
| ), f"Health response missing 'status' field: {body}" | ||
| assert response.status == 200, ( | ||
| f"Health endpoint returned status {response.status}" | ||
| ) | ||
| assert "status" in body, ( | ||
| f"Health response missing 'status' field: {body}" | ||
| ) | ||
| return | ||
| except (urllib.error.URLError, ConnectionError) as e: | ||
| if attempt == NETWORK_BINDING_MAX_ATTEMPTS - 1: # Last attempt | ||
|
|
@@ -282,9 +294,9 @@ def test_default_port_mapping(self, container_runtime, managed_container): | |
| timeout=PORT_QUERY_TIMEOUT, | ||
| ) | ||
| assert result.returncode == 0, "Failed to query port mappings" | ||
| assert ( | ||
| "8321" in result.stdout | ||
| ), f"Port 8321 not found in port mappings: {result.stdout}" | ||
| assert "8321" in result.stdout, ( | ||
| f"Port 8321 not found in port mappings: {result.stdout}" | ||
| ) | ||
|
|
||
| @pytest.mark.parametrize( | ||
| "file_path", | ||
|
|
@@ -311,9 +323,9 @@ def test_required_volumes_mounted( | |
| capture_output=True, | ||
| timeout=HEALTH_CHECK_TIMEOUT, | ||
| ) | ||
| assert ( | ||
| result.returncode == 0 | ||
| ), f"Required mount missing or not a file: {file_path}" | ||
| assert result.returncode == 0, ( | ||
| f"Required mount missing or not a file: {file_path}" | ||
| ) | ||
|
|
||
|
|
||
| class TestContainerCustomConfiguration: | ||
|
|
@@ -348,9 +360,9 @@ def test_custom_port_mapping(self, container_runtime): | |
| timeout=5, | ||
| ) | ||
| assert result.returncode == 0, "Failed to query port mappings" | ||
| assert ( | ||
| custom_port in result.stdout | ||
| ), f"Custom port {custom_port} not found in port mappings: {result.stdout}" | ||
| assert custom_port in result.stdout, ( | ||
| f"Custom port {custom_port} not found in port mappings: {result.stdout}" | ||
| ) | ||
| finally: | ||
| subprocess.run( | ||
| [container_runtime, "rm", "-f", container_name], | ||
|
|
@@ -412,9 +424,9 @@ def test_stop_container_gracefully(self, container_runtime): | |
| text=True, | ||
| timeout=5, | ||
| ) | ||
| assert ( | ||
| container_name not in result.stdout | ||
| ), f"Container {container_name} still running after stop" | ||
| assert container_name not in result.stdout, ( | ||
| f"Container {container_name} still running after stop" | ||
| ) | ||
|
|
||
| finally: | ||
| subprocess.run( | ||
|
|
@@ -464,9 +476,9 @@ def test_remove_container_saves_logs(self, container_runtime): | |
| ) | ||
|
|
||
| # Verify log file was created and is not empty | ||
| assert os.path.exists( | ||
| target_log | ||
| ), f"Container logs were not written to {target_log}" | ||
| assert os.path.exists(target_log), ( | ||
| f"Container logs were not written to {target_log}" | ||
| ) | ||
| assert os.path.getsize(target_log) > 0, "Log file was created but is empty" | ||
|
|
||
| finally: | ||
|
|
@@ -533,9 +545,9 @@ def test_clean_removes_image_and_container(self, container_runtime): | |
| text=True, | ||
| timeout=PORT_QUERY_TIMEOUT, | ||
| ) | ||
| assert ( | ||
| container_name not in result.stdout | ||
| ), f"Container {container_name} still exists after clean" | ||
| assert container_name not in result.stdout, ( | ||
| f"Container {container_name} still exists after clean" | ||
| ) | ||
|
|
||
| # Verify image is removed | ||
| result = subprocess.run( | ||
|
|
@@ -551,7 +563,7 @@ class TestContainerErrorScenarios: | |
| """Test error handling and edge cases.""" | ||
|
|
||
| def test_double_start_replaces_container(self, container_runtime): | ||
| """Test that starting container twice replaces the first instance. | ||
| """Test that starting container twice uses the same instance. | ||
|
|
||
| Parameters | ||
| ---------- | ||
|
|
@@ -615,9 +627,9 @@ def test_double_start_replaces_container(self, container_runtime): | |
| second_id = result.stdout.strip() | ||
|
|
||
| # IDs should be different (new container created) | ||
| assert ( | ||
| first_id != second_id | ||
| ), f"Container was not replaced on second start (ID: {first_id})" | ||
| assert first_id == second_id, ( | ||
| f"Container was replaced on second start (ID: {first_id})" | ||
| ) | ||
|
|
||
| finally: | ||
| subprocess.run( | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with the principal of this 👍🏽
What do you think about moving this logic to a bash script instead of keeping it in the makefile?
That way the Makefile is clean and easy to read/debug in the future