Skip to content

Commit

Permalink
Merge branch 'opensearch-project:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
atharvasharma61 committed Sep 4, 2024
2 parents f1f77ea + 7fd7bc7 commit 07e3ab2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void setup() {
e.printStackTrace();
}
clusterService = new ClusterService(settings, clusterSettings, threadPool);
identityService = new IdentityService(Settings.EMPTY, List.of());
identityService = new IdentityService(Settings.EMPTY, threadPool, List.of());
restController =
new RestController(
Collections.emptySet(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,26 +22,21 @@
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;

public class RTFCacheConfigMetricsCollectorTests extends OpenSearchSingleNodeTestCase {
private static final String TEST_INDEX = "test";
private RTFCacheConfigMetricsCollector rtfCacheConfigMetricsCollector;
private static MetricsRegistry metricsRegistry;
private static Histogram testHistogram;
private long startTimeInMills = 1153721339;

@Before
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);
Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void init() {
UsageService usageService = new UsageService();
threadPool = new TestThreadPool("test");
nodeClient = new NodeClient(Settings.EMPTY, threadPool);
identityService = new IdentityService(Settings.EMPTY, List.of());
identityService = new IdentityService(Settings.EMPTY, threadPool, List.of());
restController =
new RestController(
Collections.emptySet(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void init() {
UsageService usageService = new UsageService();
threadPool = new TestThreadPool("test");
nodeClient = new NodeClient(Settings.EMPTY, threadPool);
identityService = new IdentityService(Settings.EMPTY, List.of());
identityService = new IdentityService(Settings.EMPTY, threadPool, List.of());
restController =
new RestController(
Collections.emptySet(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void init() {
UsageService usageService = new UsageService();
threadPool = new TestThreadPool("test");
nodeClient = new NodeClient(Settings.EMPTY, threadPool);
identityService = new IdentityService(Settings.EMPTY, List.of());
identityService = new IdentityService(Settings.EMPTY, threadPool, List.of());
restController =
new RestController(
Collections.emptySet(),
Expand Down

0 comments on commit 07e3ab2

Please sign in to comment.