Search in sources :

Example 1 with BackPressureSensor

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());
}
Also used : HealthPolicyConfig(com.twitter.heron.healthmgr.HealthPolicyConfig) BackPressureSensor(com.twitter.heron.healthmgr.sensors.BackPressureSensor) HashMap(java.util.HashMap) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Aggregations

Symptom (com.microsoft.dhalion.detector.Symptom)1 ComponentMetrics (com.microsoft.dhalion.metrics.ComponentMetrics)1 HealthPolicyConfig (com.twitter.heron.healthmgr.HealthPolicyConfig)1 BackPressureSensor (com.twitter.heron.healthmgr.sensors.BackPressureSensor)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1