Search in sources :

Example 1 with BasicInstanceGroup

use of com.netflix.simianarmy.basic.chaos.BasicInstanceGroup in project SimianArmy by Netflix.

the class ASGChaosCrawler method getInstanceGroup.

/**
     * Returns the desired InstanceGroup.  If there is no set aggression coefficient, then it
     * returns the basic impl, otherwise it returns the tunable impl.
     * @param asg The autoscaling group 
     * @return The appropriate {@link InstanceGroup}
     */
protected InstanceGroup getInstanceGroup(AutoScalingGroup asg, double aggressionCoefficient) {
    InstanceGroup instanceGroup;
    // if coefficient is 1 then the BasicInstanceGroup is fine, otherwise use Tunable
    if (aggressionCoefficient == 1.0) {
        instanceGroup = new BasicInstanceGroup(asg.getAutoScalingGroupName(), Types.ASG, awsClient.region(), asg.getTags());
    } else {
        TunableInstanceGroup tunable = new TunableInstanceGroup(asg.getAutoScalingGroupName(), Types.ASG, awsClient.region(), asg.getTags());
        tunable.setAggressionCoefficient(aggressionCoefficient);
        instanceGroup = tunable;
    }
    return instanceGroup;
}
Also used : TunableInstanceGroup(com.netflix.simianarmy.tunable.TunableInstanceGroup) BasicInstanceGroup(com.netflix.simianarmy.basic.chaos.BasicInstanceGroup) TunableInstanceGroup(com.netflix.simianarmy.tunable.TunableInstanceGroup) BasicInstanceGroup(com.netflix.simianarmy.basic.chaos.BasicInstanceGroup)

Example 2 with BasicInstanceGroup

use of com.netflix.simianarmy.basic.chaos.BasicInstanceGroup in project SimianArmy by Netflix.

the class TestFilterASGChaosCrawler method testFilterGroups.

@Test
public void testFilterGroups() {
    List<TagDescription> tagList = new ArrayList<TagDescription>();
    TagDescription td = new TagDescription();
    td.setKey(tagKey);
    td.setValue(tagValue);
    tagList.add(td);
    List<InstanceGroup> listGroup = new LinkedList<InstanceGroup>();
    listGroup.add(new BasicInstanceGroup("asg1", Types.ASG, "region1", tagList));
    listGroup.add(new BasicInstanceGroup("asg2", Types.ASG, "region2", Collections.<TagDescription>emptyList()));
    listGroup.add(new BasicInstanceGroup("asg3", Types.ASG, "region3", tagList));
    listGroup.add(new BasicInstanceGroup("asg4", Types.ASG, "region4", Collections.<TagDescription>emptyList()));
    when(crawlerMock.groups()).thenReturn(listGroup);
    List<InstanceGroup> groups = crawlerMock.groups();
    assertEquals(groups.size(), 4);
    groups = crawler.groups();
    assertEquals(groups.size(), 2);
    assertEquals(groups.get(0).name(), "asg1");
    assertEquals(groups.get(1).name(), "asg3");
}
Also used : BasicInstanceGroup(com.netflix.simianarmy.basic.chaos.BasicInstanceGroup) TagDescription(com.amazonaws.services.autoscaling.model.TagDescription) InstanceGroup(com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup) BasicInstanceGroup(com.netflix.simianarmy.basic.chaos.BasicInstanceGroup) BeforeTest(org.testng.annotations.BeforeTest) Test(org.testng.annotations.Test)

Example 3 with BasicInstanceGroup

use of com.netflix.simianarmy.basic.chaos.BasicInstanceGroup in project SimianArmy by Netflix.

the class TestASGChaosCrawler method testGetInstanceGroup_basic.

@Test
public void testGetInstanceGroup_basic() {
    AutoScalingGroup asg = mkAsg("asg1", "i-123456789012345670");
    InstanceGroup group = crawler.getInstanceGroup(asg, 1.0);
    Assert.assertTrue((group instanceof BasicInstanceGroup));
    Assert.assertFalse((group instanceof TunableInstanceGroup));
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) TunableInstanceGroup(com.netflix.simianarmy.tunable.TunableInstanceGroup) BasicInstanceGroup(com.netflix.simianarmy.basic.chaos.BasicInstanceGroup) InstanceGroup(com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup) TunableInstanceGroup(com.netflix.simianarmy.tunable.TunableInstanceGroup) BasicInstanceGroup(com.netflix.simianarmy.basic.chaos.BasicInstanceGroup) Test(org.testng.annotations.Test)

Example 4 with BasicInstanceGroup

use of com.netflix.simianarmy.basic.chaos.BasicInstanceGroup in project SimianArmy by Netflix.

the class TestTunablyAggressiveChaosMonkey method testFullProbability_basic.

@Test
public void testFullProbability_basic() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("fullProbability.properties");
    TunablyAggressiveChaosMonkey chaos = new TunablyAggressiveChaosMonkey(ctx);
    InstanceGroup basic = new BasicInstanceGroup("basic", GroupTypes.TYPE_A, "region", Collections.<TagDescription>emptyList());
    double probability = chaos.getEffectiveProbability(basic);
    Assert.assertEquals(probability, 1.0);
}
Also used : BasicInstanceGroup(com.netflix.simianarmy.basic.chaos.BasicInstanceGroup) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) InstanceGroup(com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup) BasicInstanceGroup(com.netflix.simianarmy.basic.chaos.BasicInstanceGroup) Test(org.testng.annotations.Test)

Aggregations

BasicInstanceGroup (com.netflix.simianarmy.basic.chaos.BasicInstanceGroup)4 InstanceGroup (com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup)3 Test (org.testng.annotations.Test)3 TunableInstanceGroup (com.netflix.simianarmy.tunable.TunableInstanceGroup)2 AutoScalingGroup (com.amazonaws.services.autoscaling.model.AutoScalingGroup)1 TagDescription (com.amazonaws.services.autoscaling.model.TagDescription)1 TestChaosMonkeyContext (com.netflix.simianarmy.chaos.TestChaosMonkeyContext)1 BeforeTest (org.testng.annotations.BeforeTest)1