|
| 1 | +import pytest |
| 2 | +from ocp_utilities.infra import get_pods_by_name_prefix |
| 3 | +from pytest_testconfig import py_config |
| 4 | +from simple_logger.logger import get_logger |
| 5 | +from timeout_sampler import TimeoutSampler, TimeoutExpiredError |
| 6 | + |
| 7 | +from tests.model_serving.model_server.utils import verify_inference_response |
| 8 | +from utilities.constants import ( |
| 9 | + ModelFormat, |
| 10 | + ModelInferenceRuntime, |
| 11 | + ModelVersion, |
| 12 | + Protocols, |
| 13 | + Timeout, |
| 14 | +) |
| 15 | +from utilities.exceptions import PodLogMissMatchError |
| 16 | +from utilities.inference_utils import Inference |
| 17 | +from utilities.manifests.onnx import ONNX_INFERENCE_CONFIG |
| 18 | + |
| 19 | +pytestmark = [ |
| 20 | + pytest.mark.serverless, |
| 21 | + pytest.mark.sanity, |
| 22 | + pytest.mark.usefixtures("valid_aws_config"), |
| 23 | +] |
| 24 | + |
| 25 | +LOGGER = get_logger(name=__name__) |
| 26 | + |
| 27 | + |
| 28 | +@pytest.mark.serverless |
| 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 TestLogForOdHModelController: |
| 48 | + def test_odh_model_controller_failing_while_deleted_isvc(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_moniter_odh_logs_doe_maistra(self, deleted_isvc, admin_client): |
| 59 | + """Delete isvc and check pod logs for unexpected 'Maistra' string""" |
| 60 | + search_string = "maistra.io" |
| 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_1MIN, |
| 68 | + sleep=5, |
| 69 | + func=lambda: pod.log(container="manager", tail_lines=100, timestamps=True), |
| 70 | + ) |
| 71 | + |
| 72 | + for log_output in log_sampler: |
| 73 | + LOGGER.info("Log output fetched during sampling:") |
| 74 | + if search_string in log_output: |
| 75 | + raise PodLogMissMatchError(f"'{search_string}' was found in pod logs") |
| 76 | + LOGGER.info(f"'{search_string}' was not found in pod logs within timeout") |
| 77 | + |
| 78 | + except TimeoutExpiredError as e: |
| 79 | + LOGGER.error(f"Timeout while sampling logs: {str(e)}") |
0 commit comments