Skip to content
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

test: Tests for Metrics API enhancement to include error counters #7423

Merged
merged 13 commits into from
Jul 12, 2024
26 changes: 25 additions & 1 deletion qa/L0_request_cancellation/scheduler_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
indrajit96 marked this conversation as resolved.
Show resolved Hide resolved
# Copyright 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -31,6 +31,7 @@
import unittest

import numpy as np
import requests
import tritonclient.grpc as grpcclient
from tritonclient.utils import InferenceServerException

Expand Down Expand Up @@ -84,6 +85,20 @@ def _assert_streaming_response_is_cancelled(self, response):
cancelled_count += 1
self.assertEqual(cancelled_count, 1)

def _get_metrics(self):
metrics_url = "http://localhost:8002/metrics"
r = requests.get(metrics_url)
r.raise_for_status()
return r.text

def _assert_cancel_metrics_sequence_oldest(self, model_name, count, metrics):
expected_metric = f'nv_inference_request_failure{{model="{model_name}",reason="CANCELED",version="1"}} {count}'
self.assertIn(expected_metric, metrics)

def _assert_cancel_metrics_sequence_direct(self, model_name, count, metrics):
expected_metric = f'nv_inference_request_failure{{model="{model_name}",reason="CANCELED",version="1"}} {count}'
self.assertIn(expected_metric, metrics)
indrajit96 marked this conversation as resolved.
Show resolved Hide resolved

# Test queued requests on dynamic batch scheduler can be cancelled
def test_dynamic_batch_scheduler_request_cancellation(self):
model_name = "dynamic_batch"
Expand Down Expand Up @@ -228,6 +243,15 @@ def test_scheduler_streaming_request_cancellation(self):
time.sleep(2) # ensure reaper thread has responded
self._assert_streaming_response_is_cancelled(response)

def test_zerror_metrics(self):
indrajit96 marked this conversation as resolved.
Show resolved Hide resolved
indrajit96 marked this conversation as resolved.
Show resolved Hide resolved
metrics = self._get_metrics()
# Check if we have counted correctly all cancellation for sequence_oldest model
# total expected 2 * 16 + 1
self._assert_cancel_metrics_sequence_oldest("sequence_oldest", 33, metrics)
# Check if we have counted correctly all cancellation for sequence_direct model
# total expected 2 * 2
self._assert_cancel_metrics_sequence_direct("sequence_direct", 4, metrics)


if __name__ == "__main__":
unittest.main()
Loading