Search in sources :

Example 6 with InstanceGroup

use of com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup in project SimianArmy by Netflix.

the class TestBasicChaosMonkey method testEnabledB.

@Test
public void testEnabledB() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("enabledB.properties");
    ChaosMonkey chaos = new BasicChaosMonkey(ctx);
    chaos.start();
    chaos.stop();
    List<InstanceGroup> selectedOn = ctx.selectedOn();
    List<String> terminated = ctx.terminated();
    Assert.assertEquals(selectedOn.size(), 2);
    Assert.assertEquals(selectedOn.get(0).type(), TestChaosMonkeyContext.CrawlerTypes.TYPE_B);
    Assert.assertEquals(selectedOn.get(0).name(), "name2");
    Assert.assertEquals(selectedOn.get(1).type(), TestChaosMonkeyContext.CrawlerTypes.TYPE_B);
    Assert.assertEquals(selectedOn.get(1).name(), "name3");
    Assert.assertEquals(terminated.size(), 0, "nothing terminated");
}
Also used : ChaosMonkey(com.netflix.simianarmy.chaos.ChaosMonkey) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) InstanceGroup(com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup) Test(org.testng.annotations.Test)

Example 7 with InstanceGroup

use of com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup in project SimianArmy by Netflix.

the class TestBasicChaosMonkey method testDisabled.

@Test
public void testDisabled() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("disabled.properties");
    ChaosMonkey chaos = new BasicChaosMonkey(ctx);
    chaos.start();
    chaos.stop();
    List<InstanceGroup> selectedOn = ctx.selectedOn();
    List<String> terminated = ctx.terminated();
    Assert.assertEquals(selectedOn.size(), 0, "no groups selected on");
    Assert.assertEquals(terminated.size(), 0, "nothing terminated");
}
Also used : ChaosMonkey(com.netflix.simianarmy.chaos.ChaosMonkey) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) InstanceGroup(com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup) Test(org.testng.annotations.Test)

Example 8 with InstanceGroup

use of com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup in project SimianArmy by Netflix.

the class TestBasicChaosMonkey method testNoProbabilityByName.

@Test
public void testNoProbabilityByName() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("noProbabilityByName.properties");
    ChaosMonkey chaos = new BasicChaosMonkey(ctx);
    chaos.start();
    chaos.stop();
    List<InstanceGroup> selectedOn = ctx.selectedOn();
    List<String> terminated = ctx.terminated();
    Assert.assertEquals(selectedOn.size(), 4);
    Assert.assertEquals(selectedOn.get(0).type(), TestChaosMonkeyContext.CrawlerTypes.TYPE_A);
    Assert.assertEquals(selectedOn.get(0).name(), "name0");
    Assert.assertEquals(selectedOn.get(1).type(), TestChaosMonkeyContext.CrawlerTypes.TYPE_A);
    Assert.assertEquals(selectedOn.get(1).name(), "name1");
    Assert.assertEquals(selectedOn.get(2).type(), TestChaosMonkeyContext.CrawlerTypes.TYPE_B);
    Assert.assertEquals(selectedOn.get(2).name(), "name2");
    Assert.assertEquals(selectedOn.get(3).type(), TestChaosMonkeyContext.CrawlerTypes.TYPE_B);
    Assert.assertEquals(selectedOn.get(3).name(), "name3");
    Assert.assertEquals(terminated.size(), 0);
}
Also used : ChaosMonkey(com.netflix.simianarmy.chaos.ChaosMonkey) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) InstanceGroup(com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup) Test(org.testng.annotations.Test)

Example 9 with InstanceGroup

use of com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup in project SimianArmy by Netflix.

the class TestBasicChaosMonkey method testGetValueFromCfgWithDefault.

