use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestOldEmptyASGRule method testResourceWithExpectedTerminationTimeSet.
@Test
public void testResourceWithExpectedTerminationTimeSet() {
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());
Date oldTermDate = new Date(now.plusDays(10).getMillis());
String oldTermReason = "Foo";
resource.setExpectedTerminationTime(oldTermDate);
resource.setTerminationReason(oldTermReason);
Assert.assertFalse(rule.isValid(resource));
Assert.assertEquals(oldTermDate, resource.getExpectedTerminationTime());
Assert.assertEquals(oldTermReason, resource.getTerminationReason());
}
use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestOldEmptyASGRule method testASGWithInstances.
@Test
public void testASGWithInstances() {
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");
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_INSTANCES, "123456789012345671,i-123456789012345672");
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.Resource in project SimianArmy by Netflix.
the class TestOldEmptyASGRule method testEmptyASGWithValidLaunchConfig.
@Test
public void testEmptyASGWithValidLaunchConfig() {
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.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestEBSSnapshotJanitorCrawler method testSnapshotsWithIds.
@Test
public void testSnapshotsWithIds() {
Date startTime = new Date();
List<Snapshot> snapshotList = createSnapshotList(startTime);
String[] ids = { "snap-12345678901234567", "snap-12345678901234567" };
EBSSnapshotJanitorCrawler crawler = new EBSSnapshotJanitorCrawler(createMockAWSClient(snapshotList, ids));
List<Resource> resources = crawler.resources(ids);
verifySnapshotList(resources, snapshotList, startTime);
}
use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestELBJanitorCrawler method testElbsWithReferencedASGs.
@Test
public void testElbsWithReferencedASGs() {
boolean includeInstances = true;
boolean includeELbs = true;
AWSClient client = createMockAWSClient();
List<LoadBalancerDescription> elbs = createELBList(includeInstances);
List<AutoScalingGroup> asgs = createASGList(includeELbs);
addELBsToMock(client, elbs);
addASGsToMock(client, asgs);
ELBJanitorCrawler crawler = new ELBJanitorCrawler(client);
List<Resource> resources = crawler.resources();
verifyELBList(resources, elbs, 1);
}
Aggregations