Search in sources :

Example 26 with Resource

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);
}
Also used : Resource(com.netflix.simianarmy.Resource) AWSClient(com.netflix.simianarmy.client.aws.AWSClient) LoadBalancerDescription(com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription) Test(org.testng.annotations.Test)

Example 27 with Resource

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);
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) Resource(com.netflix.simianarmy.Resource) AWSClient(com.netflix.simianarmy.client.aws.AWSClient) LoadBalancerDescription(com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription) Test(org.testng.annotations.Test)

Example 28 with Resource

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));
}
Also used : AWSResource(com.netflix.simianarmy.aws.AWSResource) AWSResource(com.netflix.simianarmy.aws.AWSResource) Resource(com.netflix.simianarmy.Resource) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 29 with 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));
}
Also used : AWSResource(com.netflix.simianarmy.aws.AWSResource) AWSResource(com.netflix.simianarmy.aws.AWSResource) Resource(com.netflix.simianarmy.Resource) Test(org.testng.annotations.Test)

Example 30 with 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");
    }
}
Also used : AWSResource(com.netflix.simianarmy.aws.AWSResource) AWSResource(com.netflix.simianarmy.aws.AWSResource) Resource(com.netflix.simianarmy.Resource) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Aggregations

Resource (com.netflix.simianarmy.Resource)145 AWSResource (com.netflix.simianarmy.aws.AWSResource)132 Test (org.testng.annotations.Test)110 TestMonkeyCalendar (com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar)64 DateTime (org.joda.time.DateTime)60 Date (java.util.Date)45 MonkeyCalendar (com.netflix.simianarmy.MonkeyCalendar)21 AWSClient (com.netflix.simianarmy.client.aws.AWSClient)18 JsonNode (org.codehaus.jackson.JsonNode)17 AWSResourceType (com.netflix.simianarmy.aws.AWSResourceType)11 BeforeTest (org.testng.annotations.BeforeTest)9 AutoScalingGroup (com.amazonaws.services.autoscaling.model.AutoScalingGroup)8 LoadBalancerDescription (com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription)6 HashSet (java.util.HashSet)6 AutoScalingInstanceDetails (com.amazonaws.services.autoscaling.model.AutoScalingInstanceDetails)5 Instance (com.amazonaws.services.ec2.model.Instance)5 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 RowMapper (org.springframework.jdbc.core.RowMapper)5 Snapshot (com.amazonaws.services.ec2.model.Snapshot)4