Search in sources :

Example 1 with RolloutPlanBuilder

use of org.jboss.as.test.integration.domain.management.util.RolloutPlanBuilder in project wildfly by wildfly.

the class RolloutPlanTestCase method testMaxFailServersRolloutPlan.

/**
     * Tests rollout plan with non-zero maxFailedServers attribute.
     */
@Test
public void testMaxFailServersRolloutPlan() throws Exception {
    // deploy helper servlets
    cli.sendLine("deploy " + warFile.getAbsolutePath() + " --all-server-groups");
    checkURL("main-one", false, "/RolloutPlanTestCase/RolloutServlet");
    checkURL("main-two", false, "/RolloutPlanTestCase/RolloutServlet");
    checkURL("main-three", false, "/RolloutPlanTestCase/RolloutServlet");
    checkURL("test-one", false, "/RolloutPlanTestCase/RolloutServlet");
    // prepare socket binding
    cli.sendLine("/socket-binding-group=standard-sockets/socket-binding=test-binding:add(interface=public,port=" + TEST_PORT + ")");
    // create plan with max fail server set to 1
    RolloutPlanBuilder planBuilder = new RolloutPlanBuilder();
    planBuilder.addGroup(serverGroups[0], new RolloutPlanBuilder.RolloutPolicy(true, null, 1));
    planBuilder.addGroup(serverGroups[1], new RolloutPlanBuilder.RolloutPolicy(true, null, 1));
    planBuilder.addGroup(serverGroups[2], new RolloutPlanBuilder.RolloutPolicy(true, null, 1));
    String rolloutPlan = planBuilder.buildAsString();
    cli.sendLine("rollout-plan add --name=maxFailOnePlan --content=" + rolloutPlan);
    // 1st scenario - main-one should fail, but the whole operation should succeed
    // let the helper server bind to test port to prevent successful subsequent add connector operation on main-one
    checkURL("main-one", false, "/RolloutPlanTestCase/RolloutServlet?operation=bind&bindPort=" + TEST_PORT);
    CLIOpResult ret = testAddConnector("maxFailOnePlan");
    Assert.assertTrue(ret.isIsOutcomeSuccess());
    Assert.assertFalse(getServerStatus("main-one", ret));
    Assert.assertTrue(getServerStatus("main-two", ret));
    Assert.assertTrue(getServerStatus("main-three", ret));
    Assert.assertTrue(getServerStatus("test-one", ret));
    ret = testRemoveConnector("maxFailOnePlan");
    Assert.assertTrue(ret.isIsOutcomeSuccess());
    Assert.assertFalse(getServerStatus("main-one", ret));
    Assert.assertTrue(getServerStatus("main-two", ret));
    Assert.assertTrue(getServerStatus("main-three", ret));
    Assert.assertTrue(getServerStatus("test-one", ret));
    // 2nd scenario - main-one and main-three failures -> main-two should be rolled back but the operation succeed
    checkURL("main-three", false, "/RolloutPlanTestCase/RolloutServlet?operation=bind&bindPort=" + String.valueOf(TEST_PORT + CLITestSuite.portOffsets.get("main-three")));
    ret = testAddConnector("maxFailOnePlan");
    Assert.assertTrue(ret.isIsOutcomeSuccess());
    Assert.assertFalse(getServerStatus("main-one", ret));
    Assert.assertFalse(getServerStatus("main-two", ret));
    Assert.assertFalse(getServerStatus("main-three", ret));
    Assert.assertTrue(getServerStatus("test-one", ret));
    testCleanupConnector("maxFailOnePlan");
    // remove rollout plan
    cli.sendLine("rollout-plan remove --name=maxFailOnePlan");
}
Also used : RolloutPlanBuilder(org.jboss.as.test.integration.domain.management.util.RolloutPlanBuilder) CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult) Test(org.junit.Test)

Example 2 with RolloutPlanBuilder

use of org.jboss.as.test.integration.domain.management.util.RolloutPlanBuilder in project wildfly by wildfly.

the class RolloutPlanTestCase method testRollbackAcrossGroupsRolloutPlan.

/**
     * Tests rollout plan with RollbackAcrossGroups set to true.
     */
