use of com.twitter.heron.healthmgr.HealthPolicyConfig 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