use of com.netflix.simianarmy.chaos.TestChaosMonkeyContext 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);
}
use of com.netflix.simianarmy.chaos.TestChaosMonkeyContext in project SimianArmy by Netflix.
the class TestBasicChaosMonkey method testMandatoryTerminationInsideWindowWithPreviousTermination.
@Test
public void testMandatoryTerminationInsideWindowWithPreviousTermination() {
TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("mandatoryTerminationInsideWindow.properties");
terminateOnDemand(ctx, "TYPE_C", "name4");
Assert.assertEquals(ctx.selectedOn().size(), 1);
Assert.assertEquals(ctx.terminated().size(), 1);
ChaosMonkey chaos = new BasicChaosMonkey(ctx);
chaos.start();
chaos.stop();
// There was termination in the last window, so no mandatory termination is triggered
Assert.assertEquals(ctx.selectedOn().size(), 2);
Assert.assertEquals(ctx.terminated().size(), 1);
}
use of com.netflix.simianarmy.chaos.TestChaosMonkeyContext in project SimianArmy by Netflix.
the class TestBasicChaosMonkey method testMandatoryTerminationOutsideWindowWithPreviousTermination.
@Test
public void testMandatoryTerminationOutsideWindowWithPreviousTermination() {
TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("mandatoryTerminationOutsideWindow.properties");
terminateOnDemand(ctx, "TYPE_C", "name4");
Assert.assertEquals(ctx.selectedOn().size(), 1);
Assert.assertEquals(ctx.terminated().size(), 1);
ChaosMonkey chaos = new BasicChaosMonkey(ctx);
chaos.start();
chaos.stop();
// There was termination in the last window, so no mandatory termination is triggered
Assert.assertEquals(ctx.selectedOn().size(), 2);
Assert.assertEquals(ctx.terminated().size(), 1);
}
use of com.netflix.simianarmy.chaos.TestChaosMonkeyContext in project SimianArmy by Netflix.
the class TestChaosMonkeyResource method testTerminateNowDisabled.
@Test
void testTerminateNowDisabled() {
TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("ondemandTerminationDisabled.properties");
String input = "{\"eventType\":\"CHAOS_TERMINATION\",\"groupType\":\"TYPE_C\",\"groupName\":\"name4\"}";
Assert.assertEquals(ctx.selectedOn().size(), 0);
Assert.assertEquals(ctx.terminated().size(), 0);
ChaosMonkeyResource resource = new ChaosMonkeyResource(new BasicChaosMonkey(ctx));
validateAddEventResult(resource, input, Response.Status.FORBIDDEN);
Assert.assertEquals(ctx.selectedOn().size(), 0);
Assert.assertEquals(ctx.terminated().size(), 0);
}
use of com.netflix.simianarmy.chaos.TestChaosMonkeyContext in project SimianArmy by Netflix.
the class TestChaosMonkeyResource method testTerminateNowBadGroupNotExist.
@Test
void testTerminateNowBadGroupNotExist() {
TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("ondemandTermination.properties");
String input = "{\"eventType\":\"CHAOS_TERMINATION\",\"groupType\":\"INVALID\",\"groupName\":\"name4\"}";
ChaosMonkeyResource resource = new ChaosMonkeyResource(new BasicChaosMonkey(ctx));
validateAddEventResult(resource, input, Response.Status.NOT_FOUND);
input = "{\"eventType\":\"CHAOS_TERMINATION\",\"groupType\":\"TYPE_C\",\"groupName\":\"INVALID\"}";
resource = new ChaosMonkeyResource(new BasicChaosMonkey(ctx));
validateAddEventResult(resource, input, Response.Status.NOT_FOUND);
}
Aggregations