Search in sources :

Example 16 with AWSResource

use of com.netflix.simianarmy.aws.AWSResource 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 17 with AWSResource

use of com.netflix.simianarmy.aws.AWSResource 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 18 with AWSResource

use of com.netflix.simianarmy.aws.AWSResource 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)

Example 19 with AWSResource

use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.

the class AlwaysInvalidRule method testWithExclusionRuleMatch2.

@Test
void testWithExclusionRuleMatch2() {
    Resource resource = new AWSResource().withId("id");
    DateTime now = DateTime.now();
    BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine().addExclusionRule(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) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 20 with AWSResource

use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.

the class AlwaysInvalidRule method testMixed.

@Test
public void testMixed() {
    Resource resource = new AWSResource().withId("id");
    DateTime now = DateTime.now();
    BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine().addRule(new AlwaysValidRule()).addRule(new AlwaysInvalidRule(now, 1)).addRule(new AlwaysValidRule());
    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)

Aggregations

AWSResource (com.netflix.simianarmy.aws.AWSResource)109 Resource (com.netflix.simianarmy.Resource)102 Test (org.testng.annotations.Test)89 TestMonkeyCalendar (com.netflix.simianarmy.aws.janitor.rule.TestMonkeyCalendar)64 DateTime (org.joda.time.DateTime)63 Date (java.util.Date)41 MonkeyCalendar (com.netflix.simianarmy.MonkeyCalendar)21 BeforeTest (org.testng.annotations.BeforeTest)9 JsonNode (org.codehaus.jackson.JsonNode)7 AWSClient (com.netflix.simianarmy.client.aws.AWSClient)6 AWSResourceType (com.netflix.simianarmy.aws.AWSResourceType)5 HashSet (java.util.HashSet)5 RowMapper (org.springframework.jdbc.core.RowMapper)5 LinkedList (java.util.LinkedList)4 Tag (com.amazonaws.services.ec2.model.Tag)3 HashMap (java.util.HashMap)3 AutoScalingGroup (com.amazonaws.services.autoscaling.model.AutoScalingGroup)2 LaunchConfiguration (com.amazonaws.services.autoscaling.model.LaunchConfiguration)2 AutoScalingInstanceDetails (com.amazonaws.services.autoscaling.model.AutoScalingInstanceDetails)1 Instance (com.amazonaws.services.autoscaling.model.Instance)1