use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestELBJanitorCrawler method testElbsWithInstances.
@Test
public void testElbsWithInstances() {
boolean includeInstances = true;
AWSClient client = createMockAWSClient();
List<LoadBalancerDescription> elbs = createELBList(includeInstances);
addELBsToMock(client, elbs);
ELBJanitorCrawler crawler = new ELBJanitorCrawler(client);
List<Resource> resources = crawler.resources();
verifyELBList(resources, elbs);
}
use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class TestELBJanitorCrawler method testElbsWithNoReferencedASGs.
@Test
public void testElbsWithNoReferencedASGs() {
boolean includeInstances = true;
boolean includeELbs = false;
AWSClient client = createMockAWSClient();
List<LoadBalancerDescription> elbs = createELBList(includeInstances);
List<AutoScalingGroup> asgs = createASGList(includeELbs);
addELBsToMock(client, elbs);
addASGsToMock(client, asgs);
ELBJanitorCrawler crawler = new ELBJanitorCrawler(client);
List<Resource> resources = crawler.resources();
verifyELBList(resources, elbs, 0);
}
use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class AlwaysInvalidRule method testWithExclusionRuleNotMatch1.
@Test
void testWithExclusionRuleNotMatch1() {
Resource resource = new AWSResource().withId("id");
DateTime now = DateTime.now();
BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine().addExclusionRule(new AlwaysInvalidRule(now, 1)).addRule(new AlwaysInvalidRule(now, 1));
Assert.assertFalse(engine.isValid(resource));
}
use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class AlwaysInvalidRule method testAllValid.
@Test
public void testAllValid() {
Resource resource = new AWSResource().withId("id");
BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine().addRule(new AlwaysValidRule()).addRule(new AlwaysValidRule()).addRule(new AlwaysValidRule());
Assert.assertTrue(engine.isValid(resource));
}
use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.
the class AlwaysInvalidRule method testIsValidWithNearestTerminationTime.
@Test
public void testIsValidWithNearestTerminationTime() {
int[][] permutaions = { { 1, 2, 3 }, { 1, 3, 2 }, { 2, 1, 3 }, { 2, 3, 1 }, { 3, 1, 2 }, { 3, 2, 1 } };
for (int[] perm : permutaions) {
Resource resource = new AWSResource().withId("id");
DateTime now = DateTime.now();
BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine().addRule(new AlwaysInvalidRule(now, perm[0])).addRule(new AlwaysInvalidRule(now, perm[1])).addRule(new AlwaysInvalidRule(now, perm[2]));
Assert.assertFalse(engine.isValid(resource));
Assert.assertEquals(resource.getExpectedTerminationTime().getTime(), now.plusDays(1).getMillis());
Assert.assertEquals(resource.getTerminationReason(), "1");
}
}
Aggregations