Search in sources :

Example 21 with AutoScalingGroup

use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.

the class TestASGChaosCrawler method testFindAggressionCoefficient_unparsable.

@Test
public void testFindAggressionCoefficient_unparsable() {
    AutoScalingGroup asg1 = mkAsg("asg1", "i-123456789012345670");
    Set<TagDescription> tagDescriptions = new HashSet<>();
    tagDescriptions.add(makeTunableTag("not a number"));
    asg1.setTags(tagDescriptions);
    double aggression = crawler.findAggressionCoefficient(asg1);
    Assert.assertEquals(aggression, 1.0);
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) TagDescription(com.amazonaws.services.autoscaling.model.TagDescription) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 22 with AutoScalingGroup

use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.

the class TestASGChaosCrawler method testFindAggressionCoefficient.

@Test
public void testFindAggressionCoefficient() {
    AutoScalingGroup asg1 = mkAsg("asg1", "i-123456789012345670");
    Set<TagDescription> tagDescriptions = new HashSet<>();
    tagDescriptions.add(makeTunableTag("1.0"));
    asg1.setTags(tagDescriptions);
    double aggression = crawler.findAggressionCoefficient(asg1);
    Assert.assertEquals(aggression, 1.0);
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) TagDescription(com.amazonaws.services.autoscaling.model.TagDescription) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 23 with AutoScalingGroup

use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project incubator-gobblin by apache.

the class AWSSdkClient method getAutoScalingGroupsWithTag.

/**
 * Get list of {@link AutoScalingGroup}s for a given tag
 *
 * @param tag Tag to filter the auto scaling groups
 * @return List of {@link AutoScalingGroup}s qualifying the filter tag
 */
public List<AutoScalingGroup> getAutoScalingGroupsWithTag(Tag tag) {
    final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();
    final DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest = new DescribeAutoScalingGroupsRequest();
    final List<AutoScalingGroup> allAutoScalingGroups = autoScaling.describeAutoScalingGroups(describeAutoScalingGroupsRequest).getAutoScalingGroups();
    final List<AutoScalingGroup> filteredAutoScalingGroups = Lists.newArrayList();
    for (AutoScalingGroup autoScalingGroup : allAutoScalingGroups) {
        for (TagDescription tagDescription : autoScalingGroup.getTags()) {
            if (tagDescription.getKey().equalsIgnoreCase(tag.getKey()) && tagDescription.getValue().equalsIgnoreCase(tag.getValue())) {
                filteredAutoScalingGroups.add(autoScalingGroup);
            }
        }
    }
    return filteredAutoScalingGroups;
}
Also used : DescribeAutoScalingGroupsRequest(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest) AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) TagDescription(com.amazonaws.services.autoscaling.model.TagDescription) AmazonAutoScaling(com.amazonaws.services.autoscaling.AmazonAutoScaling)

Example 24 with AutoScalingGroup

use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.

the class TestASGOwnerEmailTag method testForOwnerTag.

@Test
public void testForOwnerTag() {
    Properties properties = new Properties();
    BasicConformityMonkeyContext ctx = new BasicConformityMonkeyContext();
    List<AutoScalingGroup> asgList = createASGList();
    String[] asgNames = { ASG1, ASG2 };
    AWSClient awsMock = createMockAWSClient(asgList, asgNames);
    Map<String, AWSClient> regionToAwsClient = Maps.newHashMap();
    regionToAwsClient.put("us-east-1", awsMock);
    AWSClusterCrawler clusterCrawler = new AWSClusterCrawler(regionToAwsClient, new BasicConfiguration(properties));
    List<Cluster> clusters = clusterCrawler.clusters(asgNames);
    Assert.assertTrue(OWNER_TAG_VALUE.equalsIgnoreCase(clusters.get(0).getOwnerEmail()));
    Assert.assertNull(clusters.get(1).getOwnerEmail());
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) BasicConformityMonkeyContext(com.netflix.simianarmy.basic.conformity.BasicConformityMonkeyContext) Cluster(com.netflix.simianarmy.conformity.Cluster) AWSClient(com.netflix.simianarmy.client.aws.AWSClient) AWSClusterCrawler(com.netflix.simianarmy.aws.conformity.crawler.AWSClusterCrawler) Properties(java.util.Properties) BasicConfiguration(com.netflix.simianarmy.basic.BasicConfiguration) Test(org.testng.annotations.Test)

Example 25 with AutoScalingGroup

use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.

the class TestASGOwnerEmailTag method makeASG.

private AutoScalingGroup makeASG(String asgName, String ownerEmail) {
    TagDescription tag = new TagDescription().withKey(OWNER_TAG_KEY).withValue(ownerEmail);
    AutoScalingGroup asg = new AutoScalingGroup().withAutoScalingGroupName(asgName).withTags(tag);
    return asg;
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) TagDescription(com.amazonaws.services.autoscaling.model.TagDescription)

Aggregations

AutoScalingGroup (com.amazonaws.services.autoscaling.model.AutoScalingGroup)34 Test (org.testng.annotations.Test)16 AWSClient (com.netflix.simianarmy.client.aws.AWSClient)11 Instance (com.amazonaws.services.autoscaling.model.Instance)9 TagDescription (com.amazonaws.services.autoscaling.model.TagDescription)9 Resource (com.netflix.simianarmy.Resource)8 DescribeAutoScalingGroupsRequest (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest)5 DescribeAutoScalingGroupsResult (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult)4 HashSet (java.util.HashSet)4 SuspendedProcess (com.amazonaws.services.autoscaling.model.SuspendedProcess)3 LoadBalancerDescription (com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription)3 BasicInstanceGroup (com.netflix.simianarmy.basic.chaos.BasicInstanceGroup)3 TunableInstanceGroup (com.netflix.simianarmy.tunable.TunableInstanceGroup)3 AmazonAutoScaling (com.amazonaws.services.autoscaling.AmazonAutoScaling)2 AmazonAutoScalingClient (com.amazonaws.services.autoscaling.AmazonAutoScalingClient)2 LaunchConfiguration (com.amazonaws.services.autoscaling.model.LaunchConfiguration)2 AWSResource (com.netflix.simianarmy.aws.AWSResource)2 InstanceGroup (com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup)2 Cluster (com.netflix.simianarmy.conformity.Cluster)2 ArrayList (java.util.ArrayList)2