Search in sources :

Example 6 with TestChaosMonkeyContext

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

the class TestBasicChaosMonkey method testNotificationEnabled.

@Test
public void testNotificationEnabled() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("notificationEnabled.properties");
    ChaosMonkey chaos = new BasicChaosMonkey(ctx);
    chaos.start();
    chaos.stop();
    Assert.assertEquals(ctx.selectedOn().size(), 4);
    Assert.assertEquals(ctx.terminated().size(), 4);
    // Notification is enabled only for 2 terminations.
    Assert.assertEquals(ctx.getNotified(), 2);
}
Also used : ChaosMonkey(com.netflix.simianarmy.chaos.ChaosMonkey) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) Test(org.testng.annotations.Test)

Example 7 with TestChaosMonkeyContext

use of com.netflix.simianarmy.chaos.TestChaosMonkeyContext 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 TestChaosMonkeyContext

use of com.netflix.simianarmy.chaos.TestChaosMonkeyContext 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 TestChaosMonkeyContext

use of com.netflix.simianarmy.chaos.TestChaosMonkeyContext 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 TestChaosMonkeyContext

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

the class TestBasicChaosMonkey method testMaxTerminationCountPerDayAsVerySmall.

@Test
public void testMaxTerminationCountPerDayAsVerySmall() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("terminationPerDayAsVerySmall.properties");
    ChaosMonkey chaos = new BasicChaosMonkey(ctx);
    chaos.start();
    chaos.stop();
    Assert.assertEquals(ctx.selectedOn().size(), 0);
    Assert.assertEquals(ctx.terminated().size(), 0);
}
Also used : ChaosMonkey(com.netflix.simianarmy.chaos.ChaosMonkey) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) Test(org.testng.annotations.Test)

Aggregations

TestChaosMonkeyContext (com.netflix.simianarmy.chaos.TestChaosMonkeyContext)41 Test (org.testng.annotations.Test)41 ChaosMonkey (com.netflix.simianarmy.chaos.ChaosMonkey)27 InstanceGroup (com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup)18 BasicChaosMonkey (com.netflix.simianarmy.basic.chaos.BasicChaosMonkey)5 BeforeTest (org.testng.annotations.BeforeTest)5 Monkey (com.netflix.simianarmy.Monkey)1 MonkeyScheduler (com.netflix.simianarmy.MonkeyScheduler)1 BasicInstanceGroup (com.netflix.simianarmy.basic.chaos.BasicInstanceGroup)1