generated from RedHatQE/python-template-repository
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[model server] Add a test to check multiple pods can read from the sa…
…me pvc (#17) * sAdd multi pod read-write pvc access * sAdd multi pod read-write pvc access * sAdd multi pod read-write pvc access * addskip if nfs does not exist * add onnx constant * remove junit
- Loading branch information
Showing
6 changed files
with
207 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1 +1,17 @@ | ||
from typing import Any, Dict | ||
|
||
# Models | ||
ONNX_STR: str = "onnx" | ||
|
||
KSERVE_CONTAINER_NAME: str = "kserve-container" | ||
KSERVE_OVMS_SERVING_RUNTIME_PARAMS: Dict[str, Any] = { | ||
"name": "ovms-runtime", | ||
"model-name": ONNX_STR, | ||
"template-name": "kserve-ovms", | ||
"model-version": "1", | ||
"multi-model": False, | ||
} | ||
INFERENCE_SERVICE_PARAMS: Dict[str, str] = {"name": ONNX_STR} | ||
|
||
# Storage | ||
NFS_STR: str = "nfs" |
Empty file.
This file contains 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
43 changes: 43 additions & 0 deletions
43
tests/model_serving/model_server/storage/pvc/test_kserve_pvc_rwx.py
This file contains 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,43 @@ | ||
import shlex | ||
from typing import List | ||
|
||
import pytest | ||
|
||
from tests.model_serving.model_server.storage.constants import ( | ||
INFERENCE_SERVICE_PARAMS, | ||
KSERVE_CONTAINER_NAME, | ||
KSERVE_OVMS_SERVING_RUNTIME_PARAMS, | ||
NFS_STR, | ||
) | ||
|
||
POD_LS_SPLIT_COMMAND: List[str] = shlex.split("ls /mnt/models") | ||
|
||
|
||
pytestmark = pytest.mark.usefixtures("skip_if_no_nfs_storage_class") | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"model_namespace, ci_s3_storage_uri, model_pvc, serving_runtime, inference_service", | ||
[ | ||
pytest.param( | ||
{"name": "pvc-rxw-access"}, | ||
{"model-dir": "test-dir"}, | ||
{"access-modes": "ReadWriteMany", "storage-class-name": NFS_STR}, | ||
KSERVE_OVMS_SERVING_RUNTIME_PARAMS, | ||
INFERENCE_SERVICE_PARAMS | {"deployment-mode": "Serverless", "min-replicas": 2}, | ||
) | ||
], | ||
indirect=True, | ||
) | ||
class TestKservePVCReadWriteManyAccess: | ||
def test_first_isvc_pvc_read_access(self, predictor_pods_scope_class): | ||
predictor_pods_scope_class[0].execute( | ||
container=KSERVE_CONTAINER_NAME, | ||
command=POD_LS_SPLIT_COMMAND, | ||
) | ||
|
||
def test_second_isvc_pvc_read_access(self, predictor_pods_scope_class): | ||
predictor_pods_scope_class[1].execute( | ||
container=KSERVE_CONTAINER_NAME, | ||
command=POD_LS_SPLIT_COMMAND, | ||
) |
This file contains 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 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,46 @@ | ||
from contextlib import contextmanager | ||
|
||
from kubernetes.dynamic import DynamicClient | ||
from ocp_resources.inference_service import InferenceService | ||
|
||
|
||
@contextmanager | ||
def create_isvc( | ||
client: DynamicClient, | ||
name: str, | ||
namespace: str, | ||
deployment_mode: str, | ||
storage_uri: str, | ||
model_format: str, | ||
runtime: str, | ||
min_replicas: int = 1, | ||
wait: bool = True, | ||
) -> InferenceService: | ||
with InferenceService( | ||
client=client, | ||
name=name, | ||
namespace=namespace, | ||
annotations={ | ||
"serving.knative.openshift.io/enablePassthrough": "true", | ||
"sidecar.istio.io/inject": "true", | ||
"sidecar.istio.io/rewriteAppHTTPProbers": "true", | ||
"serving.kserve.io/deploymentMode": deployment_mode, | ||
}, | ||
predictor={ | ||
"minReplicas": min_replicas, | ||
"model": { | ||
"modelFormat": {"name": model_format}, | ||
"version": "1", | ||
"runtime": runtime, | ||
"storageUri": storage_uri, | ||
}, | ||
}, | ||
) as inference_service: | ||
if wait: | ||
inference_service.wait_for_condition( | ||
condition=inference_service.Condition.READY, | ||
status=inference_service.Condition.Status.TRUE, | ||
timeout=10 * 60, | ||
) | ||
|
||
yield inference_service |