diff --git a/genai-perf/tests/test_telemetry_data_collector.py b/genai-perf/tests/test_telemetry_data_collector.py index 781f790f..5ca264ed 100755 --- a/genai-perf/tests/test_telemetry_data_collector.py +++ b/genai-perf/tests/test_telemetry_data_collector.py @@ -42,6 +42,7 @@ class TestTelemetryDataCollector: TEST_SERVER_URL = "http://testserver:8080/metrics" + TRITON_METRICS_RESPONSE = """\ TRITON_METRICS_RESPONSE = """\ nv_gpu_power_usage{gpu="0",uuid="GPU-1234"} 123.45 nv_gpu_power_usage{gpu="1",uuid="GPU-5678"} 234.56 @@ -99,6 +100,7 @@ def test_fetch_metrics_success( mock_response = MagicMock() mock_response.status_code = 200 mock_response.text = self.TRITON_METRICS_RESPONSE + mock_response.text = self.TRITON_METRICS_RESPONSE mock_requests_get.return_value = mock_response result = collector._fetch_metrics() @@ -106,6 +108,7 @@ def test_fetch_metrics_success( mock_requests_get.assert_called_once_with(self.TEST_SERVER_URL) assert result == self.TRITON_METRICS_RESPONSE + assert result == self.TRITON_METRICS_RESPONSE @patch("requests.get") def test_fetch_metrics_failure( @@ -126,19 +129,23 @@ def test_collect_metrics( ) -> None: mock_fetch_metrics.return_value = self.TRITON_METRICS_RESPONSE + mock_fetch_metrics.return_value = self.TRITON_METRICS_RESPONSE with patch.object( collector, "_process_and_update_metrics", new_callable=MagicMock ) as mock_process_and_update_metrics: + collector._stop_event = MagicMock() collector._stop_event.is_set = MagicMock(side_effect=[False, True]) + collector._stop_event.is_set = MagicMock(side_effect=[False, True]) collector._collect_metrics() mock_fetch_metrics.assert_called_once() mock_process_and_update_metrics.assert_called_once_with( self.TRITON_METRICS_RESPONSE + self.TRITON_METRICS_RESPONSE ) mock_sleep.assert_called_once()