use of com.microsoft.applicationinsights.alerting.analysis.AlertPipelineTrigger in project ApplicationInsights-Java by microsoft.
the class AlertTriggerTest method doesNotReTriggerAfterCooldown.
@Test
void doesNotReTriggerAfterCooldown() throws InterruptedException {
AlertConfiguration config = new AlertConfiguration(AlertMetricType.CPU, true, 0.5f, 1, 1);
AtomicBoolean called = new AtomicBoolean(false);
AlertPipelineTrigger trigger = getAlertTrigger(config, called);
for (int i = 0; i < 100; i++) {
trigger.accept(0.51);
}
assertThat(called.get()).isTrue();
called.set(false);
Thread.sleep(2000);
for (int i = 0; i < 100; i++) {
trigger.accept(0.1);
}
for (int i = 0; i < 100; i++) {
trigger.accept(0.51);
}
assertThat(called.get()).isTrue();
}
use of com.microsoft.applicationinsights.alerting.analysis.AlertPipelineTrigger in project ApplicationInsights-Java by microsoft.
the class AlertTriggerTest method overThresholdDataDoesTrigger.
@Test
void overThresholdDataDoesTrigger() {
AlertConfiguration config = new AlertConfiguration(AlertMetricType.CPU, true, 0.5f, 1, 1);
AtomicBoolean called = new AtomicBoolean(false);
AlertPipelineTrigger trigger = getAlertTrigger(config, called);
for (int i = 0; i < 100; i++) {
trigger.accept(0.51);
}
assertThat(called.get()).isTrue();
}
use of com.microsoft.applicationinsights.alerting.analysis.AlertPipelineTrigger in project ApplicationInsights-Java by microsoft.
the class AlertTriggerTest method doesNotReTriggerDueToCooldown.
@Test
void doesNotReTriggerDueToCooldown() {
AlertConfiguration config = new AlertConfiguration(AlertMetricType.CPU, true, 0.5f, 1, 1000);
AtomicBoolean called = new AtomicBoolean(false);
AlertPipelineTrigger trigger = getAlertTrigger(config, called);
for (int i = 0; i < 100; i++) {
trigger.accept(0.51);
}
assertThat(called.get()).isTrue();
called.set(false);
for (int i = 0; i < 100; i++) {
trigger.accept(0.1);
}
for (int i = 0; i < 100; i++) {
trigger.accept(0.51);
}
assertThat(called.get()).isFalse();
}
use of com.microsoft.applicationinsights.alerting.analysis.AlertPipelineTrigger in project ApplicationInsights-Java by microsoft.
the class AlertTriggerTest method underThresholdDataDoesNotTrigger.
@Test
void underThresholdDataDoesNotTrigger() {
AlertConfiguration config = new AlertConfiguration(AlertMetricType.CPU, true, 0.5f, 1, 1000);
AtomicBoolean called = new AtomicBoolean(false);
AlertPipelineTrigger trigger = getAlertTrigger(config, called);
for (int i = 0; i < 100; i++) {
trigger.accept(0.4);
}
assertThat(called.get()).isFalse();
}
Aggregations