use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestOldDetachedVolumeRule method testDetachedVolumeNotOld.
@Test
public void testDetachedVolumeNotOld() {
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);
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestOldDetachedVolumeRule method testNonVolumeResource.
@Test
public void testNonVolumeResource() {
Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
((AWSResource) resource).setAWSResourceState("available");
OldDetachedVolumeRule rule = new OldDetachedVolumeRule(new TestMonkeyCalendar(), 0, 0);
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestOrphanedELBRule method testMissingCountsCheckWithExtraFields.
@Test
public void testMissingCountsCheckWithExtraFields() {
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("test-elb").withResourceType(AWSResourceType.ELB).withOwnerEmail("owner@foo.com");
resource.setAdditionalField("bogusField1", "0");
resource.setAdditionalField("bogusField2", "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 TestTagValueExclusionRule method testExcludeTaggedResourceTagMatchOnly.
@Test
public void testExcludeTaggedResourceTagMatchOnly() {
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", "somethingelse2");
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 testNameValueConstructor2.
@Test
public void testNameValueConstructor2() {
Resource r1 = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE).withOwnerEmail("owner@foo.com");
r1.setTag("tag1", "excludeme");
String names = "tag1,tag2";
String vals = "excludeme,excludeme2";
TagValueExclusionRule rule = new TagValueExclusionRule(names.split(","), vals.split(","));
Assert.assertTrue(rule.isValid(r1));
}
Aggregations