use of com.netflix.simianarmy.MonkeyCalendar in project SimianArmy by Netflix.
the class TestSuspendedASGRule method testASGWithInstances.
@Test
public void testASGWithInstances() {
Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "2");
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_INSTANCES, "123456789012345671,i-123456789012345672");
int suspensionAgeThreshold = 2;
MonkeyCalendar calendar = new TestMonkeyCalendar();
DateTime now = new DateTime(calendar.now().getTimeInMillis());
DateTime suspensionTime = now.minusDays(suspensionAgeThreshold + 1);
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_SUSPENSION_TIME, ASGJanitorCrawler.SUSPENSION_TIME_FORMATTER.print(suspensionTime));
int retentionDays = 3;
SuspendedASGRule rule = new SuspendedASGRule(calendar, suspensionAgeThreshold, retentionDays, new DummyASGInstanceValidator());
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
use of com.netflix.simianarmy.MonkeyCalendar in project SimianArmy by Netflix.
the class TestSuspendedASGRule method testEmptyASGNotSuspended.
@Test
public void testEmptyASGNotSuspended() {
Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "0");
int suspensionAgeThreshold = 2;
MonkeyCalendar calendar = new TestMonkeyCalendar();
int retentionDays = 3;
SuspendedASGRule rule = new SuspendedASGRule(calendar, suspensionAgeThreshold, retentionDays, new DummyASGInstanceValidator());
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
use of com.netflix.simianarmy.MonkeyCalendar in project SimianArmy by Netflix.
the class TestOldEmptyASGRule method testEmptyASGWithLaunchConfigWithoutCreateTime.
@Test
public void testEmptyASGWithLaunchConfigWithoutCreateTime() {
Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_NAME, "launchConfig");
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "0");
int launchConfiguAgeThreshold = 60;
MonkeyCalendar calendar = new TestMonkeyCalendar();
int retentionDays = 3;
OldEmptyASGRule rule = new OldEmptyASGRule(calendar, launchConfiguAgeThreshold, retentionDays, new DummyASGInstanceValidator());
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
use of com.netflix.simianarmy.MonkeyCalendar in project SimianArmy by Netflix.
the class TestOldEmptyASGRule method testEmptyASGWithoutLaunchConfig.
@Test
public void testEmptyASGWithoutLaunchConfig() {
Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "0");
int launchConfiguAgeThreshold = 60;
MonkeyCalendar calendar = new TestMonkeyCalendar();
DateTime now = new DateTime(calendar.now().getTimeInMillis());
int retentionDays = 3;
OldEmptyASGRule rule = new OldEmptyASGRule(calendar, launchConfiguAgeThreshold, retentionDays, new DummyASGInstanceValidator());
Assert.assertFalse(rule.isValid(resource));
TestUtils.verifyTerminationTimeRough(resource, retentionDays, now);
}
use of com.netflix.simianarmy.MonkeyCalendar 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());
}
Aggregations