Search in sources :

Example 6 with HealthPolicyConfig

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

Aggregations

Symptom (com.microsoft.dhalion.detector.Symptom)6 ComponentMetrics (com.microsoft.dhalion.metrics.ComponentMetrics)6 HealthPolicyConfig (com.twitter.heron.healthmgr.HealthPolicyConfig)6 HashMap (java.util.HashMap)6 Test (org.junit.Test)6 InstanceMetrics (com.microsoft.dhalion.metrics.InstanceMetrics)4 BufferSizeSensor (com.twitter.heron.healthmgr.sensors.BufferSizeSensor)3 ExecuteCountSensor (com.twitter.heron.healthmgr.sensors.ExecuteCountSensor)2 BackPressureSensor (com.twitter.heron.healthmgr.sensors.BackPressureSensor)1 Instant (java.time.Instant)1