use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class AlwaysInvalidRule method testWithExclusionRuleNotMatch2.
@Test
void testWithExclusionRuleNotMatch2() {
Resource resource = new AWSResource().withId("id");
DateTime now = DateTime.now();
BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine().addExclusionRule(new AlwaysInvalidRule(now, 1)).addRule(new AlwaysValidRule());
Assert.assertTrue(engine.isValid(resource));
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestOldEmptyASGRule method testNonASGResource.
@Test
public void testNonASGResource() {
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE);
OldEmptyASGRule rule = new OldEmptyASGRule(new TestMonkeyCalendar(), 3, 60, new DummyASGInstanceValidator());
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestOldEmptyASGRule method testEmptyASGWithObsoleteLaunchConfig.
@Test
public void testEmptyASGWithObsoleteLaunchConfig() {
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();
DateTime now = new DateTime(calendar.now().getTimeInMillis());
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_CREATION_TIME, String.valueOf(now.minusDays(launchConfiguAgeThreshold + 1).getMillis()));
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.aws.AWSResource in project SimianArmy by Netflix.
the class TestOldEmptyASGRule method testASGWithoutInstanceAndNonZeroSize.
@Test
public void testASGWithoutInstanceAndNonZeroSize() {
Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_NAME, "launchConfig");
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "2");
int launchConfiguAgeThreshold = 60;
MonkeyCalendar calendar = new TestMonkeyCalendar();
DateTime now = new DateTime(calendar.now().getTimeInMillis());
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_CREATION_TIME, String.valueOf(now.minusDays(launchConfiguAgeThreshold + 1).getMillis()));
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.aws.AWSResource 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());
}
Aggregations