Search in sources :

Example 6 with MgmtOperationException

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

the class CredentialReferenceDatasourceTestCase method removeXADatasourceSilently.

private void removeXADatasourceSilently(final Scenario scenario) throws IOException {
    final ModelNode removeOperation = Operations.createRemoveOperation(scenario.getXADatasourceAddress().toModelNode());
    removeOperation.get(ModelDescriptionConstants.OPERATION_HEADERS).get("allow-resource-service-restart").set(true);
    try {
        execute(removeOperation);
    } catch (MgmtOperationException moe) {
    // ignore
    }
}
Also used : ModelNode(org.jboss.dmr.ModelNode) MgmtOperationException(org.jboss.as.test.integration.management.util.MgmtOperationException)

Example 7 with MgmtOperationException

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

the class DomainHostExcludesTest method awaitServerLaunch.

private void awaitServerLaunch(ModelControllerClient client, PathAddress serverAddr) throws InterruptedException {
    long timeout = TimeoutUtil.adjust(20000);
    long expired = System.currentTimeMillis() + timeout;
    ModelNode op = Util.getReadAttributeOperation(serverAddr, "server-state");
    do {
        try {
            ModelNode state = DomainTestUtils.executeForResult(op, client);
            if ("running".equalsIgnoreCase(state.asString())) {
                return;
            }
        } catch (IOException | MgmtOperationException e) {
        // ignore and try again
        }
        TimeUnit.MILLISECONDS.sleep(250L);
    } while (System.currentTimeMillis() < expired);
    Assert.fail("Server did not start in " + timeout + " ms");
}
Also used : IOException(java.io.IOException) ModelNode(org.jboss.dmr.ModelNode) MgmtOperationException(org.jboss.as.test.integration.management.util.MgmtOperationException)

Example 8 with MgmtOperationException

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

the class AbstractModuleDeploymentTestCaseSetup method remove.

protected void remove(final ModelNode address, final ManagementClient managementClient) throws IOException, MgmtOperationException {
    final ModelNode operation = new ModelNode();
    operation.get(OP).set("remove");
    operation.get(OP_ADDR).set(address);
    final ModelNode result = managementClient.getControllerClient().execute(operation);
    if (!SUCCESS.equals(result.get(OUTCOME).asString())) {
        throw new MgmtOperationException("Module removal failed: " + result.get(FAILURE_DESCRIPTION), operation, result);
    }
    final ModelNode responseHeaders = result.get(RESPONSE_HEADERS);
    if (responseHeaders.hasDefined(PROCESS_STATE) && ControlledProcessState.State.RELOAD_REQUIRED.toString().equals(responseHeaders.get(PROCESS_STATE).asString())) {
        this.reloadRequired = true;
    }
}
Also used : ModelNode(org.jboss.dmr.ModelNode) MgmtOperationException(org.jboss.as.test.integration.management.util.MgmtOperationException)

Example 9 with MgmtOperationException

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

the class MixedDomainTestSupport method startSlaveServer.

private void startSlaveServer() {
    DomainClient client = getDomainMasterLifecycleUtil().getDomainClient();
    PathElement hostElement = PathElement.pathElement("host", "slave");
    try {
        PathAddress pa = PathAddress.pathAddress(hostElement, PathElement.pathElement("server-config", "server-one"));
        DomainTestUtils.executeForResult(Util.getUndefineAttributeOperation(pa, "auto-start"), client);
        DomainTestUtils.executeForResult(Util.createEmptyOperation("start", pa), client);
    } catch (IOException | MgmtOperationException e) {
        throw new RuntimeException(e);
    }
    long timeout = TimeoutUtil.adjust(20000);
    long expired = System.currentTimeMillis() + timeout;
    ModelNode op = Util.getReadAttributeOperation(PathAddress.pathAddress(hostElement, PathElement.pathElement("server", "server-one")), "server-state");
    do {
        try {
            ModelNode state = DomainTestUtils.executeForResult(op, client);
            if ("running".equalsIgnoreCase(state.asString())) {
                return;
            }
        } catch (IOException | MgmtOperationException e) {
        // ignore and try again
        }
        try {
            TimeUnit.MILLISECONDS.sleep(250L);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            Assert.fail();
        }
    } while (System.currentTimeMillis() < expired);
    Assert.fail("Slave server-one did not start within " + timeout + " ms");
}
Also used : DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient) PathElement(org.jboss.as.controller.PathElement) PathAddress(org.jboss.as.controller.PathAddress) IOException(java.io.IOException) ModelNode(org.jboss.dmr.ModelNode) MgmtOperationException(org.jboss.as.test.integration.management.util.MgmtOperationException)

Example 10 with MgmtOperationException

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

the class LegacyConfigTest method cleanTestServer.

private void cleanTestServer(ModelControllerClient client) {
    try {
        ModelNode op = Util.createEmptyOperation("stop", TEST_SERVER_CONFIG);
        op.get("blocking").set(true);
        DomainTestUtils.executeForResult(op, client);
    } catch (MgmtOperationException | IOException e) {
        e.printStackTrace();
    } finally {
        try {
            DomainTestUtils.executeForResult(Util.createRemoveOperation(TEST_SERVER_CONFIG), client);
        } catch (MgmtOperationException | IOException e) {
            e.printStackTrace();
        } finally {
            try {
                DomainTestUtils.executeForResult(Util.createRemoveOperation(TEST_SERVER_GROUP), client);
            } catch (MgmtOperationException | IOException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : IOException(java.io.IOException) ModelNode(org.jboss.dmr.ModelNode) MgmtOperationException(org.jboss.as.test.integration.management.util.MgmtOperationException)

Aggregations

MgmtOperationException (org.jboss.as.test.integration.management.util.MgmtOperationException)11 ModelNode (org.jboss.dmr.ModelNode)11 IOException (java.io.IOException)4 Test (org.junit.Test)3 PathAddress (org.jboss.as.controller.PathAddress)1 PathElement (org.jboss.as.controller.PathElement)1 DomainClient (org.jboss.as.controller.client.helpers.domain.DomainClient)1 JMSOperations (org.jboss.as.test.integration.common.jms.JMSOperations)1