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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations