Search in sources :

Example 16 with CLIOpResult

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

Example 17 with CLIOpResult

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

the class ReloadableCliTestBase method doCliOperationWithoutChecks.

protected void doCliOperationWithoutChecks(final String operation) throws Exception {
    LOGGER.debugv("Performing CLI operation without checks: {0}", operation);
    initCLI();
    cli.sendLine(operation, true);
    final CLIOpResult result = cli.readAllAsOpResult();
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debugv("Operation result is: {0}", result.getResponseNode());
    }
}
Also used : CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult)

Example 18 with CLIOpResult

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

the class RemoveDeploymentPermissionsServerSetupTask method tearDown.

/*
     * (non-Javadoc)
     *
     * @see org.jboss.as.arquillian.api.ServerSetupTask#tearDown(org.jboss.as.arquillian.container.ManagementClient,
     * java.lang.String)
     */
@Override
public void tearDown(final ManagementClient managementClient, String containerId) throws Exception {
    CLIOpResult result = null;
    // remove the deployment permissions configuration if exists
    cli.sendLine("/subsystem=security-manager/deployment-permissions=default:remove()", true);
    result = cli.readAllAsOpResult();
    LOGGER.debug("Just in case. We tried to remove deployment-permissions before adding it. Result of the delete: " + result.getFromResponse(ModelDescriptionConstants.OUTCOME));
    // revert original deployment permissions
    cli.sendLine("/subsystem=security-manager/deployment-permissions=default:add(maximum-permissions=[{class=java.security.AllPermission}])");
    result = cli.readAllAsOpResult();
    assertTrue("Reverting maximum-permissions by using management API failed", result.isIsOutcomeSuccess());
    // reload the server
    LOGGER.debug("Reloading the server");
    reload(managementClient);
}
Also used : CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult)

Example 19 with CLIOpResult

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

the class DeploymentScannerTestCase method removeDeploymentScanner.

private void removeDeploymentScanner() throws Exception {
    // remove deployment scanner
    cli.sendLine("/subsystem=deployment-scanner/scanner=testScanner:remove()");
    CLIOpResult result = cli.readAllAsOpResult();
    assertTrue(result.isIsOutcomeSuccess());
    // delete deployment
    assertTrue("Could not delete deployed file.", warFile.delete());
    // wait for deployment
    Thread.sleep(2000);
    // check that the deployment is still live
    String response = HttpRequest.get(getBaseURL(url) + "SimpleServlet/SimpleServlet", 10, TimeUnit.SECONDS);
    assertTrue("Invalid response: " + response, response.indexOf("SimpleServlet") >= 0);
    // undeploy using CLI
    cli.sendLine("undeploy SimpleServlet.war");
    assertTrue(checkUndeployed(getBaseURL(url) + "SimpleServlet/SimpleServlet"));
}
Also used : CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult)

Example 20 with CLIOpResult

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

the class WildCardReadsTestCase method testReadResourceDescriptionNoGenericRegistration.

/**
     * Tests WFLY-2527 fix.
     */
@Test
public void testReadResourceDescriptionNoGenericRegistration() throws IOException {
    cli.sendLine(String.format(OP_PATTERN, EVICTION, READ_RES_DESC_OP));
    CLIOpResult opResult = cli.readAllAsOpResult();
    Assert.assertTrue(opResult.isIsOutcomeSuccess());
    ModelNode specific = opResult.getResponseNode().get(ModelDescriptionConstants.RESULT);
    cli.sendLine(String.format(OP_PATTERN, "*", READ_RES_DESC_OP));
    opResult = cli.readAllAsOpResult();
    Assert.assertTrue(opResult.isIsOutcomeSuccess());
    ModelNode generic = opResult.getResponseNode().get(ModelDescriptionConstants.RESULT);
    Assert.assertEquals(ModelType.LIST, generic.getType());
    Assert.assertEquals(1, generic.asInt());
    Assert.assertEquals(specific, generic.get(0).get(ModelDescriptionConstants.RESULT));
}
Also used : CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult) ModelNode(org.jboss.dmr.ModelNode) 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