@Test
public void testRollbackAcrossGroupsRolloutPlan() throws Exception {
    // deploy helper servlets
    cli.sendLine("deploy " + warFile.getAbsolutePath() + " --all-server-groups");
    checkURL("main-one", false, "/RolloutPlanTestCase/RolloutServlet");
    checkURL("main-two", false, "/RolloutPlanTestCase/RolloutServlet");
    checkURL("main-three", false, "/RolloutPlanTestCase/RolloutServlet");
    checkURL("test-one", false, "/RolloutPlanTestCase/RolloutServlet");
    // prepare socket binding
    cli.sendLine("/socket-binding-group=standard-sockets/socket-binding=test-binding:add(interface=public,port=" + TEST_PORT + ")");
    // create plan with max fail server set to 1
    RolloutPlanBuilder planBuilder = new RolloutPlanBuilder();
    planBuilder.addGroup(serverGroups[0], new RolloutPlanBuilder.RolloutPolicy(true, null, 1));
    planBuilder.addGroup(serverGroups[1], new RolloutPlanBuilder.RolloutPolicy(true, null, 1));
    planBuilder.addGroup(serverGroups[2], new RolloutPlanBuilder.RolloutPolicy(true, null, 1));
    planBuilder.setRollBackAcrossGroups(true);
    String rolloutPlan = planBuilder.buildAsString();
    cli.sendLine("rollout-plan add --name=groupsRollbackPlan --content=" + rolloutPlan);
    // let the main-one ane main-three fail, main two rollback and then test-one rollback
    // let the helper server bind to test port to prevent successful subsequent add connector operation on main-one
    checkURL("main-one", false, "/RolloutPlanTestCase/RolloutServlet?operation=bind&bindPort=" + TEST_PORT);
    checkURL("main-three", false, "/RolloutPlanTestCase/RolloutServlet?operation=bind&bindPort=" + String.valueOf(TEST_PORT + CLITestSuite.portOffsets.get("main-three")));
    CLIOpResult ret = testAddConnector("groupsRollbackPlan");
    Assert.assertFalse(ret.isIsOutcomeSuccess());
    Assert.assertFalse(getServerStatus("main-one", ret));
    Assert.assertFalse(getServerStatus("main-two", ret));
    Assert.assertFalse(getServerStatus("main-three", ret));
    Assert.assertFalse(getServerStatus("test-one", ret));
    // remove rollout plan
    cli.sendLine("rollout-plan remove --name=groupsRollbackPlan");
}
Also used : RolloutPlanBuilder(org.jboss.as.test.integration.domain.management.util.RolloutPlanBuilder) CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult) Test(org.junit.Test)

Example 3 with RolloutPlanBuilder

use of org.jboss.as.test.integration.domain.management.util.RolloutPlanBuilder in project wildfly by wildfly.

the class RolloutPlanTestCase method testInSeriesRolloutPlan.

@Test
public void testInSeriesRolloutPlan() throws Exception {
    // create rollout plans
    // 1st plan
    RolloutPlanBuilder planBuilder = new RolloutPlanBuilder();
    planBuilder.addGroup(serverGroups[0], new RolloutPlanBuilder.RolloutPolicy(true, null, null));
    planBuilder.addGroup(serverGroups[1], new RolloutPlanBuilder.RolloutPolicy(true, null, null));
    planBuilder.addGroup(serverGroups[2], new RolloutPlanBuilder.RolloutPolicy(true, null, null));
    String rolloutPlan = planBuilder.buildAsString();
    cli.sendLine("rollout-plan add --name=testPlan --content=" + rolloutPlan);
    // 2nd with reversed order
    planBuilder = new RolloutPlanBuilder();
    planBuilder.addGroup(serverGroups[2], new RolloutPlanBuilder.RolloutPolicy(true, null, null));
    planBuilder.addGroup(serverGroups[1], new RolloutPlanBuilder.RolloutPolicy(true, null, null));
    planBuilder.addGroup(serverGroups[0], new RolloutPlanBuilder.RolloutPolicy(true, null, null));
    rolloutPlan = planBuilder.buildAsString();
    cli.sendLine("rollout-plan add --name=testPlan2 --content=" + rolloutPlan);
    // check they are listed
    cli.sendLine("cd /management-client-content=rollout-plans/rollout-plan");
    cli.sendLine("ls");
    String ls = cli.readOutput();
    Assert.assertTrue(ls.contains("testPlan"));
    Assert.assertTrue(ls.contains("testPlan2"));
    // deploy using 1st prepared rollout plan
    cli.sendLine("deploy " + warFile.getAbsolutePath() + " --all-server-groups --headers={rollout id=testPlan}");
    // check that the apps were deployed in correct order
    // get application deployment times from servers
    long mainOneTime = Long.valueOf(checkURL("main-one", false));
    long mainTwoTime = Long.valueOf(checkURL("main-two", false));
    long mainThreeTime = Long.valueOf(checkURL("main-three", false));
    long otherTwoTime = Long.valueOf(checkURL("other-two", false));
    long testOneTime = Long.valueOf(checkURL("test-one", false));
    Assert.assertTrue(mainOneTime < otherTwoTime);
    Assert.assertTrue(mainTwoTime < otherTwoTime);
    Assert.assertTrue(mainThreeTime < otherTwoTime);
    Assert.assertTrue(otherTwoTime < testOneTime);
    // undeploy apps
    cli.sendLine("undeploy RolloutPlanTestCase.war --all-relevant-server-groups");
    // deploy using 2nd plan
    cli.sendLine("deploy " + warFile.getAbsolutePath() + " --all-server-groups --headers={rollout id=testPlan2}");
    // check that the apps were deployed in reversed order
    mainOneTime = Long.valueOf(checkURL("main-one", false));
    mainTwoTime = Long.valueOf(checkURL("main-two", false));
    mainThreeTime = Long.valueOf(checkURL("main-three", false));
    otherTwoTime = Long.valueOf(checkURL("other-two", false));
    testOneTime = Long.valueOf(checkURL("test-one", false));
    Assert.assertTrue(mainOneTime > otherTwoTime);
    Assert.assertTrue(mainTwoTime > otherTwoTime);
    Assert.assertTrue(mainThreeTime > otherTwoTime);
    Assert.assertTrue(otherTwoTime > testOneTime);
    // remove rollout plans
    cli.sendLine("rollout-plan remove --name=testPlan");
    cli.sendLine("rollout-plan remove --name=testPlan2");
    // check plans are no more listed
    cli.sendLine("cd /management-client-content=rollout-plans");
    cli.sendLine("ls");
    ls = cli.readOutput();
    Assert.assertFalse(ls.contains("testPlan"));
    Assert.assertFalse(ls.contains("testPlan2"));
}
Also used : RolloutPlanBuilder(org.jboss.as.test.integration.domain.management.util.RolloutPlanBuilder) Test(org.junit.Test)

