use of com.twitter.heron.healthmgr.sensors.BackPressureSensor in project incubator-heron by apache.
the class BackPressureDetectorTest method testConfigAndFilter.
@Test
public void testConfigAndFilter() {
HealthPolicyConfig config = mock(HealthPolicyConfig.class);
when(config.getConfig(CONF_NOISE_FILTER, 20)).thenReturn(50);
ComponentMetrics compMetrics = new ComponentMetrics("bolt", "i1", METRIC_BACK_PRESSURE.text(), 55);
Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
topologyMetrics.put("bolt", compMetrics);
BackPressureSensor sensor = mock(BackPressureSensor.class);
when(sensor.get()).thenReturn(topologyMetrics);
BackPressureDetector detector = new BackPressureDetector(sensor, config);
List<Symptom> symptoms = detector.detect();
Assert.assertEquals(1, symptoms.size());
compMetrics = new ComponentMetrics("bolt", "i1", METRIC_BACK_PRESSURE.text(), 45);
topologyMetrics.put("bolt", compMetrics);
sensor = mock(BackPressureSensor.class);
when(sensor.get()).thenReturn(topologyMetrics);
detector = new BackPressureDetector(sensor, config);
symptoms = detector.detect();
Assert.assertEquals(0, symptoms.size());
}
Aggregations