Search in sources :

Example 21 with InstanceGroup

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

the class TestChaosMonkeyContext method chaosCrawler.

@Override
public ChaosCrawler chaosCrawler() {
    return new ChaosCrawler() {

        @Override
        public EnumSet<?> groupTypes() {
            return EnumSet.allOf(CrawlerTypes.class);
        }

        @Override
        public List<InstanceGroup> groups() {
            InstanceGroup gA0 = new TestInstanceGroup(CrawlerTypes.TYPE_A, "name0", "reg1", "0:i-123456789012345670");
            InstanceGroup gA1 = new TestInstanceGroup(CrawlerTypes.TYPE_A, "name1", "reg1", "1:i-123456789012345671");
            InstanceGroup gB2 = new TestInstanceGroup(CrawlerTypes.TYPE_B, "name2", "reg1", "2:i-123456789012345672");
            InstanceGroup gB3 = new TestInstanceGroup(CrawlerTypes.TYPE_B, "name3", "reg1", "3:i-123456789012345673");
            InstanceGroup gC1 = new TestInstanceGroup(CrawlerTypes.TYPE_C, "name4", "reg1", "3:i-123456789012345674", "3:i-123456789012345675");
            InstanceGroup gC2 = new TestInstanceGroup(CrawlerTypes.TYPE_C, "name5", "reg1", "3:i-123456789012345676", "3:i-123456789012345677");
            InstanceGroup gD0 = new TestInstanceGroup(CrawlerTypes.TYPE_D, "new-group-TestGroup1-XXXXXXXXX", "reg1", "3:i-123456789012345678", "3:i-123456789012345679");
            return Arrays.asList(gA0, gA1, gB2, gB3, gC1, gC2, gD0);
        }

        @Override
        public List<InstanceGroup> groups(String... names) {
            Map<String, InstanceGroup> nameToGroup = new HashMap<String, InstanceGroup>();
            for (InstanceGroup ig : groups()) {
                nameToGroup.put(ig.name(), ig);
            }
            List<InstanceGroup> list = new LinkedList<InstanceGroup>();
            for (String name : names) {
                InstanceGroup ig = nameToGroup.get(name);
                if (ig == null) {
                    continue;
                }
                for (String instanceId : selected) {
                    // Remove selected instances from crawler list
                    TestInstanceGroup testIg = (TestInstanceGroup) ig;
                    testIg.deleteInstance(instanceId);
                }
                list.add(ig);
            }
            return list;
        }
    };
}
Also used : InstanceGroup(com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup)

Example 22 with InstanceGroup

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

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

the class TestBasicChaosMonkey method testAll.

@Test
public void testAll() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("all.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(), 4);
    Assert.assertEquals(terminated.get(0), "0:i-123456789012345670");
    Assert.assertEquals(terminated.get(1), "1:i-123456789012345671");
    Assert.assertEquals(terminated.get(2), "2:i-123456789012345672");
    Assert.assertEquals(terminated.get(3), "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 24 with InstanceGroup

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

the class TestBasicChaosMonkey method testNoProbability.

@Test
public void testNoProbability() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("noProbability.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 25 with InstanceGroup

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

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