Example 4 with RolloutPlanBuilder

use of org.jboss.as.test.integration.domain.management.util.RolloutPlanBuilder in project wildfly by wildfly.

the class RolloutPlanTestCase method testMaxFailServersPercentageRolloutPlan.

/**
     * Tests rollout plan with non-zero maxFailurePercentage attribute.
     */
@Test
public void testMaxFailServersPercentageRolloutPlan() throws Exception {
    // deploy helper servlets
    cli.sendLine("deploy " + warFile.getAbsolutePath() + " --all-server-groups");
    // prepare socket binding
    cli.sendLine("/socket-binding-group=standard-sockets/socket-binding=test-binding:add(interface=public,port=" + TEST_PORT + ")");
    // create plan with max fail server percentage set to 40%
    RolloutPlanBuilder planBuilder = new RolloutPlanBuilder();
    planBuilder.addGroup(serverGroups[0], new RolloutPlanBuilder.RolloutPolicy(true, 40, 0));
    planBuilder.addGroup(serverGroups[1], new RolloutPlanBuilder.RolloutPolicy(true, 40, 0));
    planBuilder.addGroup(serverGroups[2], new RolloutPlanBuilder.RolloutPolicy(true, 40, 0));
    String rolloutPlan = planBuilder.buildAsString();
    cli.sendLine("rollout-plan add --name=maxFailPercPlan --content=" + rolloutPlan);
    // 1st scenario - server-one should fail, but the whole operation should succeed
    checkURL("main-one", false, "/RolloutPlanTestCase/RolloutServlet?operation=bind&bindPort=" + TEST_PORT);
    CLIOpResult ret = testAddConnector("maxFailPercPlan");
    Assert.assertTrue(ret.isIsOutcomeSuccess());
    Assert.assertFalse(getServerStatus("main-one", ret));
    Assert.assertTrue(getServerStatus("main-two", ret));
    Assert.assertTrue(getServerStatus("main-three", ret));
    Assert.assertTrue(getServerStatus("test-one", ret));
    ret = testRemoveConnector("maxFailPercPlan");
    Assert.assertTrue(ret.isIsOutcomeSuccess());
    Assert.assertFalse(getServerStatus("main-one", ret));
    Assert.assertTrue(getServerStatus("main-two", ret));
    Assert.assertTrue(getServerStatus("main-three", ret));
    Assert.assertTrue(getServerStatus("test-one", ret));
    // 2nd scenario - main-one and main-three should fail -> main-two should be rolled back but the operation succeed
    checkURL("main-three", false, "/RolloutPlanTestCase/RolloutServlet?operation=bind&bindPort=" + String.valueOf(TEST_PORT + CLITestSuite.portOffsets.get("main-three")));
    ret = testAddConnector("maxFailPercPlan");
    Assert.assertTrue(ret.isIsOutcomeSuccess());
    Assert.assertFalse(getServerStatus("main-one", ret));
    Assert.assertFalse(getServerStatus("main-two", ret));
    Assert.assertFalse(getServerStatus("main-three", ret));
    Assert.assertTrue(getServerStatus("test-one", ret));
    testCleanupConnector("maxFailPercPlan");
    // remove rollout plan
    cli.sendLine("rollout-plan remove --name=maxFailPercPlan");
}
Also used : RolloutPlanBuilder(org.jboss.as.test.integration.domain.management.util.RolloutPlanBuilder) CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult) Test(org.junit.Test)

Aggregations

RolloutPlanBuilder (org.jboss.as.test.integration.domain.management.util.RolloutPlanBuilder)4 Test (org.junit.Test)4 CLIOpResult (org.jboss.as.test.integration.management.util.CLIOpResult)3