Package com.netflix.simianarmy.chaos

Examples of com.netflix.simianarmy.chaos.TestChaosMonkeyContext$MockSshClient


        MockitoAnnotations.initMocks(this);
    }

    @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);
    }
View Full Code Here


        Assert.assertEquals(ctx.terminated().size(), 3);
    }

    @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);
    }
View Full Code Here

    public static final long EXPECTED_MILLISECONDS = 2000;

    @Test
    public void testIsGroupEnabled() {
        TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("cloudformation.properties");
        CloudFormationChaosMonkey chaos = new CloudFormationChaosMonkey(ctx);
        InstanceGroup group1 = new BasicInstanceGroup("new-group-TestGroup1-XCFNFNFNF",
                TestChaosMonkeyContext.CrawlerTypes.TYPE_D, "region");
        InstanceGroup group2 = new BasicInstanceGroup("new-group-TestGroup2-XCFNGHFNF",
                TestChaosMonkeyContext.CrawlerTypes.TYPE_D, "region");
View Full Code Here

        assertFalse(chaos.isGroupEnabled(group2));
    }

    @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");
        assertFalse(chaos.isMaxTerminationCountExceeded(group1));
    }
View Full Code Here

        assertFalse(chaos.isMaxTerminationCountExceeded(group1));
    }

    @Test
    public void testGetEffectiveProbability() {
        TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("cloudformation.properties");
        CloudFormationChaosMonkey chaos = new CloudFormationChaosMonkey(ctx);
        InstanceGroup group1 = new BasicInstanceGroup("new-group-TestGroup1-XCFNFNFNF",
                TestChaosMonkeyContext.CrawlerTypes.TYPE_D, "region");
        assertEquals(1.0, chaos.getEffectiveProbability(group1));
    }
View Full Code Here

        assertEquals(1.0, chaos.getEffectiveProbability(group1));
    }

    @Test
    public void testNoSuffixInstanceGroup() {
        TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("disabled.properties");
        CloudFormationChaosMonkey chaos = new CloudFormationChaosMonkey(ctx);
        InstanceGroup group = new BasicInstanceGroup("new-group-TestGroup-XCFNFNFNF",
                TestChaosMonkeyContext.CrawlerTypes.TYPE_D, "region");
        InstanceGroup newGroup = chaos.noSuffixInstanceGroup(group);
        assertEquals(newGroup.name(), "new-group-TestGroup");
View Full Code Here

        assertEquals(newGroup.name(), "new-group-TestGroup");
    }

    @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");
        assertEquals(chaos.getLastOptInMilliseconds(group), EXPECTED_MILLISECONDS);
    }
View Full Code Here

        assertEquals(chaos.getLastOptInMilliseconds(group), EXPECTED_MILLISECONDS);
    }

    @Test
    public void testCloudFormationChaosMonkeyIntegration() {
        TestChaosMonkeyContext ctx = new TestChaosMonkeyContext("cloudformation.properties");
        CloudFormationChaosMonkey chaos = new CloudFormationChaosMonkey(ctx);
        chaos.start();
        chaos.stop();
        Assert.assertEquals(ctx.selectedOn().size(), 1);
        Assert.assertEquals(ctx.terminated().size(), 1);
        Assert.assertEquals(ctx.getNotified(), 1);
    }
View Full Code Here

        Assert.assertEquals(ctx.terminated().size(), 0);
    }

    @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);
View Full Code Here

        validateAddEventResult(resource, input, Response.Status.BAD_REQUEST);
    }

    @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);
View Full Code Here

TOP

Related Classes of com.netflix.simianarmy.chaos.TestChaosMonkeyContext$MockSshClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.