Skip to content

Commit

Permalink
add smoke metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
rnetser committed Jan 3, 2025
1 parent 8bf2f58 commit fea4e6b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
21 changes: 12 additions & 9 deletions tests/model_serving/model_server/metrics/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
import requests
from _pytest.fixtures import FixtureRequest
from kubernetes.dynamic import DynamicClient
from ocp_utilities.monitoring import Prometheus
from simple_logger.logger import get_logger
Expand All @@ -20,12 +21,14 @@ def prometheus(admin_client: DynamicClient) -> Prometheus:
)


@pytest.fixture(scope="class")
def deleted_metrics(prometheus: Prometheus) -> None:
for metric in ("tgi_request_success", "tgi_request_count"):
LOGGER.info(f"deleting {metric} metric")
requests.post(
f"{prometheus.api_url}/api/v1/admin/tsdb/delete_series?match[]={metric}",
headers=prometheus.headers,
verify=prometheus.verify_ssl,
)
@pytest.fixture()
def deleted_metric(request: FixtureRequest, prometheus: Prometheus) -> None:
metric = request.param["metric-name"]

LOGGER.info(f"deleting {metric} metric")

requests.post(
f"{prometheus.api_url}/api/v1/admin/tsdb/delete_series?match[]={metric}",
headers=prometheus.headers,
verify=prometheus.verify_ssl,
)
11 changes: 5 additions & 6 deletions tests/model_serving/model_server/metrics/test_model_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
],
indirect=True,
)
@pytest.mark.usefixtures("deleted_metrics")
class TestModelMetrics:
@pytest.mark.smoke
@pytest.mark.polarion("ODS-2555")
@pytest.mark.dependency(name="test_model_metrics_num_success_requests")
@pytest.mark.parametrize("deleted_metric", [["tgi_request_success"]], indirect=True)
def test_model_metrics_num_success_requests(
self, http_s3_caikit_serverless_inference_service_auth_disabled, prometheus
self, http_s3_caikit_serverless_inference_service_auth_disabled, deleted_metric, prometheus
):
"""Verify number of successful model requests in OpenShift monitoring system (UserWorkloadMonitoring)metrics"""
verify_inference_response(
Expand All @@ -50,9 +49,9 @@ def test_model_metrics_num_success_requests(

@pytest.mark.smoke
@pytest.mark.polarion("ODS-2555")
@pytest.mark.dependency(depends=["test_model_metrics_num_success_requests"])
@pytest.mark.parametrize("deleted_metric", [["tgi_request_count"]], indirect=True)
def test_model_metrics_num_total_requests(
self, http_s3_caikit_serverless_inference_service_auth_disabled, prometheus
self, http_s3_caikit_serverless_inference_service_auth_disabled, deleted_metric, prometheus
):
"""Verify number of total model requests in OpenShift monitoring system (UserWorkloadMonitoring)metrics"""
total_runs = 5
Expand All @@ -69,5 +68,5 @@ def test_model_metrics_num_total_requests(
validate_metrics_value(
prometheus=prometheus,
metric_name="tgi_request_count",
expected_value=str(total_runs + 1),
expected_value=str(total_runs),
)

0 comments on commit fea4e6b

Please sign in to comment.