Search in sources :

Example 16 with DomainClient

use of org.jboss.as.controller.client.helpers.domain.DomainClient in project wildfly by wildfly.

the class SimpleMixedDomainTest method test00010_JgroupsTransformers.

@Test
public void test00010_JgroupsTransformers() throws Exception {
    final DomainClient masterClient = support.getDomainMasterLifecycleUtil().createDomainClient();
    try {
        // Check composite operation
        final ModelNode compositeOp = new ModelNode();
        compositeOp.get(OP).set(COMPOSITE);
        compositeOp.get(OP_ADDR).setEmptyList();
        compositeOp.get(STEPS).add(createProtocolPutPropertyOperation("tcp", "MPING", "send_on_all_interfaces", "true"));
        compositeOp.get(STEPS).add(createProtocolPutPropertyOperation("tcp", "MPING", "receive_on_all_interfaces", "true"));
        DomainTestUtils.executeForResult(compositeOp, masterClient);
    } finally {
        IoUtils.safeClose(masterClient);
    }
}
Also used : DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 17 with DomainClient

use of org.jboss.as.controller.client.helpers.domain.DomainClient in project wildfly by wildfly.

the class SimpleMixedDomainTest method profileCloneEap7x.

private void profileCloneEap7x() throws Exception {
    // EAP 7 allows the clone operation.
    // However EAP 7 will need to take into account the ignore-unused-configuration
    // setting which does not exist in 6.x
    final DomainClient masterClient = support.getDomainMasterLifecycleUtil().createDomainClient();
    final DomainClient slaveClient = support.getDomainSlaveLifecycleUtil().createDomainClient();
    try {
        final PathAddress newProfileAddress = PathAddress.pathAddress(PROFILE, "new-profile");
        // Create a new profile (so that we can ignore it on the host later)
        DomainTestUtils.executeForResult(Util.createAddOperation(newProfileAddress), masterClient);
        // Attempt to clone it. It should work but not exist on the slave since unused configuration is ignored
        final ModelNode clone = Util.createEmptyOperation(CLONE, newProfileAddress);
        clone.get(TO_PROFILE).set("cloned");
        DomainTestUtils.executeForResult(clone, masterClient);
        // Check the new profile does not exist on the slave
        final ModelNode readChildrenNames = Util.createEmptyOperation(READ_CHILDREN_NAMES_OPERATION, PathAddress.EMPTY_ADDRESS);
        readChildrenNames.get(CHILD_TYPE).set(PROFILE);
        ModelNode result = DomainTestUtils.executeForResult(readChildrenNames, slaveClient);
        List<ModelNode> list = result.asList();
        Assert.assertEquals(1, list.size());
        Assert.assertEquals(list.toString(), "full-ha", list.get(0).asString());
        // Update the server group to use the new profile
        DomainTestUtils.executeForResult(Util.getWriteAttributeOperation(PathAddress.pathAddress(SERVER_GROUP, "other-server-group"), PROFILE, "new-profile"), masterClient);
        // Check the profiles
        result = DomainTestUtils.executeForResult(readChildrenNames, slaveClient);
        list = result.asList();
        Assert.assertEquals(1, list.size());
        Assert.assertEquals(list.toString(), "new-profile", list.get(0).asString());
    } finally {
        IoUtils.safeClose(slaveClient);
        IoUtils.safeClose(masterClient);
    }
}
Also used : DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 18 with DomainClient

use of org.jboss.as.controller.client.helpers.domain.DomainClient in project wildfly by wildfly.

the class SimpleMixedDomainTest method test00011_ExampleDSConnection.

/**
 * Tests test-connection-in-pool() of ExampleDS.
 *
 * @throws Exception
 */
