use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestOrphanedELBRule method testMissingInstanceCountCheck.
@Test
public void testMissingInstanceCountCheck() {
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("test-elb").withResourceType(AWSResourceType.ELB).withOwnerEmail("owner@foo.com");
resource.setAdditionalField("referencedASGCount", "0");
OrphanedELBRule rule = new OrphanedELBRule(new TestMonkeyCalendar(), 7);
Assert.assertTrue(rule.isValid(resource));
}
use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestUntaggedRule method testTaggedInstance.
@Test
public void testTaggedInstance() {
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE);
resource.setTag("tag1", "value1");
resource.setTag("tag2", "value2");
((AWSResource) resource).setAWSResourceState("running");
Set<String> tags = new HashSet<String>();
tags.add("tag1");
tags.add("tag2");
int retentionDaysWithOwner = 4;
int retentionDaysWithoutOwner = 8;
UntaggedRule rule = new UntaggedRule(new TestMonkeyCalendar(), tags, retentionDaysWithOwner, retentionDaysWithoutOwner);
Assert.assertTrue(rule.isValid(resource));
}
use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestOrphanedInstanceRule method testOrphanedInstancesWithLaunchTimeNotExpires.
@Test
public void testOrphanedInstancesWithLaunchTimeNotExpires() {
int ageThreshold = 5;
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE).withLaunchTime(new Date(now.minusDays(ageThreshold - 1).getMillis()));
((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.Resource in project SimianArmy by Netflix.
the class TestOrphanedInstanceRule method testOrphanedInstancesWithoutOwner.
@Test
public void testOrphanedInstancesWithoutOwner() {
int ageThreshold = 5;
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE).withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
((AWSResource) resource).setAWSResourceState("running");
int retentionDaysWithOwner = 4;
int retentionDaysWithoutOwner = 8;
OrphanedInstanceRule rule = new OrphanedInstanceRule(new TestMonkeyCalendar(), ageThreshold, retentionDaysWithOwner, retentionDaysWithoutOwner);
Assert.assertFalse(rule.isValid(resource));
TestUtils.verifyTerminationTimeRough(resource, retentionDaysWithoutOwner, now);
}
use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestOrphanedInstanceRule method testNonInstanceResource.
@Test
public void testNonInstanceResource() {
Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
((AWSResource) resource).setAWSResourceState("running");
OrphanedInstanceRule rule = new OrphanedInstanceRule(new TestMonkeyCalendar(), 0, 0, 0);
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
Aggregations