-
Notifications
You must be signed in to change notification settings - Fork 64
Adding Test For InferenceService Zero Initial Scale #262
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
rnetser
merged 10 commits into
opendatahub-io:main
from
brettmthompson:feature/add-zero-initial-scale-test
Apr 25, 2025
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f5b1f06
adding test for zero initial scale
brettmthompson da7461d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 569244c
Merge branch 'main' into feature/add-zero-initial-scale-test
brettmthompson f435cc1
fixing precommit error
brettmthompson 8b9a228
using label_selectors when getting deployment
brettmthompson cc09aed
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0a374f3
Merge branch 'main' into feature/add-zero-initial-scale-test
brettmthompson 2661c4a
adding argument names to func call and running pre-commit on all files
brettmthompson 57f5dc0
fixing bug in ovms_kserve_inference_service function that was prevent…
brettmthompson bac50fd
Merge branch 'main' into feature/add-zero-initial-scale-test
brettmthompson 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
93 changes: 93 additions & 0 deletions
93
tests/model_serving/model_server/serverless/test_zero_initial_scale.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,93 @@ | ||
| import pytest | ||
| from ocp_resources.deployment import Deployment | ||
|
|
||
| from tests.model_serving.model_server.serverless.constants import ( | ||
| ONNX_SERVERLESS_INFERENCE_SERVICE_CONFIG, | ||
| ) | ||
| from tests.model_serving.model_server.serverless.utils import verify_no_inference_pods | ||
| from tests.model_serving.model_server.utils import verify_inference_response | ||
| from utilities.constants import ( | ||
| Protocols, | ||
| RunTimeConfigs, | ||
| ) | ||
| from utilities.exceptions import DeploymentValidationError | ||
| from utilities.general import create_isvc_label_selector_str | ||
| from utilities.inference_utils import Inference | ||
| from utilities.manifests.onnx import ONNX_INFERENCE_CONFIG | ||
|
|
||
| pytestmark = [ | ||
| pytest.mark.serverless, | ||
| pytest.mark.sanity, | ||
| pytest.mark.usefixtures("valid_aws_config"), | ||
| ] | ||
|
|
||
|
|
||
| @pytest.mark.serverless | ||
| @pytest.mark.parametrize( | ||
| "model_namespace, ovms_kserve_serving_runtime, ovms_kserve_inference_service", | ||
| [ | ||
| pytest.param( | ||
| {"name": "serverless-initial-scale-zero"}, | ||
| RunTimeConfigs.ONNX_OPSET13_RUNTIME_CONFIG, | ||
| { | ||
| **ONNX_SERVERLESS_INFERENCE_SERVICE_CONFIG, | ||
| "min-replicas": 0, | ||
| }, | ||
| ) | ||
| ], | ||
| indirect=True, | ||
| ) | ||
| class TestServerlessInitialScaleZero: | ||
| @pytest.mark.dependency(name="test_no_serverless_pods_created_for_zero_initial_scale") | ||
| def test_no_serverless_pods_created_for_zero_initial_scale(self, admin_client, ovms_kserve_inference_service): | ||
| """Verify no pods are created when inference service initial scale is zero, i.e. zero min-replicas requested.""" | ||
| verify_no_inference_pods(client=admin_client, isvc=ovms_kserve_inference_service) | ||
|
|
||
| @pytest.mark.dependency(name="test_no_serverless_replicas_created_for_zero_initial_scale") | ||
| def test_no_serverless_replicas_created_for_zero_initial_scale( | ||
| self, admin_client, ovms_kserve_inference_service, ovms_kserve_serving_runtime | ||
| ): | ||
| """Verify replica count is zero when inference service initial scale is zero""" | ||
| labels = [ | ||
| "serving.knative.dev/configurationGeneration=1", | ||
| create_isvc_label_selector_str( | ||
| isvc=ovms_kserve_inference_service, | ||
| resource_type="depoyment", | ||
| runtime_name=ovms_kserve_serving_runtime.name, | ||
| ), | ||
| ] | ||
|
|
||
| deployments = list( | ||
| Deployment.get( | ||
| label_selector=",".join(labels), client=admin_client, namespace=ovms_kserve_inference_service.namespace | ||
| ) | ||
| ) | ||
|
|
||
| if not deployments: | ||
| raise DeploymentValidationError( | ||
| f"Inference Service {ovms_kserve_inference_service.name} new deployment not found" | ||
| ) | ||
|
|
||
| if deployments[0].instance.spec.replicas == 0: | ||
| deployments[0].wait_for_replicas() | ||
| return | ||
|
|
||
| raise DeploymentValidationError( | ||
| f"Inference Service {ovms_kserve_inference_service.name} deployment should have 0 replicas when created" | ||
| ) | ||
|
|
||
| @pytest.mark.dependency( | ||
| depends=[ | ||
| "test_no_serverless_pods_created_for_zero_initial_scale", | ||
| "test_no_serverless_replicas_created_for_zero_initial_scale", | ||
| ] | ||
| ) | ||
| def test_serverless_inference_after_zero_initial_scale(self, ovms_kserve_inference_service): | ||
| """Verify model can be queried after being created with an initial scale of zero.""" | ||
| 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, | ||
| ) | ||
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.