|
| 1 | +import pytest |
| 2 | +import re |
| 3 | +from ocp_utilities.infra import get_pods_by_name_prefix |
| 4 | +from pytest_testconfig import py_config |
| 5 | +from simple_logger.logger import get_logger |
| 6 | +from timeout_sampler import TimeoutSampler, TimeoutExpiredError |
| 7 | + |
| 8 | +from tests.model_serving.model_server.utils import verify_inference_response |
| 9 | +from utilities.constants import ( |
| 10 | + ModelFormat, |
| 11 | + ModelInferenceRuntime, |
| 12 | + ModelVersion, |
| 13 | + Protocols, |
| 14 | + Timeout, |
| 15 | +) |
| 16 | +from utilities.exceptions import PodLogMissMatchError |
| 17 | +from utilities.inference_utils import Inference |
| 18 | +from utilities.manifests.onnx import ONNX_INFERENCE_CONFIG |
| 19 | + |
| 20 | +pytestmark = [ |
| 21 | + pytest.mark.serverless, |
| 22 | + pytest.mark.sanity, |
| 23 | + pytest.mark.usefixtures("valid_aws_config"), |
| 24 | +] |
| 25 | + |
| 26 | +LOGGER = get_logger(name=__name__) |
| 27 | + |
| 28 | + |
| 29 | +@pytest.mark.parametrize( |
| 30 | + "model_namespace, openvino_kserve_serving_runtime, ovms_serverless_inference_service", |
| 31 | + [ |
| 32 | + pytest.param( |
| 33 | + {"name": "serverless-maistra"}, |
| 34 | + { |
| 35 | + "runtime-name": ModelInferenceRuntime.ONNX_RUNTIME, |
| 36 | + "model-format": {ModelFormat.ONNX: ModelVersion.OPSET13}, |
| 37 | + }, |
| 38 | + { |
| 39 | + "name": ModelFormat.ONNX, |
| 40 | + "model-version": ModelVersion.OPSET13, |
| 41 | + "model-dir": "test-dir", |
| 42 | + }, |
| 43 | + ) |
| 44 | + ], |
| 45 | + indirect=True, |
| 46 | +) |
| 47 | +class TestNoMaistraErrorInLogs: |
| 48 | + def test_inference_before_isvc_deletion(self, ovms_serverless_inference_service): |
| 49 | + """Verify model can be queried""" |
| 50 | + verify_inference_response( |
| 51 | + inference_service=ovms_serverless_inference_service, |
| 52 | + inference_config=ONNX_INFERENCE_CONFIG, |
| 53 | + inference_type=Inference.INFER, |
| 54 | + protocol=Protocols.HTTPS, |
| 55 | + use_default_query=True, |
| 56 | + ) |
| 57 | + |
| 58 | + def test_pod_logs_do_not_contain_maistra_error(self, deleted_isvc, admin_client): |
| 59 | + """Delete isvc and check pod logs for 'ServiceMeshMemberRoll' error""" |
| 60 | + regex_pattern = r'"error":\s*"no matches for kind \\"ServiceMeshMemberRoll\\" in version \\"maistra\.io/v1\\""' |
| 61 | + pod = get_pods_by_name_prefix( |
| 62 | + client=admin_client, namespace=py_config["applications_namespace"], pod_prefix="odh-model-controller" |
| 63 | + )[0] |
| 64 | + |
| 65 | + try: |
| 66 | + log_sampler = TimeoutSampler( |
| 67 | + wait_timeout=Timeout.TIMEOUT_4MIN, |
| 68 | + sleep=5, |
| 69 | + func=pod.log, |
| 70 | + container="manager", |
| 71 | + tail_lines=500, |
| 72 | + timestamps=True, |
| 73 | + ) |
| 74 | + |
| 75 | + for log_output in log_sampler: |
| 76 | + LOGGER.info("Log output fetched during sampling:") |
| 77 | + if re.search(regex_pattern, log_output): |
| 78 | + raise PodLogMissMatchError("ServiceMeshMemberRoll error found in pod logs") |
| 79 | + |
| 80 | + except TimeoutExpiredError: |
| 81 | + LOGGER.info(f"Error {regex_pattern} not found in {pod.name} logs") |
0 commit comments