Search in sources :

Example 16 with Resource

use of com.netflix.simianarmy.Resource 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);
}
Also used : AWSResource(com.netflix.simianarmy.aws.AWSResource) Resource(com.netflix.simianarmy.Resource) AWSResource(com.netflix.simianarmy.aws.AWSResource) RowMapper(org.springframework.jdbc.core.RowMapper) Test(org.testng.annotations.Test)

Example 17 with Resource

use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.

the class TestASGJanitorCrawler method testInstancesWithNames.

@Test
public void testInstancesWithNames() {
    List<AutoScalingGroup> asgList = createASGList();
    String[] asgNames = { "asg1", "asg2" };
    AWSClient awsMock = createMockAWSClient(asgList, asgNames);
    ASGJanitorCrawler crawler = new ASGJanitorCrawler(awsMock);
    List<Resource> resources = crawler.resources(asgNames);
    verifyASGList(resources, asgList);
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) Resource(com.netflix.simianarmy.Resource) AWSClient(com.netflix.simianarmy.client.aws.AWSClient) Test(org.testng.annotations.Test)

Example 18 with Resource

use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.

the class TestASGJanitorCrawler method testInstancesWithResourceType.

@Test
public void testInstancesWithResourceType() {
    List<AutoScalingGroup> asgList = createASGList();
    AWSClient awsMock = createMockAWSClient(asgList);
    ASGJanitorCrawler crawler = new ASGJanitorCrawler(awsMock);
    for (AWSResourceType resourceType : AWSResourceType.values()) {
        List<Resource> resources = crawler.resources(resourceType);
        if (resourceType == AWSResourceType.ASG) {
            verifyASGList(resources, asgList);
        } else {
            Assert.assertTrue(resources.isEmpty());
        }
    }
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) AWSResourceType(com.netflix.simianarmy.aws.AWSResourceType) Resource(com.netflix.simianarmy.Resource) AWSClient(com.netflix.simianarmy.client.aws.AWSClient) Test(org.testng.annotations.Test)

Example 19 with Resource

use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.

the class TestInstanceJanitorCrawler method testInstancesWithNullIds.

@Test
public void testInstancesWithNullIds() {
    List<AutoScalingInstanceDetails> instanceDetailsList = createInstanceDetailsList();
    List<Instance> instanceList = createInstanceList();
    AWSClient awsMock = createMockAWSClient(instanceDetailsList, instanceList);
    InstanceJanitorCrawler crawler = new InstanceJanitorCrawler(awsMock);
    List<Resource> resources = crawler.resources();
    verifyInstanceList(resources, instanceDetailsList);
}
Also used : Instance(com.amazonaws.services.ec2.model.Instance) Resource(com.netflix.simianarmy.Resource) AWSResource(com.netflix.simianarmy.aws.AWSResource) AutoScalingInstanceDetails(com.amazonaws.services.autoscaling.model.AutoScalingInstanceDetails) AWSClient(com.netflix.simianarmy.client.aws.AWSClient) Test(org.testng.annotations.Test)

Example 20 with Resource

use of com.netflix.simianarmy.Resource in project SimianArmy by Netflix.

the class TestInstanceJanitorCrawler method testInstancesWithResourceType.

@Test
public void testInstancesWithResourceType() {
    List<AutoScalingInstanceDetails> instanceDetailsList = createInstanceDetailsList();
    List<Instance> instanceList = createInstanceList();
    AWSClient awsMock = createMockAWSClient(instanceDetailsList, instanceList);
    InstanceJanitorCrawler crawler = new InstanceJanitorCrawler(awsMock);
    for (AWSResourceType resourceType : AWSResourceType.values()) {
        List<Resource> resources = crawler.resources(resourceType);
        if (resourceType == AWSResourceType.INSTANCE) {
            verifyInstanceList(resources, instanceDetailsList);
        } else {
            Assert.assertTrue(resources.isEmpty());
        }
    }
}
Also used : Instance(com.amazonaws.services.ec2.model.Instance) AWSResourceType(com.netflix.simianarmy.aws.AWSResourceType) Resource(com.netflix.simianarmy.Resource) AWSResource(com.netflix.simianarmy.aws.AWSResource) AutoScalingInstanceDetails(com.amazonaws.services.autoscaling.model.AutoScalingInstanceDetails) AWSClient(com.netflix.simianarmy.client.aws.AWSClient) 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