-
Notifications
You must be signed in to change notification settings - Fork 63
Tests for stopping and resuming an ISVC #370
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
israel-hdez
merged 35 commits into
opendatahub-io:main
from
hdefazio:feat/stop_resume_model
Jul 7, 2025
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
342a5e4
Rough draft for adding tests for stopping and resuming an ISVC
hdefazio 5f652d9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1ac50f0
RHOAIENG-19886-created raw stop_resume tests. Fixed stop_resume serve…
andresllh 2d4dd0d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1faaafa
Update utilities/inference_utils.py
hdefazio b0d5fd6
RHOAIENG-19886-created raw stop_resume tests. Created fixture for pat…
andresllh 662895f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] bb18da3
Merge branch 'main' into feat/stop_resume_model
andresllh 0fa989f
Merge branch 'main' into feat/stop_resume_model
hdefazio 32a885e
RHOAIENG-19886-created raw stop_resume tests. Addressed Edgar's PR co…
andresllh c5fa6c0
Merge branch 'feat/stop_resume_model' of github.com:hdefazio/opendata…
andresllh b236e00
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 772c4de
Merge branch 'main' into feat/stop_resume_model
andresllh 0184d7c
RHOAIENG-19886-created raw stop_resume tests. Addressed Brett and Edg…
andresllh 76e5215
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1e71542
RHOAIENG-19886-created raw stop_resume tests. Addressed Brett and Edg…
andresllh f7071fa
Merge branch 'feat/stop_resume_model' of github.com:hdefazio/opendata…
andresllh ba27c5c
RHOAIENG-19886-created raw stop_resume tests. Addressed Brett and Edg…
andresllh 011d0b8
RHOAIENG-19886-created raw stop_resume tests. Addressed Milind and Br…
andresllh eb202d8
Merge branch 'main' into feat/stop_resume_model
andresllh 800b496
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] edce9a7
RHOAIENG-19886-created raw stop_resume tests. Fix precommit issues.
andresllh 1571e56
Merge branch 'feat/stop_resume_model' of github.com:hdefazio/opendata…
andresllh 7f4867f
RHOAIENG-19886-created raw stop_resume tests. Cleaning up.
andresllh 53cb343
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 85fb2f0
RHOAIENG-19886-created raw stop_resume tests. Reworked nested time sa…
andresllh 69f8e4a
Merge branch 'feat/stop_resume_model' of github.com:hdefazio/opendata…
andresllh f9a3091
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 9ce8022
RHOAIENG-19886-created raw stop_resume tests. Fix precommit issues.
andresllh 6fb0c3b
Merge branch 'feat/stop_resume_model' of github.com:hdefazio/opendata…
andresllh 3af8532
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 861e86e
RHOAIENG-19886-created raw stop_resume tests. Fix precommit issues.
andresllh 3344265
Merge branch 'feat/stop_resume_model' of github.com:hdefazio/opendata…
andresllh 47889cd
Merge branch 'main' into feat/stop_resume_model
andresllh 5ae2f5c
Merge branch 'main' into feat/stop_resume_model
andresllh 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
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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| from typing import Generator, Any | ||
|
|
||
| import pytest | ||
| from ocp_resources.inference_service import InferenceService | ||
| from ocp_resources.resource import ResourceEditor | ||
| from utilities.constants import Annotations | ||
|
|
||
|
|
||
| @pytest.fixture(scope="function") | ||
| def patched_inference_service_stop_annotation( | ||
| request: pytest.FixtureRequest, | ||
| ovms_kserve_inference_service: InferenceService, | ||
| ) -> Generator[InferenceService, Any, Any]: | ||
| with ResourceEditor( | ||
| patches={ | ||
| ovms_kserve_inference_service: { | ||
| "metadata": { | ||
| "annotations": {Annotations.KserveIo.FORCE_STOP_RUNTIME: request.param.get("stop", "false")} | ||
| }, | ||
| } | ||
| } | ||
| ): | ||
| yield ovms_kserve_inference_service | ||
|
|
||
|
|
||
| @pytest.fixture(scope="function") | ||
| def patched_raw_inference_service_stop_annotation( | ||
| request: pytest.FixtureRequest, | ||
| ovms_raw_inference_service: InferenceService, | ||
| ) -> Generator[InferenceService, Any, Any]: | ||
| with ResourceEditor( | ||
| patches={ | ||
| ovms_raw_inference_service: { | ||
| "metadata": { | ||
| "annotations": {Annotations.KserveIo.FORCE_STOP_RUNTIME: request.param.get("stop", "false")} | ||
| }, | ||
| } | ||
| } | ||
| ): | ||
| yield ovms_raw_inference_service |
125 changes: 125 additions & 0 deletions
125
tests/model_serving/model_server/stop_resume/test_raw_stop_resume_model.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,125 @@ | ||
| import pytest | ||
|
|
||
| from tests.model_serving.model_server.utils import verify_inference_response | ||
| from utilities.constants import ( | ||
| ModelFormat, | ||
| ModelVersion, | ||
| Protocols, | ||
| RunTimeConfigs, | ||
| ) | ||
| from utilities.inference_utils import Inference | ||
| from utilities.manifests.onnx import ONNX_INFERENCE_CONFIG | ||
| from tests.model_serving.model_server.stop_resume.utils import consistently_verify_no_pods_exist | ||
|
|
||
| pytestmark = [pytest.mark.serverless, pytest.mark.usefixtures("valid_aws_config")] | ||
|
|
||
|
|
||
| @pytest.mark.rawdeployment | ||
| @pytest.mark.smoke | ||
| @pytest.mark.parametrize( | ||
| "unprivileged_model_namespace, ovms_kserve_serving_runtime, ovms_raw_inference_service", | ||
| [ | ||
| pytest.param( | ||
| {"name": "kserve-raw-stop-resume"}, | ||
| RunTimeConfigs.ONNX_OPSET13_RUNTIME_CONFIG, | ||
| { | ||
| "name": ModelFormat.ONNX, | ||
| "model-version": ModelVersion.OPSET13, | ||
| "model-dir": "test-dir", | ||
| "stop": False, | ||
| }, | ||
| ) | ||
| ], | ||
| indirect=True, | ||
| ) | ||
| class TestStopRaw: | ||
| def test_raw_onnx_rest_inference( | ||
israel-hdez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| self, unprivileged_model_namespace, ovms_kserve_serving_runtime, ovms_raw_inference_service | ||
| ): | ||
| """Verify that kserve Raw ONNX model can be queried using REST""" | ||
| verify_inference_response( | ||
| inference_service=ovms_raw_inference_service, | ||
| inference_config=ONNX_INFERENCE_CONFIG, | ||
| inference_type=Inference.INFER, | ||
| protocol=Protocols.HTTPS, | ||
| use_default_query=True, | ||
| ) | ||
|
|
||
| @pytest.mark.parametrize( | ||
| "patched_raw_inference_service_stop_annotation", | ||
| [pytest.param({"stop": "true"})], | ||
| indirect=True, | ||
| ) | ||
| def test_stop_and_update_to_true_delete_pod_rollout( | ||
| self, | ||
| unprivileged_client, | ||
| unprivileged_model_namespace, | ||
| ovms_kserve_serving_runtime, | ||
| ovms_raw_inference_service, | ||
| patched_raw_inference_service_stop_annotation, | ||
| ): | ||
| """Verify pod rollout is deleted when the stop annotation updated to true""" | ||
| """Verify pods do not exist""" | ||
| result = consistently_verify_no_pods_exist( | ||
| client=unprivileged_client, | ||
| isvc=patched_raw_inference_service_stop_annotation, | ||
| ) | ||
| assert result, "Verification failed: pods were found when none should exist" | ||
|
|
||
|
|
||
| @pytest.mark.rawdeployment | ||
| @pytest.mark.smoke | ||
| @pytest.mark.parametrize( | ||
| "unprivileged_model_namespace, ovms_kserve_serving_runtime, ovms_raw_inference_service", | ||
| [ | ||
| pytest.param( | ||
| {"name": "kserve-raw-stop-resume"}, | ||
| RunTimeConfigs.ONNX_OPSET13_RUNTIME_CONFIG, | ||
| { | ||
| "name": ModelFormat.ONNX, | ||
| "model-version": ModelVersion.OPSET13, | ||
| "model-dir": "test-dir", | ||
| "stop": True, | ||
| }, | ||
| ) | ||
| ], | ||
| indirect=True, | ||
| ) | ||
| class TestStoppedResumeRaw: | ||
| def test_stop_and_true_no_pod_rollout( | ||
| self, | ||
| unprivileged_client, | ||
| unprivileged_model_namespace, | ||
| ovms_kserve_serving_runtime, | ||
| ovms_raw_inference_service, | ||
| ): | ||
| """Verify no pod rollout when the stop annotation is true""" | ||
| """Verify pods do not exist""" | ||
| result = consistently_verify_no_pods_exist( | ||
| client=unprivileged_client, | ||
| isvc=ovms_raw_inference_service, | ||
| ) | ||
| assert result, "Verification failed: pods were found when none should exist" | ||
|
|
||
| @pytest.mark.parametrize( | ||
| "patched_raw_inference_service_stop_annotation", | ||
| [pytest.param({"stop": "false"})], | ||
| indirect=True, | ||
| ) | ||
| def test_stop_and_update_to_false_pod_rollout( | ||
| self, | ||
| unprivileged_client, | ||
| unprivileged_model_namespace, | ||
| ovms_kserve_serving_runtime, | ||
| ovms_raw_inference_service, | ||
| patched_raw_inference_service_stop_annotation, | ||
| ): | ||
| """Verify pod rollout when the stop annotation is updated to false""" | ||
| """Verify that kserve Raw ONNX model can be queried using REST""" | ||
| verify_inference_response( | ||
israel-hdez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| inference_service=patched_raw_inference_service_stop_annotation, | ||
| inference_config=ONNX_INFERENCE_CONFIG, | ||
| inference_type=Inference.INFER, | ||
| protocol=Protocols.HTTPS, | ||
| use_default_query=True, | ||
| ) | ||
128 changes: 128 additions & 0 deletions
128
tests/model_serving/model_server/stop_resume/test_serverless_stop_resume_model.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,128 @@ | ||
| import pytest | ||
israel-hdez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| from tests.model_serving.model_server.utils import verify_inference_response | ||
| from utilities.constants import ( | ||
| KServeDeploymentType, | ||
| ModelFormat, | ||
| ModelVersion, | ||
| Protocols, | ||
| RunTimeConfigs, | ||
| ) | ||
| from utilities.inference_utils import Inference | ||
| from utilities.manifests.onnx import ONNX_INFERENCE_CONFIG | ||
| from tests.model_serving.model_server.stop_resume.utils import consistently_verify_no_pods_exist | ||
|
|
||
| pytestmark = [pytest.mark.serverless, pytest.mark.usefixtures("valid_aws_config")] | ||
|
|
||
|
|
||
| @pytest.mark.serverless | ||
| @pytest.mark.smoke | ||
| @pytest.mark.parametrize( | ||
| "unprivileged_model_namespace, ovms_kserve_serving_runtime, ovms_kserve_inference_service", | ||
| [ | ||
| pytest.param( | ||
| {"name": "kserve-serverless-stop-resume"}, | ||
| RunTimeConfigs.ONNX_OPSET13_RUNTIME_CONFIG, | ||
| { | ||
| "name": ModelFormat.ONNX, | ||
| "model-version": ModelVersion.OPSET13, | ||
| "model-dir": "test-dir", | ||
| "deployment-mode": KServeDeploymentType.SERVERLESS, | ||
| "stop": False, | ||
| }, | ||
| ) | ||
| ], | ||
| indirect=True, | ||
| ) | ||
| class TestStopServerless: | ||
| def test_serverless_onnx_rest_inference( | ||
| self, unprivileged_model_namespace, ovms_kserve_serving_runtime, ovms_kserve_inference_service | ||
| ): | ||
| """Verify that kserve Serverless ONNX model can be queried using REST""" | ||
| verify_inference_response( | ||
| inference_service=ovms_kserve_inference_service, | ||
| inference_config=ONNX_INFERENCE_CONFIG, | ||
| inference_type=Inference.INFER, | ||
| protocol=Protocols.HTTPS, | ||
| use_default_query=True, | ||
| ) | ||
|
|
||
| @pytest.mark.parametrize( | ||
| "patched_inference_service_stop_annotation", | ||
| [pytest.param({"stop": "true"})], | ||
| indirect=True, | ||
| ) | ||
| def test_stop_and_update_to_true_delete_pod_rollout( | ||
| self, | ||
| unprivileged_client, | ||
| unprivileged_model_namespace, | ||
| ovms_kserve_serving_runtime, | ||
| ovms_kserve_inference_service, | ||
| patched_inference_service_stop_annotation, | ||
| ): | ||
| """Verify pod rollout is deleted when the stop annotation updated to true""" | ||
| """Verify pods do not exist""" | ||
| result = consistently_verify_no_pods_exist( | ||
| client=unprivileged_client, | ||
| isvc=patched_inference_service_stop_annotation, | ||
| ) | ||
| assert result, "Verification failed: pods were found when none should exist" | ||
|
|
||
|
|
||
| @pytest.mark.serverless | ||
| @pytest.mark.smoke | ||
| @pytest.mark.parametrize( | ||
| "unprivileged_model_namespace, ovms_kserve_serving_runtime, ovms_kserve_inference_service", | ||
| [ | ||
| pytest.param( | ||
| {"name": "kserve-serverless-stop-resume"}, | ||
| RunTimeConfigs.ONNX_OPSET13_RUNTIME_CONFIG, | ||
| { | ||
| "name": ModelFormat.ONNX, | ||
| "model-version": ModelVersion.OPSET13, | ||
| "model-dir": "test-dir", | ||
| "deployment-mode": KServeDeploymentType.SERVERLESS, | ||
| "stop": True, | ||
| }, | ||
| ) | ||
| ], | ||
| indirect=True, | ||
| ) | ||
| class TestStoppedResumeServerless: | ||
| def test_stop_and_true_no_pod_rollout( | ||
| self, | ||
| unprivileged_client, | ||
| unprivileged_model_namespace, | ||
| ovms_kserve_serving_runtime, | ||
| ovms_kserve_inference_service, | ||
| ): | ||
| """Verify no pod rollout when the stop annotation is true""" | ||
| """Verify pods do not exist""" | ||
| result = consistently_verify_no_pods_exist( | ||
| client=unprivileged_client, | ||
| isvc=ovms_kserve_inference_service, | ||
| ) | ||
| assert result, "Verification failed: pods were found when none should exist" | ||
|
|
||
| @pytest.mark.parametrize( | ||
| "patched_inference_service_stop_annotation", | ||
| [pytest.param({"stop": "false"})], | ||
| indirect=True, | ||
| ) | ||
| def test_stop_and_update_to_false_pod_rollout( | ||
| self, | ||
| unprivileged_client, | ||
| unprivileged_model_namespace, | ||
| ovms_kserve_serving_runtime, | ||
| ovms_kserve_inference_service, | ||
| patched_inference_service_stop_annotation, | ||
| ): | ||
| """Verify pod rollout when the stop annotation is updated to false""" | ||
| """Verify that kserve Serverless ONNX model can be queried using REST""" | ||
| verify_inference_response( | ||
| inference_service=patched_inference_service_stop_annotation, | ||
| inference_config=ONNX_INFERENCE_CONFIG, | ||
| inference_type=Inference.INFER, | ||
| protocol=Protocols.HTTPS, | ||
| use_default_query=True, | ||
| ) | ||
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.