From 84d7d1f12751d55809ca390804193613e1701ce0 Mon Sep 17 00:00:00 2001 From: Atharva Sharma <60044988+atharvasharma61@users.noreply.github.com> Date: Wed, 4 Sep 2024 17:03:18 +0530 Subject: [PATCH] fixes the cacheConfigRTFCollector UT (#713) Signed-off-by: Atharva Sharma --- .../telemetry/RTFCacheConfigMetricsCollectorTests.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/opensearch/performanceanalyzer/collectors/telemetry/RTFCacheConfigMetricsCollectorTests.java b/src/test/java/org/opensearch/performanceanalyzer/collectors/telemetry/RTFCacheConfigMetricsCollectorTests.java index 00d5d871..27d55e36 100644 --- a/src/test/java/org/opensearch/performanceanalyzer/collectors/telemetry/RTFCacheConfigMetricsCollectorTests.java +++ b/src/test/java/org/opensearch/performanceanalyzer/collectors/telemetry/RTFCacheConfigMetricsCollectorTests.java @@ -6,13 +6,11 @@ package org.opensearch.performanceanalyzer.collectors.telemetry; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyDouble; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; import java.io.IOException; import org.junit.After; @@ -24,7 +22,6 @@ import org.opensearch.performanceanalyzer.commons.config.overrides.ConfigOverridesWrapper; import org.opensearch.performanceanalyzer.commons.metrics.MetricsConfiguration; import org.opensearch.performanceanalyzer.config.PerformanceAnalyzerController; -import org.opensearch.telemetry.metrics.Histogram; import org.opensearch.telemetry.metrics.MetricsRegistry; import org.opensearch.test.OpenSearchSingleNodeTestCase; @@ -32,7 +29,6 @@ public class RTFCacheConfigMetricsCollectorTests extends OpenSearchSingleNodeTes private static final String TEST_INDEX = "test"; private RTFCacheConfigMetricsCollector rtfCacheConfigMetricsCollector; private static MetricsRegistry metricsRegistry; - private static Histogram testHistogram; private long startTimeInMills = 1153721339; @Before @@ -40,10 +36,7 @@ public void init() { MetricsConfiguration.CONFIG_MAP.put( RTFCacheConfigMetricsCollector.class, MetricsConfiguration.cdefault); metricsRegistry = mock(MetricsRegistry.class); - testHistogram = mock(Histogram.class); OpenSearchResources.INSTANCE.setMetricsRegistry(metricsRegistry); - when(metricsRegistry.createHistogram(anyString(), anyString(), anyString())) - .thenReturn(testHistogram); IndicesService indicesService = getInstanceFromNode(IndicesService.class); OpenSearchResources.INSTANCE.setIndicesService(indicesService); ConfigOverridesWrapper mockWrapper = mock(ConfigOverridesWrapper.class); @@ -62,6 +55,7 @@ public void tearDown() throws Exception { public void testCollectMetrics() throws IOException { createIndex(TEST_INDEX); rtfCacheConfigMetricsCollector.collectMetrics(startTimeInMills); - verify(testHistogram, atLeastOnce()).record(anyDouble(), any()); + verify(metricsRegistry, atLeastOnce()) + .createGauge(anyString(), anyString(), anyString(), any(), any()); } }