Search in sources :

Example 1 with BasicChaosMonkey

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

the class TestChaosMonkeyArmy method runChaosMonkey.

private TestChaosMonkeyContext runChaosMonkey(String key, boolean burnMoney) {
    Properties properties = new Properties();
    properties.setProperty("simianarmy.chaos.enabled", "true");
    properties.setProperty("simianarmy.chaos.leashed", "false");
    properties.setProperty("simianarmy.chaos.TYPE_A.enabled", "true");
    properties.setProperty("simianarmy.chaos.notification.global.enabled", "true");
    properties.setProperty("simianarmy.chaos.burnmoney", Boolean.toString(burnMoney));
    properties.setProperty("simianarmy.chaos.shutdowninstance.enabled", "false");
    properties.setProperty("simianarmy.chaos." + key.toLowerCase() + ".enabled", "true");
    properties.setProperty("simianarmy.chaos.ssh.key", sshKey.getAbsolutePath());
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext(properties);
    ChaosMonkey chaos = new BasicChaosMonkey(ctx);
    chaos.start();
    chaos.stop();
    return ctx;
}
Also used : BasicChaosMonkey(com.netflix.simianarmy.basic.chaos.BasicChaosMonkey) BasicChaosMonkey(com.netflix.simianarmy.basic.chaos.BasicChaosMonkey) Properties(java.util.Properties)

Example 2 with BasicChaosMonkey

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

the class TestChaosMonkeyResource method testTerminateNowBadEventType.

@Test
void testTerminateNowBadEventType() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("ondemandTermination.properties");
    String input = "{\"eventType\":\"INVALID\",\"groupType\":\"TYPE_C\",\"groupName\":\"name4\"}";
    ChaosMonkeyResource resource = new ChaosMonkeyResource(new BasicChaosMonkey(ctx));
    validateAddEventResult(resource, input, Response.Status.BAD_REQUEST);
}
Also used : BasicChaosMonkey(com.netflix.simianarmy.basic.chaos.BasicChaosMonkey) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 3 with BasicChaosMonkey

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

the class TestChaosMonkeyResource method testTerminateNowBadInput.

@Test
void testTerminateNowBadInput() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("ondemandTermination.properties");
    String input = "{\"groupType\":\"TYPE_C\",\"groupName\":\"name4\"}";
    ChaosMonkeyResource resource = new ChaosMonkeyResource(new BasicChaosMonkey(ctx));
    validateAddEventResult(resource, input, Response.Status.BAD_REQUEST);
    input = "{\"eventType\":\"CHAOS_TERMINATION\",\"groupName\":\"name4\"}";
    resource = new ChaosMonkeyResource(new BasicChaosMonkey(ctx));
    validateAddEventResult(resource, input, Response.Status.BAD_REQUEST);
    input = "{\"eventType\":\"CHAOS_TERMINATION\",\"groupType\":\"TYPE_C\"}";
    resource = new ChaosMonkeyResource(new BasicChaosMonkey(ctx));
    validateAddEventResult(resource, input, Response.Status.BAD_REQUEST);
}
Also used : BasicChaosMonkey(com.netflix.simianarmy.basic.chaos.BasicChaosMonkey) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 4 with BasicChaosMonkey

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

the class TestChaosMonkeyResource method testTerminateNow.

@Test
void testTerminateNow() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("ondemandTermination.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.OK);
    Assert.assertEquals(ctx.selectedOn().size(), 1);
    Assert.assertEquals(ctx.terminated().size(), 1);
    validateAddEventResult(resource, input, Response.Status.OK);
    Assert.assertEquals(ctx.selectedOn().size(), 2);
    Assert.assertEquals(ctx.terminated().size(), 2);
    // TYPE_C.name4 only has two instances, so the 3rd ondemand termination
    // will not terminate anything.
    validateAddEventResult(resource, input, Response.Status.GONE);
    Assert.assertEquals(ctx.selectedOn().size(), 3);
    Assert.assertEquals(ctx.terminated().size(), 2);
    // Try a different type will work
    input = "{\"eventType\":\"CHAOS_TERMINATION\",\"groupType\":\"TYPE_C\",\"groupName\":\"name5\"}";
    validateAddEventResult(resource, input, Response.Status.OK);
    Assert.assertEquals(ctx.selectedOn().size(), 4);
    Assert.assertEquals(ctx.terminated().size(), 3);
}
Also used : BasicChaosMonkey(com.netflix.simianarmy.basic.chaos.BasicChaosMonkey) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 5 with BasicChaosMonkey

use of com.netflix.simianarmy.basic.chaos.BasicChaosMonkey 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);
}
Also used : BasicChaosMonkey(com.netflix.simianarmy.basic.chaos.BasicChaosMonkey) TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

BasicChaosMonkey (com.netflix.simianarmy.basic.chaos.BasicChaosMonkey)6 TestChaosMonkeyContext (com.netflix.simianarmy.chaos.TestChaosMonkeyContext)5 BeforeTest (org.testng.annotations.BeforeTest)5 Test (org.testng.annotations.Test)5 Properties (java.util.Properties)1