@Test
public void test00011_ExampleDSConnection() throws Exception {
    PathAddress exampleDSAddress = PathAddress.pathAddress(PathElement.pathElement(HOST, "slave"), PathElement.pathElement(RUNNING_SERVER, "server-one"), PathElement.pathElement(SUBSYSTEM, "datasources"), PathElement.pathElement("data-source", "ExampleDS"));
    DomainClient masterClient = support.getDomainMasterLifecycleUtil().createDomainClient();
    try {
        ModelNode op = Util.createOperation("test-connection-in-pool", PathAddress.pathAddress(exampleDSAddress));
        ModelNode response = masterClient.execute(op);
        assertEquals(op.toString() + '\n' + response.toString(), SUCCESS, response.get(OUTCOME).asString());
    } finally {
        IoUtils.safeClose(masterClient);
    }
}
Also used : DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 19 with DomainClient

use of org.jboss.as.controller.client.helpers.domain.DomainClient 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 20 with DomainClient

use of org.jboss.as.controller.client.helpers.domain.DomainClient in project wildfly by wildfly.

the class JVMServerPropertiesTestCase method testServerProperties.

@Test
public void testServerProperties() throws IOException, MgmtOperationException, InterruptedException, TimeoutException {
    ModelNode op = createDeploymentOperation(deploymentPath.resolve(PROP_SERVLET_APP_WAR), SERVER_GROUP_ONE, SERVER_GROUP_TWO, SERVER_GROUP_THREE);
    DomainTestUtils.executeForResult(op, masterLifecycleUtil.createDomainClient());
    validateProperties("server-one", 8080, BY_SERVER);
    validateProperties("server-two", 8180, BY_SERVER);
    validateProperties("server-three", 8280, BY_SERVER);
    op = Util.getWriteAttributeOperation(PathAddress.pathAddress(HOST_MASTER), DIRECTORY_GROUPING, BY_TYPE);
    DomainTestUtils.executeForResult(op, masterLifecycleUtil.createDomainClient());
    op = Util.createEmptyOperation(RELOAD, PathAddress.pathAddress(HOST_MASTER));
    op.get(RESTART_SERVERS).set(true);
    masterLifecycleUtil.executeAwaitConnectionClosed(op);
    masterLifecycleUtil.connect();
    masterLifecycleUtil.awaitHostController(System.currentTimeMillis());
    DomainClient masterClient = masterLifecycleUtil.createDomainClient();
    DomainTestUtils.waitUntilState(masterClient, PathAddress.pathAddress(HOST_MASTER, SERVER_CONFIG_ONE), ServerStatus.STARTED.toString());
    DomainTestUtils.waitUntilState(masterClient, PathAddress.pathAddress(HOST_MASTER, SERVER_CONFIG_TWO), ServerStatus.STARTED.toString());
    DomainTestUtils.waitUntilState(masterClient, PathAddress.pathAddress(HOST_MASTER, SERVER_CONFIG_THREE), ServerStatus.STARTED.toString());
    validateProperties("server-one", 8080, BY_TYPE);
    validateProperties("server-two", 8180, BY_TYPE);
    validateProperties("server-three", 8280, BY_TYPE);
}
Also used : DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Aggregations

DomainClient (org.jboss.as.controller.client.helpers.domain.DomainClient)24 ModelNode (org.jboss.dmr.ModelNode)17 Test (org.junit.Test)16 PathAddress (org.jboss.as.controller.PathAddress)5 File (java.io.File)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 OperationBuilder (org.jboss.as.controller.client.OperationBuilder)2 DeploymentPlan (org.jboss.as.controller.client.helpers.domain.DeploymentPlan)2 DeploymentPlanResult (org.jboss.as.controller.client.helpers.domain.DeploymentPlanResult)2 DomainDeploymentManager (org.jboss.as.controller.client.helpers.domain.DomainDeploymentManager)2 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)2 ZipExporter (org.jboss.shrinkwrap.api.exporter.ZipExporter)2 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)2 Map (java.util.Map)1 PathElement (org.jboss.as.controller.PathElement)1 Operations (org.jboss.as.controller.client.helpers.Operations)1 ServerIdentity (org.jboss.as.controller.client.helpers.domain.ServerIdentity)1 ServerStatus (org.jboss.as.controller.client.helpers.domain.ServerStatus)1