@Test
public void testGetValueFromCfgWithDefault() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("propertiesWithDefaults.properties");
    BasicChaosMonkey chaos = new BasicChaosMonkey(ctx);
    // named 1 has actual values in config
    InstanceGroup named1 = new BasicInstanceGroup("named1", GroupTypes.TYPE_A, "test-dev-1", Collections.<TagDescription>emptyList());
    // named 2 doesn't have values but it's group has values
    InstanceGroup named2 = new BasicInstanceGroup("named2", GroupTypes.TYPE_A, "test-dev-1", Collections.<TagDescription>emptyList());
    // named 3 doesn't have values and it's group doesn't have values
    InstanceGroup named3 = new BasicInstanceGroup("named3", GroupTypes.TYPE_B, "test-dev-1", Collections.<TagDescription>emptyList());
    Assert.assertEquals(chaos.getBoolFromCfgOrDefault(named1, "enabled", true), false);
    Assert.assertEquals(chaos.getNumFromCfgOrDefault(named1, "probability", 3.0), 1.1);
    Assert.assertEquals(chaos.getNumFromCfgOrDefault(named1, "maxTerminationsPerDay", 4.0), 2.1);
    Assert.assertEquals(chaos.getBoolFromCfgOrDefault(named2, "enabled", true), true);
    Assert.assertEquals(chaos.getNumFromCfgOrDefault(named2, "probability", 3.0), 1.0);
    Assert.assertEquals(chaos.getNumFromCfgOrDefault(named2, "maxTerminationsPerDay", 4.0), 2.0);
    Assert.assertEquals(chaos.getBoolFromCfgOrDefault(named3, "enabled", true), true);
    Assert.assertEquals(chaos.getNumFromCfgOrDefault(named3, "probability", 3.0), 3.0);
    Assert.assertEquals(chaos.getNumFromCfgOrDefault(named3, "maxTerminationsPerDay", 4.0), 4.0);
}
Also used : TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) InstanceGroup(com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup) Test(org.testng.annotations.Test)

Example 10 with InstanceGroup

use of com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup in project SimianArmy by Netflix.

the class TestBasicChaosMonkey method testEnabledA.

@Test
public void testEnabledA() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("enabledA.properties");
    ChaosMonkey chaos = new BasicChaosMonkey(ctx);
    chaos.start();
    chaos.stop();
    List<InstanceGroup> selectedOn = ctx.selectedOn();
    List<String> terminated = ctx.terminated();
    Assert.assertEquals(selectedOn.size(), 2);
    Assert.assertEquals(selectedOn.get(0).type(), TestChaosMonkeyContext.CrawlerTypes.TYPE_A);
    Assert.assertEquals(selectedOn.get(0).name(), "name0");
    Assert.assertEquals(selectedOn.get(1).type(), TestChaosMonkeyContext.CrawlerTypes.TYPE_A);
    Assert.assertEquals(selectedOn.get(1).name(), "name1");
    Assert.assertEquals(terminated.size(), 0, "nothing terminated");
}
Also used : ChaosMonkey(com.netflix.simianarmy.chaos.ChaosMonkey) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) InstanceGroup(com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup) Test(org.testng.annotations.Test)

Aggregations

InstanceGroup (com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup)25 Test (org.testng.annotations.Test)21 TestChaosMonkeyContext (com.netflix.simianarmy.chaos.TestChaosMonkeyContext)18 ChaosMonkey (com.netflix.simianarmy.chaos.ChaosMonkey)11 BasicInstanceGroup (com.netflix.simianarmy.basic.chaos.BasicInstanceGroup)4 AutoScalingGroup (com.amazonaws.services.autoscaling.model.AutoScalingGroup)2 TunableInstanceGroup (com.netflix.simianarmy.tunable.TunableInstanceGroup)2 TagDescription (com.amazonaws.services.autoscaling.model.TagDescription)1 Monkey (com.netflix.simianarmy.Monkey)1 MonkeyScheduler (com.netflix.simianarmy.MonkeyScheduler)1 BeforeTest (org.testng.annotations.BeforeTest)1