Search in sources :

Example 21 with TestChaosMonkeyContext

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

the class TestBasicChaosMonkey method testMaxTerminationCountPerDayAsBiggerThanOne.

@Test
public void testMaxTerminationCountPerDayAsBiggerThanOne() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("terminationPerDayAsBiggerThanOne.properties");
    ChaosMonkey chaos = new BasicChaosMonkey(ctx);
    chaos.start();
    chaos.stop();
    Assert.assertEquals(ctx.selectedOn().size(), 1);
    Assert.assertEquals(ctx.terminated().size(), 1);
    // Run the chaos the second time will trigger another termination
    chaos.start();
    chaos.stop();
    Assert.assertEquals(ctx.selectedOn().size(), 2);
    Assert.assertEquals(ctx.terminated().size(), 2);
}
Also used : ChaosMonkey(com.netflix.simianarmy.chaos.ChaosMonkey) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) Test(org.testng.annotations.Test)

Example 22 with TestChaosMonkeyContext

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

the class TestBasicChaosMonkey method testEnabledAwithout1.

@Test
public void testEnabledAwithout1() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("enabledAwithout1.properties");
    ChaosMonkey chaos = new BasicChaosMonkey(ctx);
    chaos.start();
    chaos.stop();
    List<InstanceGroup> selectedOn = ctx.selectedOn();
    List<String> terminated = ctx.terminated();
    Assert.assertEquals(selectedOn.size(), 1);
    Assert.assertEquals(selectedOn.get(0).type(), TestChaosMonkeyContext.CrawlerTypes.TYPE_A);
    Assert.assertEquals(selectedOn.get(0).name(), "name0");
    Assert.assertEquals(terminated.size(), 1);
    Assert.assertEquals(terminated.get(0), "0:i-123456789012345670");
}
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 23 with TestChaosMonkeyContext

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

the class TestBasicChaosMonkey method testEnabledAwith0.

@Test
public void testEnabledAwith0() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("enabledAwith0.properties");
    ChaosMonkey chaos = new BasicChaosMonkey(ctx);
    chaos.start();
    chaos.stop();
    List<InstanceGroup> selectedOn = ctx.selectedOn();
    List<String> terminated = ctx.terminated();
    Assert.assertEquals(selectedOn.size(), 1);
    Assert.assertEquals(selectedOn.get(0).type(), TestChaosMonkeyContext.CrawlerTypes.TYPE_A);
    Assert.assertEquals(selectedOn.get(0).name(), "name0");
    Assert.assertEquals(terminated.size(), 1);
    Assert.assertEquals(terminated.get(0), "0:i-123456789012345670");
}
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 24 with TestChaosMonkeyContext

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

the class TestBasicChaosMonkey method testGlobalNotificationEnabled.

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

Example 25 with TestChaosMonkeyContext

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

the class TestBasicChaosMonkey method testFullProbability.

@Test
public void testFullProbability() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("fullProbability.properties") {

        @Override
        public MonkeyScheduler scheduler() {
            return new MonkeyScheduler() {

                @Override
                public int frequency() {
                    return 1;
                }

                @Override
                public TimeUnit frequencyUnit() {
                    return TimeUnit.DAYS;
                }

                @Override
                public void start(Monkey monkey, Runnable run) {
                    Assert.assertEquals(monkey.type().name(), monkey.type().name(), "starting monkey");
                    run.run();
                }

                @Override
                public void stop(Monkey monkey) {
                    Assert.assertEquals(monkey.type().name(), monkey.type().name(), "stopping monkey");
                }
            };
        }
    };
    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(), 4);
}
Also used : ChaosMonkey(com.netflix.simianarmy.chaos.ChaosMonkey) ChaosMonkey(com.netflix.simianarmy.chaos.ChaosMonkey) Monkey(com.netflix.simianarmy.Monkey) MonkeyScheduler(com.netflix.simianarmy.MonkeyScheduler) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) InstanceGroup(com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup) 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