Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Revert "Fixing test name and AES build (#228)"
Browse files Browse the repository at this point in the history
This reverts commit 4a3b717.
  • Loading branch information
khushbr authored Oct 23, 2020
1 parent 4a3b717 commit 5567d84
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,35 @@

import com.amazon.opendistro.elasticsearch.performanceanalyzer.CustomMetricsLocationTestBase;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.config.PerformanceAnalyzerController;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.config.PluginSettings;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.config.overrides.ConfigOverridesWrapper;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.MetricsConfiguration;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.PerformanceAnalyzerMetrics;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.reader_writer_shared.Event;

import org.junit.Test;
import org.mockito.Mockito;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class FaultDetectionMetricsCollectorTests extends CustomMetricsLocationTestBase {

public class FaultDetectionMetricsCollectorTest extends CustomMetricsLocationTestBase {
@Test
public void testFaultDetectionMetrics() {
public void testShardsStateMetrics() {
MetricsConfiguration.CONFIG_MAP.put(FaultDetectionMetricsCollector.class, MetricsConfiguration.cdefault);
System.setProperty("performanceanalyzer.metrics.log.enabled", "False");
long startTimeInMills = 1153721339;
PerformanceAnalyzerController controller = Mockito.mock(PerformanceAnalyzerController.class);
ConfigOverridesWrapper configOverrides = Mockito.mock(ConfigOverridesWrapper.class);
FaultDetectionMetricsCollector faultDetectionMetricsCollector = new FaultDetectionMetricsCollector(
controller, configOverrides);
Mockito.when(controller.isCollectorEnabled(configOverrides, "FaultDetectionMetricsCollector"))
.thenReturn(true);
FaultDetectionMetricsCollector faultDetectionMetricsCollector = new FaultDetectionMetricsCollector(
controller, configOverrides);
faultDetectionMetricsCollector.saveMetricValues("fault_detection", startTimeInMills,
"follower_check", "65432", "start");
List<Event> metrics = new ArrayList<>();
PerformanceAnalyzerMetrics.metricQueue.drainTo(metrics);

assertEquals(1, metrics.size());
assertEquals("fault_detection", metrics.get(0).value);
String fetchedValue = PerformanceAnalyzerMetrics.getMetric(PluginSettings.instance().getMetricsLocation()
+ PerformanceAnalyzerMetrics.getTimeInterval(startTimeInMills)+"/fault_detection/");
PerformanceAnalyzerMetrics.removeMetrics(PluginSettings.instance().getMetricsLocation()
+ PerformanceAnalyzerMetrics.getTimeInterval(startTimeInMills));
assertEquals("fault_detection", fetchedValue);

try {
faultDetectionMetricsCollector.saveMetricValues("fault_detection_metrics", startTimeInMills);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@

import com.amazon.opendistro.elasticsearch.performanceanalyzer.CustomMetricsLocationTestBase;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.config.PerformanceAnalyzerController;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.config.PluginSettings;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.config.overrides.ConfigOverridesWrapper;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.MetricsConfiguration;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.PerformanceAnalyzerMetrics;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.reader_writer_shared.Event;
import org.junit.Test;
import org.mockito.Mockito;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class ShardStateCollectorTests extends CustomMetricsLocationTestBase {
public class ShardStateCollectorTest extends CustomMetricsLocationTestBase {

@Test
public void testShardsStateMetrics() {
Expand All @@ -43,11 +40,11 @@ public void testShardsStateMetrics() {
.thenReturn(true);
ShardStateCollector shardsStateCollector = new ShardStateCollector(controller, configOverrides);
shardsStateCollector.saveMetricValues("shard_state_metrics", startTimeInMills);
List<Event> metrics = new ArrayList<>();
PerformanceAnalyzerMetrics.metricQueue.drainTo(metrics);

assertEquals(1, metrics.size());
assertEquals("shard_state_metrics", metrics.get(0).value);
String fetchedValue = PerformanceAnalyzerMetrics.getMetric(PluginSettings.instance().getMetricsLocation()
+ PerformanceAnalyzerMetrics.getTimeInterval(startTimeInMills)+"/shard_state_metrics/");
PerformanceAnalyzerMetrics.removeMetrics(PluginSettings.instance().getMetricsLocation()
+ PerformanceAnalyzerMetrics.getTimeInterval(startTimeInMills));
assertEquals("shard_state_metrics", fetchedValue);

try {
shardsStateCollector.saveMetricValues("shard_state_metrics", startTimeInMills, "123");
Expand Down

0 comments on commit 5567d84

Please sign in to comment.