Search in sources :

Example 26 with CLIOpResult

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

the class RolloutPlanTestCase method before.

@BeforeClass
public static void before() throws Exception {
    CLITestSuite.createSupport(RolloutPlanTestCase.class.getSimpleName());
    final WebArchive war = ShrinkWrap.create(WebArchive.class, "RolloutPlanTestCase.war");
    war.addClass(RolloutPlanTestServlet.class);
    war.addAsManifestResource(createPermissionsXmlAsset(// main-one
    new SocketPermission(TestSuiteEnvironment.formatPossibleIpv6Address(CLITestSuite.hostAddresses.get("master")) + ":" + TEST_PORT, "listen,resolve"), // main-three
    new SocketPermission(TestSuiteEnvironment.formatPossibleIpv6Address(CLITestSuite.hostAddresses.get("master")) + ":" + (TEST_PORT + 350), "listen,resolve")), "permissions.xml");
    String tempDir = System.getProperty("java.io.tmpdir");
    warFile = new File(tempDir + File.separator + "RolloutPlanTestCase.war");
    new ZipExporterImpl(war).exportTo(warFile, true);
    AbstractCliTestBase.initCLI(DomainTestSupport.masterAddress);
    // add another server group to default profile
    cli.sendLine("/server-group=test-server-group:add(profile=default,socket-binding-group=standard-sockets)");
    // add a server to the group
    cli.sendLine("/host=master/server-config=test-one:add(group=test-server-group,socket-binding-port-offset=700");
    cli.sendLine("/host=master/server-config=test-one/interface=public:add(inet-address=" + CLITestSuite.hostAddresses.get("master") + ")");
    CLITestSuite.addServer("test-one", "master", "test-server-group", "default", 700, true);
    // start main-two
    cli.sendLine("/host=master/server-config=main-two:start(blocking=true)");
    CLIOpResult res = cli.readAllAsOpResult();
    Assert.assertTrue(res.isIsOutcomeSuccess());
    waitUntilState("main-two", "STARTED");
    // start test-one
    cli.sendLine("/host=master/server-config=test-one:start(blocking=true)");
    res = cli.readAllAsOpResult();
    Assert.assertTrue(res.isIsOutcomeSuccess());
    waitUntilState("test-one", "STARTED");
}
Also used : WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) SocketPermission(java.net.SocketPermission) CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult) File(java.io.File) ZipExporterImpl(org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl) BeforeClass(org.junit.BeforeClass)

Example 27 with CLIOpResult

use of org.jboss.as.test.integration.management.util.CLIOpResult 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)

Aggregations

CLIOpResult (org.jboss.as.test.integration.management.util.CLIOpResult)27 Test (org.junit.Test)13 Map (java.util.Map)6 RolloutPlanBuilder (org.jboss.as.test.integration.domain.management.util.RolloutPlanBuilder)3 CLIWrapper (org.jboss.as.test.integration.management.util.CLIWrapper)3 ModelNode (org.jboss.dmr.ModelNode)2 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)2 File (java.io.File)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 SocketPermission (java.net.SocketPermission)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 StandardCharsets (java.nio.charset.StandardCharsets)1 AllPermission (java.security.AllPermission)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1