use of com.twitter.heron.healthmgr.sensors.BufferSizeSensor in project incubator-heron by apache.
the class GrowingWaitQueueDetectorTest method testDetector.
@Test
public void testDetector() {
HealthPolicyConfig config = mock(HealthPolicyConfig.class);
when(config.getConfig(CONF_LIMIT, 10.0)).thenReturn(5.0);
ComponentMetrics compMetrics;
InstanceMetrics instanceMetrics;
Map<Instant, Double> bufferSizes;
Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
instanceMetrics = new InstanceMetrics("i1");
bufferSizes = new HashMap<>();
bufferSizes.put(Instant.ofEpochSecond(1497892222), 0.0);
bufferSizes.put(Instant.ofEpochSecond(1497892270), 300.0);
bufferSizes.put(Instant.ofEpochSecond(1497892330), 700.0);
bufferSizes.put(Instant.ofEpochSecond(1497892390), 1000.0);
bufferSizes.put(Instant.ofEpochSecond(1497892450), 1300.0);
instanceMetrics.addMetric(METRIC_BUFFER_SIZE.text(), bufferSizes);
compMetrics = new ComponentMetrics("bolt");
compMetrics.addInstanceMetric(instanceMetrics);
topologyMetrics.put("bolt", compMetrics);
BufferSizeSensor sensor = mock(BufferSizeSensor.class);
when(sensor.get()).thenReturn(topologyMetrics);
GrowingWaitQueueDetector detector = new GrowingWaitQueueDetector(sensor, config);
List<Symptom> symptoms = detector.detect();
assertEquals(1, symptoms.size());
instanceMetrics = new InstanceMetrics("i1");
bufferSizes = new HashMap<>();
bufferSizes.put(Instant.ofEpochSecond(1497892222), 0.0);
bufferSizes.put(Instant.ofEpochSecond(1497892270), 200.0);
bufferSizes.put(Instant.ofEpochSecond(1497892330), 400.0);
bufferSizes.put(Instant.ofEpochSecond(1497892390), 600.0);
bufferSizes.put(Instant.ofEpochSecond(1497892450), 800.0);
instanceMetrics.addMetric(METRIC_BUFFER_SIZE.text(), bufferSizes);
compMetrics = new ComponentMetrics("bolt");
compMetrics.addInstanceMetric(instanceMetrics);
topologyMetrics.put("bolt", compMetrics);
sensor = mock(BufferSizeSensor.class);
when(sensor.get()).thenReturn(topologyMetrics);
detector = new GrowingWaitQueueDetector(sensor, config);
symptoms = detector.detect();
assertEquals(0, symptoms.size());
}
use of com.twitter.heron.healthmgr.sensors.BufferSizeSensor in project incubator-heron by apache.
the class LargeWaitQueueDetectorTest method testConfigAndFilter.
@Test
public void testConfigAndFilter() {
HealthPolicyConfig config = mock(HealthPolicyConfig.class);
when(config.getConfig(CONF_SIZE_LIMIT, 1000)).thenReturn(20);
ComponentMetrics compMetrics = new ComponentMetrics("bolt", "i1", METRIC_BUFFER_SIZE.text(), 21);
Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
topologyMetrics.put("bolt", compMetrics);
BufferSizeSensor sensor = mock(BufferSizeSensor.class);
when(sensor.get()).thenReturn(topologyMetrics);
LargeWaitQueueDetector detector = new LargeWaitQueueDetector(sensor, config);
List<Symptom> symptoms = detector.detect();
assertEquals(1, symptoms.size());
compMetrics = new ComponentMetrics("bolt", "i1", METRIC_BUFFER_SIZE.text(), 19);
topologyMetrics.put("bolt", compMetrics);
sensor = mock(BufferSizeSensor.class);
when(sensor.get()).thenReturn(topologyMetrics);
detector = new LargeWaitQueueDetector(sensor, config);
symptoms = detector.detect();
assertEquals(0, symptoms.size());
}
use of com.twitter.heron.healthmgr.sensors.BufferSizeSensor in project incubator-heron by apache.
the class WaitQueueDisparityDetectorTest method testConfigAndFilter.
@Test
public void testConfigAndFilter() {
HealthPolicyConfig config = mock(HealthPolicyConfig.class);
when(config.getConfig(CONF_DISPARITY_RATIO, 20.0)).thenReturn(15.0);
ComponentMetrics compMetrics = new ComponentMetrics("bolt");
compMetrics.addInstanceMetric(new InstanceMetrics("i1", METRIC_BUFFER_SIZE.text(), 1501));
compMetrics.addInstanceMetric(new InstanceMetrics("i2", METRIC_BUFFER_SIZE.text(), 100));
Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
topologyMetrics.put("bolt", compMetrics);
BufferSizeSensor sensor = mock(BufferSizeSensor.class);
when(sensor.get()).thenReturn(topologyMetrics);
when(sensor.getMetricName()).thenReturn(METRIC_BUFFER_SIZE.text());
WaitQueueDisparityDetector detector = new WaitQueueDisparityDetector(sensor, config);
List<Symptom> symptoms = detector.detect();
assertEquals(1, symptoms.size());
compMetrics = new ComponentMetrics("bolt");
compMetrics.addInstanceMetric(new InstanceMetrics("i1", METRIC_BUFFER_SIZE.text(), 1500));
compMetrics.addInstanceMetric(new InstanceMetrics("i2", METRIC_BUFFER_SIZE.text(), 110));
topologyMetrics.put("bolt", compMetrics);
sensor = mock(BufferSizeSensor.class);
when(sensor.get()).thenReturn(topologyMetrics);
detector = new WaitQueueDisparityDetector(sensor, config);
symptoms = detector.detect();
assertEquals(0, symptoms.size());
}
Aggregations