Search in sources :

Example 66 with TestMonkeyCalendar

use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.

the class TestNoGeneratedAMIRule method testUncompletedVolume.

@Test
public void testUncompletedVolume() {
    Resource resource = new AWSResource().withId("snap-12345678901234567").withResourceType(AWSResourceType.EBS_SNAPSHOT);
    ((AWSResource) resource).setAWSResourceState("stopped");
    NoGeneratedAMIRule rule = new NoGeneratedAMIRule(new TestMonkeyCalendar(), 0, 0);
    Assert.assertTrue(rule.isValid(resource));
    Assert.assertNull(resource.getExpectedTerminationTime());
}
Also used : TestMonkeyCalendar(com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar) AWSResource(com.netflix.simianarmy.aws.AWSResource) AWSResource(com.netflix.simianarmy.aws.AWSResource) Resource(com.netflix.simianarmy.Resource) Test(org.testng.annotations.Test)

Example 67 with TestMonkeyCalendar

use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.

the class TestNoGeneratedAMIRule method testSnapshotsWithoutLauchTime.

@Test
public void testSnapshotsWithoutLauchTime() {
    int ageThreshold = 5;
    Resource resource = new AWSResource().withId("snap-12345678901234567").withResourceType(AWSResourceType.EBS_SNAPSHOT);
    ((AWSResource) resource).setAWSResourceState("completed");
    int retentionDays = 4;
    NoGeneratedAMIRule rule = new NoGeneratedAMIRule(new TestMonkeyCalendar(), ageThreshold, retentionDays);
    Assert.assertTrue(rule.isValid(resource));
    Assert.assertNull(resource.getExpectedTerminationTime());
}
Also used : TestMonkeyCalendar(com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar) AWSResource(com.netflix.simianarmy.aws.AWSResource) AWSResource(com.netflix.simianarmy.aws.AWSResource) Resource(com.netflix.simianarmy.Resource) Test(org.testng.annotations.Test)

Example 68 with TestMonkeyCalendar

use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.

the class TestNoGeneratedAMIRule method testOldSnapshotWithoutAMI.

@Test
public void testOldSnapshotWithoutAMI() {
    int ageThreshold = 5;
    DateTime now = DateTime.now();
    Resource resource = new AWSResource().withId("snap-12345678901234567").withResourceType(AWSResourceType.EBS_SNAPSHOT).withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
    ((AWSResource) resource).setAWSResourceState("completed");
    int retentionDays = 4;
    NoGeneratedAMIRule rule = new NoGeneratedAMIRule(new TestMonkeyCalendar(), ageThreshold, retentionDays);
    Assert.assertFalse(rule.isValid(resource));
    TestUtils.verifyTerminationTimeRough(resource, retentionDays, now);
}
Also used : TestMonkeyCalendar(com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar) AWSResource(com.netflix.simianarmy.aws.AWSResource) AWSResource(com.netflix.simianarmy.aws.AWSResource) Resource(com.netflix.simianarmy.Resource) DateTime(org.joda.time.DateTime) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 69 with TestMonkeyCalendar

use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.

the class TestNoGeneratedAMIRule method testOldSnapshotWithoutAMIWithoutOwnerOverride.

@Test
public void testOldSnapshotWithoutAMIWithoutOwnerOverride() {
    int ageThreshold = 5;
    DateTime now = DateTime.now();
    Resource resource = new AWSResource().withId("snap-12345678901234567").withOwnerEmail("owner@netflix.com").withResourceType(AWSResourceType.EBS_SNAPSHOT).withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
    ((AWSResource) resource).setAWSResourceState("completed");
    int retentionDays = 4;
    NoGeneratedAMIRule rule = new NoGeneratedAMIRule(new TestMonkeyCalendar(), ageThreshold, retentionDays);
    Assert.assertFalse(rule.isValid(resource));
    Assert.assertEquals(resource.getOwnerEmail(), "owner@netflix.com");
    TestUtils.verifyTerminationTimeRough(resource, retentionDays, now);
}
Also used : TestMonkeyCalendar(com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar) AWSResource(com.netflix.simianarmy.aws.AWSResource) AWSResource(com.netflix.simianarmy.aws.AWSResource) Resource(com.netflix.simianarmy.Resource) DateTime(org.joda.time.DateTime) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 70 with TestMonkeyCalendar

use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.

the class TestNoGeneratedAMIRule method testNonSnapshotResource.

@Test
public void testNonSnapshotResource() {
    Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
    ((AWSResource) resource).setAWSResourceState("completed");
    NoGeneratedAMIRule rule = new NoGeneratedAMIRule(new TestMonkeyCalendar(), 0, 0);
    Assert.assertTrue(rule.isValid(resource));
    Assert.assertNull(resource.getExpectedTerminationTime());
}
Also used : TestMonkeyCalendar(com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar) AWSResource(com.netflix.simianarmy.aws.AWSResource) AWSResource(com.netflix.simianarmy.aws.AWSResource) Resource(com.netflix.simianarmy.Resource) Test(org.testng.annotations.Test)

Aggregations

TestMonkeyCalendar (com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar)79 Test (org.testng.annotations.Test)79 AWSResource (com.netflix.simianarmy.aws.AWSResource)73 Resource (com.netflix.simianarmy.Resource)64 DateTime (org.joda.time.DateTime)51 Date (java.util.Date)28 MonkeyCalendar (com.netflix.simianarmy.MonkeyCalendar)21 BasicJanitorRuleEngine (com.netflix.simianarmy.basic.janitor.BasicJanitorRuleEngine)9 HashSet (java.util.HashSet)5 Calendar (java.util.Calendar)1