use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.
the class TestNoGeneratedAMIRule method testOldSnapshotWithoutAMIWithOwnerOverride.
@Test
public void testOldSnapshotWithoutAMIWithOwnerOverride() {
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, "new_owner@netflix.com");
Assert.assertFalse(rule.isValid(resource));
Assert.assertEquals(resource.getOwnerEmail(), "new_owner@netflix.com");
TestUtils.verifyTerminationTimeRough(resource, retentionDays, now);
}
use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.
the class TestOldDetachedVolumeRule method testOldDetachedVolume.
@Test
public void testOldDetachedVolume() {
int ageThreshold = 5;
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("vol-12345678901234567").withResourceType(AWSResourceType.EBS_VOLUME).withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
((AWSResource) resource).setAWSResourceState("available");
Date lastDetachTime = new Date(now.minusDays(ageThreshold + 1).getMillis());
String metaTag = VolumeTaggingMonkey.makeMetaTag(null, null, lastDetachTime);
resource.setTag(JanitorMonkey.JANITOR_META_TAG, metaTag);
int retentionDays = 4;
OldDetachedVolumeRule rule = new OldDetachedVolumeRule(new TestMonkeyCalendar(), ageThreshold, retentionDays);
Assert.assertFalse(rule.isValid(resource));
TestUtils.verifyTerminationTimeRough(resource, retentionDays, now);
}
use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.
the class TestSuspendedASGRule method testNullResource.
@Test(expectedExceptions = IllegalArgumentException.class)
public void testNullResource() {
SuspendedASGRule rule = new SuspendedASGRule(new TestMonkeyCalendar(), 3, 2, new DummyASGInstanceValidator());
rule.isValid(null);
}
use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.
the class TestOrphanedELBRule method testELBWithReferencedASGsNoInstances.
@Test
public void testELBWithReferencedASGsNoInstances() {
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("test-elb").withResourceType(AWSResourceType.ELB).withOwnerEmail("owner@foo.com");
resource.setAdditionalField("referencedASGCount", "4");
resource.setAdditionalField("instanceCount", "0");
OrphanedELBRule rule = new OrphanedELBRule(new TestMonkeyCalendar(), 7);
Assert.assertTrue(rule.isValid(resource));
}
use of com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar in project SimianArmy by Netflix.
the class TestOrphanedELBRule method testMissingCountsCheck.
@Test
public void testMissingCountsCheck() {
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("test-elb").withResourceType(AWSResourceType.ELB).withOwnerEmail("owner@foo.com");
OrphanedELBRule rule = new OrphanedELBRule(new TestMonkeyCalendar(), 7);
Assert.assertTrue(rule.isValid(resource));
}
Aggregations