use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.
the class TestOrphanedInstanceRule method testOrphanedInstancesWithoutLaunchTime.
@Test
public void testOrphanedInstancesWithoutLaunchTime() {
int ageThreshold = 5;
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE);
((AWSResource) resource).setAWSResourceState("running");
int retentionDaysWithOwner = 4;
int retentionDaysWithoutOwner = 8;
OrphanedInstanceRule rule = new OrphanedInstanceRule(new TestMonkeyCalendar(), ageThreshold, retentionDaysWithOwner, retentionDaysWithoutOwner);
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.
the class TestOldUnusedLaunchConfigRule method testOldLaunchConfigWithNullFlag.
@Test
public void testOldLaunchConfigWithNullFlag() {
Resource resource = new AWSResource().withId("launchConfig1").withResourceType(AWSResourceType.LAUNCH_CONFIG);
MonkeyCalendar calendar = new TestMonkeyCalendar();
int ageThreshold = 3;
DateTime now = new DateTime(calendar.now().getTimeInMillis());
resource.setLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
int retentionDays = 3;
OldUnusedLaunchConfigRule rule = new OldUnusedLaunchConfigRule(calendar, ageThreshold, retentionDays);
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.
the class TestNoGeneratedAMIRule method testSnapshotWithoutAMINotOld.
@Test
public void testSnapshotWithoutAMINotOld() {
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.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.
the class TestNoGeneratedAMIRule method testTaggedAsNotMark.
@Test
public void testTaggedAsNotMark() {
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);
resource.setTag(JanitorMonkey.JANITOR_TAG, "donotmark");
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.
the class TestNoGeneratedAMIRule method testNullResource.
@Test(expectedExceptions = IllegalArgumentException.class)
public void testNullResource() {
NoGeneratedAMIRule rule = new NoGeneratedAMIRule(new TestMonkeyCalendar(), 5, 4);
rule.isValid(null);
}
Aggregations