Search in sources :

Example 16 with TestChaosMonkeyContext

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

the class TestCloudFormationChaosMonkey method testGetLastOptInMilliseconds.

@Test
public void testGetLastOptInMilliseconds() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("cloudformation.properties");
    CloudFormationChaosMonkey chaos = new CloudFormationChaosMonkey(ctx);
    InstanceGroup group = new BasicInstanceGroup("new-group-TestGroup1-XCFNFNFNF", TestChaosMonkeyContext.CrawlerTypes.TYPE_D, "region", Collections.<TagDescription>emptyList());
    assertEquals(chaos.getLastOptInMilliseconds(group), EXPECTED_MILLISECONDS);
}
Also used : TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) InstanceGroup(com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup) Test(org.testng.annotations.Test)

Example 17 with TestChaosMonkeyContext

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

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

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

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

the class TestTunablyAggressiveChaosMonkey method testFullProbability_tuned.

@Test
public void testFullProbability_tuned() {
    TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("fullProbability.properties");
    TunablyAggressiveChaosMonkey chaos = new TunablyAggressiveChaosMonkey(ctx);
    TunableInstanceGroup tuned = new TunableInstanceGroup("basic", GroupTypes.TYPE_A, "region", Collections.<TagDescription>emptyList());
    tuned.setAggressionCoefficient(0.5);
    double probability = chaos.getEffectiveProbability(tuned);
    Assert.assertEquals(probability, 0.5);
}
Also used : TestChaosMonkeyContext(com.netflix.simianarmy.chaos.TestChaosMonkeyContext) 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