-
Notifications
You must be signed in to change notification settings - Fork 64
Upgrade tests for llm-d #1206
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
Merged
Merged
Upgrade tests for llm-d #1206
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
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
117 changes: 117 additions & 0 deletions
117
tests/model_serving/model_server/upgrade/test_upgrade_llmd.py
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 |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| import pytest | ||
| from ocp_resources.gateway import Gateway | ||
| from ocp_resources.llm_inference_service import LLMInferenceService | ||
|
|
||
| from tests.model_serving.model_server.llmd.utils import ( | ||
| parse_completion_text, | ||
| send_chat_completions, | ||
| ) | ||
| from tests.model_serving.model_server.upgrade.utils import ( | ||
| verify_gateway_accepted, | ||
| verify_llmd_pods_not_restarted, | ||
| verify_llmd_router_not_restarted, | ||
| ) | ||
|
|
||
| pytestmark = [pytest.mark.llmd_cpu] | ||
|
|
||
| PROMPT = "What is the capital of Italy?" | ||
| EXPECTED_ANSWER = "rome" | ||
|
|
||
|
|
||
| class TestLlmdPreUpgrade: | ||
| """Pre-upgrade: deploy LLMD InferenceService and validate inference.""" | ||
|
|
||
| @pytest.mark.pre_upgrade | ||
| def test_llmd_llmisvc_deployed(self, llmd_inference_service_fixture: LLMInferenceService): | ||
| """Test steps: | ||
|
|
||
| 1. Verify LLMInferenceService resource exists on the cluster. | ||
| """ | ||
| assert llmd_inference_service_fixture.exists, ( | ||
| f"LLMInferenceService {llmd_inference_service_fixture.name} does not exist" | ||
| ) | ||
|
|
||
| @pytest.mark.pre_upgrade | ||
| def test_llmd_inference_pre_upgrade(self, llmd_inference_service_fixture: LLMInferenceService): | ||
| """Test steps: | ||
|
|
||
| 1. Send a chat completion request to /v1/chat/completions. | ||
| 2. Assert the response status is 200. | ||
| 3. Assert the completion text contains the expected answer. | ||
| """ | ||
| status, body = send_chat_completions(llmisvc=llmd_inference_service_fixture, prompt=PROMPT) | ||
| assert status == 200, f"Expected 200, got {status}: {body}" | ||
| completion = parse_completion_text(response_body=body) | ||
| assert EXPECTED_ANSWER in completion.lower(), f"Expected '{EXPECTED_ANSWER}' in response, got: {completion}" | ||
|
|
||
|
|
||
| class TestLlmdPostUpgrade: | ||
| """Post-upgrade: verify LLMD deployment survived the platform upgrade.""" | ||
|
|
||
| @pytest.mark.post_upgrade | ||
| @pytest.mark.dependency(name="llmd_llmisvc_exists") | ||
| def test_llmd_llmisvc_exists(self, llmd_inference_service_fixture: LLMInferenceService): | ||
| """Test steps: | ||
|
|
||
| 1. Verify LLMInferenceService resource still exists after upgrade. | ||
| """ | ||
| assert llmd_inference_service_fixture.exists, ( | ||
| f"LLMInferenceService {llmd_inference_service_fixture.name} does not exist after upgrade" | ||
| ) | ||
|
|
||
| @pytest.mark.post_upgrade | ||
| def test_llmd_gateway_exists(self, llmd_gateway_fixture: Gateway): | ||
| """Test steps: | ||
|
|
||
| 1. Verify the LLMD Gateway resource exists. | ||
| 2. Verify the Gateway has an Accepted condition set to True. | ||
| """ | ||
| verify_gateway_accepted(gateway=llmd_gateway_fixture) | ||
|
|
||
| @pytest.mark.post_upgrade | ||
| @pytest.mark.dependency(depends=["llmd_llmisvc_exists"]) | ||
| def test_llmd_workload_pods_not_restarted( | ||
| self, | ||
| admin_client, | ||
| llmd_inference_service_fixture: LLMInferenceService, | ||
| ): | ||
| """Test steps: | ||
|
|
||
| 1. Get all workload pods for the LLMInferenceService. | ||
| 2. Verify no container has restarted during the upgrade. | ||
| """ | ||
| verify_llmd_pods_not_restarted( | ||
| client=admin_client, | ||
| llmisvc=llmd_inference_service_fixture, | ||
| ) | ||
|
|
||
| @pytest.mark.post_upgrade | ||
| @pytest.mark.dependency(depends=["llmd_llmisvc_exists"]) | ||
| def test_llmd_router_scheduler_not_restarted( | ||
| self, | ||
| admin_client, | ||
| llmd_inference_service_fixture: LLMInferenceService, | ||
| ): | ||
| """Test steps: | ||
|
|
||
| 1. Get the router-scheduler pod for the LLMInferenceService. | ||
| 2. Verify no container has restarted during the upgrade. | ||
| """ | ||
| verify_llmd_router_not_restarted( | ||
| client=admin_client, | ||
| llmisvc=llmd_inference_service_fixture, | ||
| ) | ||
|
|
||
| @pytest.mark.post_upgrade | ||
| @pytest.mark.dependency(depends=["llmd_llmisvc_exists"]) | ||
| def test_llmd_inference_post_upgrade(self, llmd_inference_service_fixture: LLMInferenceService): | ||
| """Test steps: | ||
|
|
||
| 1. Send a chat completion request to /v1/chat/completions. | ||
| 2. Assert the response status is 200. | ||
| 3. Assert the completion text contains the expected answer. | ||
| """ | ||
| status, body = send_chat_completions(llmisvc=llmd_inference_service_fixture, prompt=PROMPT) | ||
| assert status == 200, f"Expected 200, got {status}: {body}" | ||
| completion = parse_completion_text(response_body=body) | ||
| assert EXPECTED_ANSWER in completion.lower(), f"Expected '{EXPECTED_ANSWER}' in response, got: {completion}" |
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
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.
Uh oh!
There was an error while loading. Please reload this page.