Search in sources :

Example 11 with TestChaosMonkeyContext

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

the class TestBasicChaosMonkey method testMandatoryTerminationNoOptInTime.

@Test
public void testMandatoryTerminationNoOptInTime() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("mandatoryTerminationNoOptInTime.properties");
    ChaosMonkey chaos = new BasicChaosMonkey(ctx);
    chaos.start();
    chaos.stop();
    Assert.assertEquals(ctx.selectedOn().size(), 1);
    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)

Example 12 with TestChaosMonkeyContext

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

the class TestBasicChaosMonkey method testMaxTerminationCountPerDayAsSmallerThanOne.

@Test
public void testMaxTerminationCountPerDayAsSmallerThanOne() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("terminationPerDayAsSmallerThanOne.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 NOT trigger another termination
    chaos.start();
    chaos.stop();
    Assert.assertEquals(ctx.selectedOn().size(), 1);
    Assert.assertEquals(ctx.terminated().size(), 1);
}
Also used : ChaosMonkey(com.netflix.simianarmy.chaos.ChaosMonkey) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) Test(org.testng.annotations.Test)

Example 13 with TestChaosMonkeyContext

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

Example 14 with TestChaosMonkeyContext

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

the class TestBasicChaosMonkey method testMandatoryTerminationInsideWindow.

@Test
public void testMandatoryTerminationInsideWindow() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("mandatoryTerminationInsideWindow.properties");
    ChaosMonkey chaos = new BasicChaosMonkey(ctx);
    chaos.start();
    chaos.stop();
    // The last opt-in time is within the window, so no mandatory termination is triggered
    Assert.assertEquals(ctx.selectedOn().size(), 1);
    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)

Example 15 with TestChaosMonkeyContext

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

the class TestCloudFormationChaosMonkey method testIsMaxTerminationCountExceeded.

@Test
public void testIsMaxTerminationCountExceeded() {
    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());
    assertFalse(chaos.isMaxTerminationCountExceeded(group1));
}
Also used : 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