use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestOrphanedELBRule method testELBWithInstancesNoASGs.
@Test
public void testELBWithInstancesNoASGs() {
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("test-elb").withResourceType(AWSResourceType.ELB).withOwnerEmail("owner@foo.com");
resource.setAdditionalField("referencedASGCount", "0");
resource.setAdditionalField("instanceCount", "4");
OrphanedELBRule rule = new OrphanedELBRule(new TestMonkeyCalendar(), 7);
Assert.assertTrue(rule.isValid(resource));
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestTagValueExclusionRule method testExcludeTaggedResourceAllNullTags.
@Test
public void testExcludeTaggedResourceAllNullTags() {
Resource r1 = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE).withOwnerEmail("owner@foo.com");
r1.setTag("tag", null);
r1.setTag("tag1", null);
r1.setTag("tag2", null);
TagValueExclusionRule rule = new TagValueExclusionRule(exclusionTags);
Assert.assertFalse(rule.isValid(r1));
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestTagValueExclusionRule method testExcludeTaggedResourceWithTagAndValueMatch2.
@Test
public void testExcludeTaggedResourceWithTagAndValueMatch2() {
Resource r1 = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE).withOwnerEmail("owner@foo.com");
r1.setTag("tag", null);
r1.setTag("tag1", "somethingelse");
r1.setTag("tag2", "excludeme2");
TagValueExclusionRule rule = new TagValueExclusionRule(exclusionTags);
Assert.assertTrue(rule.isValid(r1));
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestTagValueExclusionRule method testExcludeUntaggedResource.
@Test
public void testExcludeUntaggedResource() {
Resource r1 = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE).withOwnerEmail("owner@foo.com");
TagValueExclusionRule rule = new TagValueExclusionRule(exclusionTags);
Assert.assertFalse(rule.isValid(r1));
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestUntaggedRule method testResourceWithExpectedTerminationTimeSet.
@Test
public void testResourceWithExpectedTerminationTimeSet() {
DateTime now = DateTime.now();
Date oldTermDate = new Date(now.plusDays(10).getMillis());
String oldTermReason = "Foo";
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE).withExpectedTerminationTime(oldTermDate).withTerminationReason(oldTermReason);
((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.assertFalse(rule.isValid(resource));
Assert.assertEquals(oldTermDate, resource.getExpectedTerminationTime());
Assert.assertEquals(oldTermReason, resource.getTerminationReason());
}
Aggregations