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

Fixing test name and AES build #228

Merged
merged 1 commit into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,40 @@

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 FaultDetectionMetricsCollectorTest extends CustomMetricsLocationTestBase {
public class FaultDetectionMetricsCollectorTests extends CustomMetricsLocationTestBase {

@Test
public void testShardsStateMetrics() {
public void testFaultDetectionMetrics() {
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);
Mockito.when(controller.isCollectorEnabled(configOverrides, "FaultDetectionMetricsCollector"))
.thenReturn(true);
FaultDetectionMetricsCollector faultDetectionMetricsCollector = new FaultDetectionMetricsCollector(
controller, configOverrides);
Mockito.when(controller.isCollectorEnabled(configOverrides, "FaultDetectionMetricsCollector"))
.thenReturn(true);
faultDetectionMetricsCollector.saveMetricValues("fault_detection", startTimeInMills,
"follower_check", "65432", "start");
String fetchedValue = PerformanceAnalyzerMetrics.getMetric(PluginSettings.instance().getMetricsLocation()
+ PerformanceAnalyzerMetrics.getTimeInterval(startTimeInMills)+"/fault_detection/");
PerformanceAnalyzerMetrics.removeMetrics(PluginSettings.instance().getMetricsLocation()
+ PerformanceAnalyzerMetrics.getTimeInterval(startTimeInMills));
assertEquals("fault_detection", fetchedValue);
List<Event> metrics = new ArrayList<>();
PerformanceAnalyzerMetrics.metricQueue.drainTo(metrics);

assertEquals(1, metrics.size());
assertEquals("fault_detection", metrics.get(0).value);

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

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 ShardStateCollectorTest extends CustomMetricsLocationTestBase {
public class ShardStateCollectorTests extends CustomMetricsLocationTestBase {

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

assertEquals(1, metrics.size());
assertEquals("shard_state_metrics", metrics.get(0).value);

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