Search in sources :

Example 31 with AWSClient

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

the class TestInstanceJanitorCrawler method createMockAWSClient.

private AWSClient createMockAWSClient(List<AutoScalingInstanceDetails> instanceDetailsList, List<Instance> instanceList, String... ids) {
    AWSClient awsMock = mock(AWSClient.class);
    when(awsMock.describeAutoScalingInstances(ids)).thenReturn(instanceDetailsList);
    when(awsMock.describeInstances(ids)).thenReturn(instanceList);
    when(awsMock.region()).thenReturn("us-east-1");
    return awsMock;
}
Also used : AWSClient(com.netflix.simianarmy.client.aws.AWSClient)

Example 32 with AWSClient

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

the class TestInstanceJanitorCrawler method testInstancesNotExistingInASG.

@Test
public void testInstancesNotExistingInASG() {
    List<AutoScalingInstanceDetails> instanceDetailsList = Collections.emptyList();
    List<Instance> instanceList = createInstanceList();
    AWSClient awsMock = createMockAWSClient(instanceDetailsList, instanceList);
    InstanceJanitorCrawler crawler = new InstanceJanitorCrawler(awsMock);
    List<Resource> resources = crawler.resources();
    Assert.assertEquals(resources.size(), instanceList.size());
}
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 33 with AWSClient

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

the class TestInstanceJanitorCrawler method testInstancesWithIds.

@Test
public void testInstancesWithIds() {
    List<AutoScalingInstanceDetails> instanceDetailsList = createInstanceDetailsList();
    List<Instance> instanceList = createInstanceList();
    String[] ids = { "i-12345678901234560", "i-12345678901234561" };
    AWSClient awsMock = createMockAWSClient(instanceDetailsList, instanceList, ids);
    InstanceJanitorCrawler crawler = new InstanceJanitorCrawler(awsMock);
    List<Resource> resources = crawler.resources(ids);
    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 34 with AWSClient

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

the class TestLaunchConfigJanitorCrawler method createMockAWSClient.

private AWSClient createMockAWSClient(List<AutoScalingGroup> asgList, List<LaunchConfiguration> lcList, String... lcNames) {
    AWSClient awsMock = mock(AWSClient.class);
    when(awsMock.describeAutoScalingGroups()).thenReturn(asgList);
    when(awsMock.describeLaunchConfigurations(lcNames)).thenReturn(lcList);
    when(awsMock.region()).thenReturn("us-east-1");
    return awsMock;
}
Also used : AWSClient(com.netflix.simianarmy.client.aws.AWSClient)

Example 35 with AWSClient

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

the class TestELBJanitorCrawler method testElbsWithNoInstances.

@Test
public void testElbsWithNoInstances() {
    boolean includeInstances = false;
    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)

Aggregations

AWSClient (com.netflix.simianarmy.client.aws.AWSClient)37 Resource (com.netflix.simianarmy.Resource)18 Test (org.testng.annotations.Test)15 AutoScalingGroup (com.amazonaws.services.autoscaling.model.AutoScalingGroup)11 AWSResource (com.netflix.simianarmy.aws.AWSResource)10 Instance (com.amazonaws.services.ec2.model.Instance)7 LoadBalancerDescription (com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription)6 AutoScalingInstanceDetails (com.amazonaws.services.autoscaling.model.AutoScalingInstanceDetails)5 LinkedList (java.util.LinkedList)4 Tag (com.amazonaws.services.ec2.model.Tag)3 Instance (com.amazonaws.services.autoscaling.model.Instance)2 LaunchConfiguration (com.amazonaws.services.autoscaling.model.LaunchConfiguration)2 SuspendedProcess (com.amazonaws.services.autoscaling.model.SuspendedProcess)2 TagDescription (com.amazonaws.services.autoscaling.model.TagDescription)2 AmazonSimpleDB (com.amazonaws.services.simpledb.AmazonSimpleDB)2 AWSResourceType (com.netflix.simianarmy.aws.AWSResourceType)2 Cluster (com.netflix.simianarmy.conformity.Cluster)2 GroupIdentifier (com.amazonaws.services.ec2.model.GroupIdentifier)1 Snapshot (com.amazonaws.services.ec2.model.Snapshot)1 Volume (com.amazonaws.services.ec2.model.Volume)1