use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestTagValueExclusionRule method testNameValueConstructor.
@Test
public void testNameValueConstructor() {
Resource r1 = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE).withOwnerEmail("owner@foo.com");
r1.setTag("tag1", "excludeme");
String names = "tag1";
String vals = "excludeme";
TagValueExclusionRule rule = new TagValueExclusionRule(names.split(","), vals.split(","));
Assert.assertTrue(rule.isValid(r1));
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestTagValueExclusionRule method testExcludeTaggedResourceWithTagAndValueMatchBoth.
@Test
public void testExcludeTaggedResourceWithTagAndValueMatchBoth() {
Resource r1 = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE).withOwnerEmail("owner@foo.com");
r1.setTag("tag", null);
r1.setTag("tag1", "excludeme");
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 TestUntaggedRule method testUntaggedResource.
@Test
public void testUntaggedResource() {
DateTime now = DateTime.now();
Resource imageResource = new AWSResource().withId("ami-123123").withResourceType(AWSResourceType.IMAGE);
Resource asgResource = new AWSResource().withId("my-cool-asg").withResourceType(AWSResourceType.ASG);
Resource ebsSnapshotResource = new AWSResource().withId("snap-12345678901234567").withResourceType(AWSResourceType.EBS_SNAPSHOT);
Resource lauchConfigurationResource = new AWSResource().withId("my-cool-launch-configuration").withResourceType(AWSResourceType.LAUNCH_CONFIG);
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(imageResource));
Assert.assertFalse(rule.isValid(asgResource));
Assert.assertFalse(rule.isValid(ebsSnapshotResource));
Assert.assertFalse(rule.isValid(lauchConfigurationResource));
TestUtils.verifyTerminationTimeRough(imageResource, retentionDaysWithoutOwner, now);
TestUtils.verifyTerminationTimeRough(asgResource, retentionDaysWithoutOwner, now);
TestUtils.verifyTerminationTimeRough(ebsSnapshotResource, retentionDaysWithoutOwner, now);
TestUtils.verifyTerminationTimeRough(lauchConfigurationResource, retentionDaysWithoutOwner, now);
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestOldDetachedVolumeRule method testAttachedVolume.
@Test
public void testAttachedVolume() {
int ageThreshold = 5;
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("vol-12345678901234567").withResourceType(AWSResourceType.EBS_VOLUME).withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
((AWSResource) resource).setAWSResourceState("available");
String metaTag = VolumeTaggingMonkey.makeMetaTag("i-12345678901234567", "owner", null);
resource.setTag(JanitorMonkey.JANITOR_META_TAG, metaTag);
int retentionDays = 4;
OldDetachedVolumeRule rule = new OldDetachedVolumeRule(new TestMonkeyCalendar(), ageThreshold, retentionDays);
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestOldDetachedVolumeRule method testTaggedAsNotMark.
@Test
public void testTaggedAsNotMark() {
int ageThreshold = 5;
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("vol-12345678901234567").withResourceType(AWSResourceType.EBS_VOLUME).withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
((AWSResource) resource).setAWSResourceState("available");
Date lastDetachTime = new Date(now.minusDays(ageThreshold + 1).getMillis());
String metaTag = VolumeTaggingMonkey.makeMetaTag(null, null, lastDetachTime);
resource.setTag(JanitorMonkey.JANITOR_META_TAG, metaTag);
int retentionDays = 4;
OldDetachedVolumeRule rule = new OldDetachedVolumeRule(new TestMonkeyCalendar(), ageThreshold, retentionDays);
resource.setTag(JanitorMonkey.JANITOR_TAG, "donotmark");
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
Aggregations