Search in sources :

Example 6 with PutMetricAlarmRequest

use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class RdsAlarmSetupTest method testHightWriteLatency.

@Test
public void testHightWriteLatency() {
    PutMetricAlarmRequest expected = RdsAlarmSetup.createDefaultPutMetricRequest(dbInstance, topicArn);
    expected.setAlarmName(databaseIdentifer + HIGH_WRITE_LATENCY);
    expected.withStatistic("Average").withMetricName(METRIC_WRITE_LATENCY).withComparisonOperator(ComparisonOperator.GreaterThanOrEqualToThreshold).withThreshold(0.1).withEvaluationPeriods(1).withPeriod(FIVE_MINUTES_IN_SECONDS);
    PutMetricAlarmRequest result = RdsAlarmSetup.createHighWriteLatency(dbInstance, topicArn);
    assertEquals(expected, result);
}
Also used : PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest) Test(org.junit.Test)

Example 7 with PutMetricAlarmRequest

use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class RdsAlarmSetupTest method testLowFreeStorage.

@Test
public void testLowFreeStorage() {
    PutMetricAlarmRequest expected = RdsAlarmSetup.createDefaultPutMetricRequest(dbInstance, topicArn);
    expected.setAlarmName(databaseIdentifer + LOW_FREE_STOREAGE_SPACE);
    Double tenPercentGB = ((double) dbInstance.getAllocatedStorage()) * 0.1;
    Double tenPercentBytes = tenPercentGB * Constants.BYTES_PER_GIGABYTE;
    System.out.println("10% = " + tenPercentBytes + " bytes");
    expected.withStatistic("Average").withMetricName(METRIC_FREE_STOREAGE_SPACE).withComparisonOperator(ComparisonOperator.LessThanOrEqualToThreshold).withThreshold(tenPercentBytes).withEvaluationPeriods(1).withPeriod(FIVE_MINUTES_IN_SECONDS);
    PutMetricAlarmRequest result = RdsAlarmSetup.createLowFreeStorage(dbInstance, topicArn);
    assertEquals(expected, result);
}
Also used : PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest) Test(org.junit.Test)

Example 8 with PutMetricAlarmRequest

use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class RdsAlarmSetupTest method testCreateLowFreeableMemorySmallInstances.

@Test
public void testCreateLowFreeableMemorySmallInstances() {
    // the free able memory alarm is a function of the instances size
    Double totalMemory = Constants.getDatabaseClassMemrorySizeBytes(DATABASE_INSTANCE_CLASS_M1_SMALL);
    System.out.println("Small memory total: " + totalMemory + " bytes");
    PutMetricAlarmRequest expected = RdsAlarmSetup.createDefaultPutMetricRequest(dbInstance, topicArn);
    expected.setAlarmName(databaseIdentifer + "-Low-Freeable-Memory");
    Double eightPercent = totalMemory - (totalMemory * 0.8);
    // Average FreeableMemory < 80% for 1 consecutive period of 5 minutes
    expected.withStatistic("Average").withMetricName(METRIC_FREEABLE_MEMORY).withComparisonOperator(ComparisonOperator.LessThanThreshold).withThreshold(eightPercent).withEvaluationPeriods(1).withPeriod(FIVE_MINUTES_IN_SECONDS);
    PutMetricAlarmRequest result = RdsAlarmSetup.createLowFreeableMemory(dbInstance, topicArn);
    assertEquals(expected, result);
}
Also used : PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest) Test(org.junit.Test)

Example 9 with PutMetricAlarmRequest

use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElbAlarmSetupTest method testCreateUnhealthyInstancesPutMetricAlarmRequest.

@Test
public void testCreateUnhealthyInstancesPutMetricAlarmRequest() {
    PutMetricAlarmRequest expectedReq = ElbAlarmTestHelper.getExpectedPutMetricAlarmRequest();
    String loadBalancerName = "loadBalancer";
    PutMetricAlarmRequest req = ElbAlarmSetup.createUnhealthyInstancesPutMetricAlarmRequest("prefix", loadBalancerName, resources.getStackInstanceNotificationTopicArn());
    assertEquals(expectedReq, req);
}
Also used : PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest) Test(org.junit.Test)

Example 10 with PutMetricAlarmRequest

use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElbAlarmSetupTest method testCreateDefaultPutMetricAlarmRequest.

// TODO: Add tests for error cases
@Test
public void testCreateDefaultPutMetricAlarmRequest() {
    PutMetricAlarmRequest expectedReq = ElbAlarmTestHelper.getExpectedBasePutMetricAlarmRequest();
    String loadBalancerName = "loadBalancer";
    PutMetricAlarmRequest req = ElbAlarmSetup.createDefaultPutMetricAlarmRequest(loadBalancerName, resources.getStackInstanceNotificationTopicArn());
    assertEquals(expectedReq, req);
}
Also used : PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest) Test(org.junit.Test)

Aggregations

PutMetricAlarmRequest (com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest)60 Test (org.junit.Test)9 Dimension (com.amazonaws.services.cloudwatch.model.Dimension)5 ArrayList (java.util.ArrayList)4 AmazonCloudWatch (com.amazonaws.services.cloudwatch.AmazonCloudWatch)1 DescribeAlarmsResult (com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult)1 PutMetricAlarmResult (com.amazonaws.services.cloudwatch.model.PutMetricAlarmResult)1 LoadBalancer (com.amazonaws.services.elasticbeanstalk.model.LoadBalancer)1 DBInstance (com.amazonaws.services.rds.model.DBInstance)1 LinkedList (java.util.LinkedList)1