use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestTagValueExclusionRule method testExcludeTaggedResourceWithTagAndValueMatch1.
@Test
public void testExcludeTaggedResourceWithTagAndValueMatch1() {
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", "somethingelse");
TagValueExclusionRule rule = new TagValueExclusionRule(exclusionTags);
Assert.assertTrue(rule.isValid(r1));
}
use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestTagValueExclusionRule method testExcludeTaggedResourceValueMatchOnly.
@Test
public void testExcludeTaggedResourceValueMatchOnly() {
Resource r1 = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE).withOwnerEmail("owner@foo.com");
r1.setTag("tag", null);
r1.setTag("tagA", "excludeme");
r1.setTag("tagB", "excludeme2");
TagValueExclusionRule rule = new TagValueExclusionRule(exclusionTags);
Assert.assertFalse(rule.isValid(r1));
}
use of com.netflix.simianarmy.Resource 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.Resource 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.Resource 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);
}
Aggregations