Search in sources :

Example 11 with Symptom

use of com.microsoft.dhalion.core.Symptom in project heron by twitter.

the class ProcessingRateSkewDetectorTest method testConfigAndFilter.

@Test
public void testConfigAndFilter() {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_SKEW_RATIO, 1.5)).thenReturn(2.5);
    Measurement measurement1 = new Measurement("bolt", "i1", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 1000);
    Measurement measurement2 = new Measurement("bolt", "i2", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 200.0);
    Collection<Measurement> metrics = new ArrayList<>();
    metrics.add(measurement1);
    metrics.add(measurement2);
    ProcessingRateSkewDetector detector = new ProcessingRateSkewDetector(config);
    PoliciesExecutor.ExecutionContext context = mock(PoliciesExecutor.ExecutionContext.class);
    when(context.checkpoint()).thenReturn(Instant.now());
    detector.initialize(context);
    Collection<Symptom> symptoms = detector.detect(metrics);
    assertEquals(3, symptoms.size());
    SymptomsTable symptomsTable = SymptomsTable.of(symptoms);
    assertEquals(1, symptomsTable.type("POSITIVE " + BaseDetector.SymptomType.SYMPTOM_PROCESSING_RATE_SKEW).size());
    assertEquals(1, symptomsTable.type("NEGATIVE " + BaseDetector.SymptomType.SYMPTOM_PROCESSING_RATE_SKEW).size());
    assertEquals(1, symptomsTable.type("POSITIVE " + BaseDetector.SymptomType.SYMPTOM_PROCESSING_RATE_SKEW).assignment("i1").size());
    assertEquals(1, symptomsTable.type("NEGATIVE " + BaseDetector.SymptomType.SYMPTOM_PROCESSING_RATE_SKEW).assignment("i2").size());
    measurement1 = new Measurement("bolt", "i1", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 1000);
    measurement2 = new Measurement("bolt", "i2", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 500.0);
    metrics = new ArrayList<>();
    metrics.add(measurement1);
    metrics.add(measurement2);
    detector = new ProcessingRateSkewDetector(config);
    detector.initialize(context);
    symptoms = detector.detect(metrics);
    assertEquals(0, symptoms.size());
}
Also used : Measurement(com.microsoft.dhalion.core.Measurement) HealthPolicyConfig(org.apache.heron.healthmgr.HealthPolicyConfig) ArrayList(java.util.ArrayList) PoliciesExecutor(com.microsoft.dhalion.policy.PoliciesExecutor) Symptom(com.microsoft.dhalion.core.Symptom) SymptomsTable(com.microsoft.dhalion.core.SymptomsTable) Test(org.junit.Test)

Example 12 with Symptom

use of com.microsoft.dhalion.core.Symptom in project heron by twitter.

the class DataSkewDiagnoserTest method failsIfNoDataSkewSymptom.

@Test
public void failsIfNoDataSkewSymptom() {
    Symptom symptom = new Symptom(SYMPTOM_COMP_BACK_PRESSURE.text(), Instant.now(), null);
    Collection<Symptom> symptoms = Collections.singletonList(symptom);
    Collection<Diagnosis> result = diagnoser.diagnose(symptoms);
    assertEquals(0, result.size());
}
Also used : Diagnosis(com.microsoft.dhalion.core.Diagnosis) Symptom(com.microsoft.dhalion.core.Symptom) Test(org.junit.Test)

Example 13 with Symptom

use of com.microsoft.dhalion.core.Symptom in project heron by twitter.

the class UnderProvisioningDiagnoserTest method diagnosisFailsNotSimilarQueueSizes.

@Test
public void diagnosisFailsNotSimilarQueueSizes() {
    Collection<String> assign = Collections.singleton(comp);
    Symptom bpSymptom = new Symptom(SYMPTOM_COMP_BACK_PRESSURE.text(), now, assign);
    Symptom qDisparitySymptom = new Symptom(SYMPTOM_WAIT_Q_SIZE_SKEW.text(), now, assign);
    Collection<Symptom> symptoms = Arrays.asList(bpSymptom, qDisparitySymptom);
    Collection<Diagnosis> result = diagnoser.diagnose(symptoms);
    assertEquals(0, result.size());
}
Also used : Diagnosis(com.microsoft.dhalion.core.Diagnosis) Symptom(com.microsoft.dhalion.core.Symptom) Test(org.junit.Test)

Example 14 with Symptom

use of com.microsoft.dhalion.core.Symptom in project heron by twitter.

the class UnderProvisioningDiagnoserTest method diagnosisWhen1Of1InstanceInBP.

@Test
public void diagnosisWhen1Of1InstanceInBP() {
    Collection<String> assign = Collections.singleton(comp);
    Symptom symptom = new Symptom(SYMPTOM_COMP_BACK_PRESSURE.text(), now, assign);
    Collection<Symptom> symptoms = Collections.singletonList(symptom);
    Collection<Diagnosis> result = diagnoser.diagnose(symptoms);
    validateDiagnosis(result);
}
Also used : Diagnosis(com.microsoft.dhalion.core.Diagnosis) Symptom(com.microsoft.dhalion.core.Symptom) Test(org.junit.Test)

Example 15 with Symptom

use of com.microsoft.dhalion.core.Symptom in project heron by twitter.

the class UnderProvisioningDiagnoserTest method diagnosisFailsNotSimilarProcessingRates.

@Test
public void diagnosisFailsNotSimilarProcessingRates() {
    // TODO BP instance should be same as the one with high processing rate
    Collection<String> assign = Collections.singleton(comp);
    Symptom bpSymptom = new Symptom(SYMPTOM_COMP_BACK_PRESSURE.text(), now, assign);
    Symptom qDisparitySymptom = new Symptom(SYMPTOM_PROCESSING_RATE_SKEW.text(), now, assign);
    Collection<Symptom> symptoms = Arrays.asList(bpSymptom, qDisparitySymptom);
    Collection<Diagnosis> result = diagnoser.diagnose(symptoms);
    assertEquals(0, result.size());
}
Also used : Diagnosis(com.microsoft.dhalion.core.Diagnosis) Symptom(com.microsoft.dhalion.core.Symptom) Test(org.junit.Test)

Aggregations

Symptom (com.microsoft.dhalion.core.Symptom)20 Test (org.junit.Test)16 Diagnosis (com.microsoft.dhalion.core.Diagnosis)10 ArrayList (java.util.ArrayList)10 Measurement (com.microsoft.dhalion.core.Measurement)6 PoliciesExecutor (com.microsoft.dhalion.policy.PoliciesExecutor)6 HealthPolicyConfig (org.apache.heron.healthmgr.HealthPolicyConfig)6 MeasurementsTable (com.microsoft.dhalion.core.MeasurementsTable)4 SymptomsTable (com.microsoft.dhalion.core.SymptomsTable)4 Instant (java.time.Instant)2 HashSet (java.util.HashSet)2 HealthManagerMetrics (org.apache.heron.healthmgr.HealthManagerMetrics)1