use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestAWSResource method testParseFieldToValueMap.
@Test
public void testParseFieldToValueMap() throws Exception {
Date now = new Date();
Map<String, String> map = getTestingFieldValueMap(now, getTestingFields());
AWSResource resource = AWSResource.parseFieldtoValueMap(map);
Map<String, String> resourceFieldValueMap = resource.getFieldToValueMap();
verifyMapsAreEqual(resourceFieldValueMap, map);
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestRDSJanitorResourceTracker method testGetResourceNotFound.
@SuppressWarnings("unchecked")
@Test
public void testGetResourceNotFound() {
ArrayList<AWSResource> resources = new ArrayList<>();
TestRDSJanitorResourceTracker tracker = new TestRDSJanitorResourceTracker();
when(tracker.getJdbcTemplate().query(Matchers.anyString(), Matchers.any(Object[].class), Matchers.any(RowMapper.class))).thenReturn(resources);
Resource resource = tracker.getResource("id-2");
Assert.assertNull(resource);
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestOldEmptyASGRule method testResourceWithExpectedTerminationTimeSet.
@Test
public void testResourceWithExpectedTerminationTimeSet() {
Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "0");
int launchConfiguAgeThreshold = 60;
MonkeyCalendar calendar = new TestMonkeyCalendar();
DateTime now = new DateTime(calendar.now().getTimeInMillis());
int retentionDays = 3;
OldEmptyASGRule rule = new OldEmptyASGRule(calendar, launchConfiguAgeThreshold, retentionDays, new DummyASGInstanceValidator());
Date oldTermDate = new Date(now.plusDays(10).getMillis());
String oldTermReason = "Foo";
resource.setExpectedTerminationTime(oldTermDate);
resource.setTerminationReason(oldTermReason);
Assert.assertFalse(rule.isValid(resource));
Assert.assertEquals(oldTermDate, resource.getExpectedTerminationTime());
Assert.assertEquals(oldTermReason, resource.getTerminationReason());
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestOldEmptyASGRule method testASGWithInstances.
@Test
public void testASGWithInstances() {
Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_NAME, "launchConfig");
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "2");
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_INSTANCES, "123456789012345671,i-123456789012345672");
int launchConfiguAgeThreshold = 60;
MonkeyCalendar calendar = new TestMonkeyCalendar();
DateTime now = new DateTime(calendar.now().getTimeInMillis());
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_CREATION_TIME, String.valueOf(now.minusDays(launchConfiguAgeThreshold + 1).getMillis()));
int retentionDays = 3;
OldEmptyASGRule rule = new OldEmptyASGRule(calendar, launchConfiguAgeThreshold, retentionDays, new DummyASGInstanceValidator());
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class TestOldEmptyASGRule method testEmptyASGWithValidLaunchConfig.
@Test
public void testEmptyASGWithValidLaunchConfig() {
Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_NAME, "launchConfig");
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "0");
int launchConfiguAgeThreshold = 60;
MonkeyCalendar calendar = new TestMonkeyCalendar();
DateTime now = new DateTime(calendar.now().getTimeInMillis());
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_CREATION_TIME, String.valueOf(now.minusDays(launchConfiguAgeThreshold - 1).getMillis()));
int retentionDays = 3;
OldEmptyASGRule rule = new OldEmptyASGRule(calendar, launchConfiguAgeThreshold, retentionDays, new DummyASGInstanceValidator());
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
}
Aggregations