Search in sources :

Example 16 with InstanceGroup

use of com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup 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 17 with InstanceGroup

use of com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup 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)

Example 18 with InstanceGroup

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

the class TestBasicChaosMonkey method testUnleashedEnabledB.

@Test
public void testUnleashedEnabledB() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("unleashedEnabledB.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(), 2);
    Assert.assertEquals(terminated.get(0), "2:i-123456789012345672");
    Assert.assertEquals(terminated.get(1), "3:i-123456789012345673");
}
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 19 with InstanceGroup

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

the class TestBasicChaosMonkey method testUnleashedEnabledA.

@Test
public void testUnleashedEnabledA() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("unleashedEnabledA.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(), 2);
    Assert.assertEquals(terminated.get(0), "0:i-123456789012345670");
    Assert.assertEquals(terminated.get(1), "1:i-123456789012345671");
}
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 20 with InstanceGroup

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

the class TestCloudFormationChaosMonkey method testIsGroupEnabled.

@Test
public void testIsGroupEnabled() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("cloudformation.properties");
    CloudFormationChaosMonkey chaos = new CloudFormationChaosMonkey(ctx);
    InstanceGroup group1 = new BasicInstanceGroup("new-group-TestGroup1-XCFNFNFNF", TestChaosMonkeyContext.CrawlerTypes.TYPE_D, "region", Collections.<TagDescription>emptyList());
    InstanceGroup group2 = new BasicInstanceGroup("new-group-TestGroup2-XCFNGHFNF", TestChaosMonkeyContext.CrawlerTypes.TYPE_D, "region", Collections.<TagDescription>emptyList());
    assertTrue(chaos.isGroupEnabled(group1));
    assertFalse(chaos.isGroupEnabled(group2));
}
Also used : 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