Search in sources :

Example 6 with WildFlyManagedConfiguration

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

the class OrderedChildResourcesTestCase method testOrderedChildResources.

@Test
public void testOrderedChildResources() throws Exception {
    final WildFlyManagedConfiguration masterConfig = createConfiguration("domain.xml", "host-master.xml", getClass().getSimpleName());
    final DomainLifecycleUtil masterUtils = new DomainLifecycleUtil(masterConfig);
    final WildFlyManagedConfiguration slaveConfig = createConfiguration("domain.xml", "host-slave.xml", getClass().getSimpleName(), "slave", slaveAddress, 19999);
    final DomainLifecycleUtil slaveUtils = new DomainLifecycleUtil(slaveConfig);
    try {
        masterUtils.start();
        slaveUtils.start();
        PathAddress jgroupsTcpAddr = PathAddress.pathAddress(PROFILE, "full-ha").append(SUBSYSTEM, "jgroups").append("stack", "tcp");
        final ModelNode originalMasterStack = readResource(masterUtils.getDomainClient(), jgroupsTcpAddr);
        originalMasterStack.protect();
        final ModelNode originalSlaveStack = readResource(slaveUtils.getDomainClient(), jgroupsTcpAddr);
        originalSlaveStack.protect();
        Assert.assertEquals(originalMasterStack, originalSlaveStack);
        //FD is normally in the middle somewhere
        final String protocolName = "FD";
        int index = -1;
        ModelNode value = null;
        Iterator<Property> it = originalMasterStack.get(PROTOCOL).asPropertyList().iterator();
        for (int i = 0; it.hasNext(); i++) {
            Property property = it.next();
            if (property.getName().equals(protocolName)) {
                value = property.getValue();
                index = i;
                break;
            }
        }
        //Make sure that we found the protocol and that it is not at the end
        Assert.assertTrue(0 <= index);
        Assert.assertTrue(index < originalMasterStack.get(PROTOCOL).keys().size() - 2);
        //Remove the protocol
        DomainTestUtils.executeForResult(Util.createRemoveOperation(jgroupsTcpAddr.append(PROTOCOL, protocolName)), masterUtils.getDomainClient());
        //Reload the master into admin-only and re-add the protocol
        reloadMaster(masterUtils, true);
        ModelNode add = value.clone();
        add.get(OP).set(ADD);
        add.get(OP_ADDR).set(jgroupsTcpAddr.append(PROTOCOL, protocolName).toModelNode());
        add.get(ADD_INDEX).set(index);
        DomainTestUtils.executeForResult(add, masterUtils.getDomainClient());
        //Reload the master into normal mode and check the protocol is in the right place on the slave
        reloadMaster(masterUtils, false);
        ModelNode slaveStack = readResource(slaveUtils.getDomainClient(), jgroupsTcpAddr);
        Assert.assertEquals(originalMasterStack, slaveStack);
        //Check that :read-operation-description has add-index defined; WFLY-6782
        ModelNode rodOp = Util.createOperation(READ_OPERATION_DESCRIPTION_OPERATION, jgroupsTcpAddr.append(PROTOCOL, protocolName));
        rodOp.get(NAME).set(ADD);
        ModelNode result = DomainTestUtils.executeForResult(rodOp, masterUtils.getDomainClient());
        Assert.assertTrue(result.get(REQUEST_PROPERTIES).hasDefined(ADD_INDEX));
    } finally {
        try {
            slaveUtils.stop();
        } finally {
            masterUtils.stop();
        }
    }
}
Also used : WildFlyManagedConfiguration(org.jboss.as.test.integration.domain.management.util.WildFlyManagedConfiguration) PathAddress(org.jboss.as.controller.PathAddress) DomainLifecycleUtil(org.jboss.as.test.integration.domain.management.util.DomainLifecycleUtil) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property) Test(org.junit.Test)

Example 7 with WildFlyManagedConfiguration

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

the class DefaultConfigSmokeTestCase method testMasterAndSlave.

@Test
public void testMasterAndSlave() throws Exception {
    final WildFlyManagedConfiguration masterConfig = createConfiguration("domain.xml", "host-master.xml", getClass().getSimpleName());
    final DomainLifecycleUtil masterUtils = new DomainLifecycleUtil(masterConfig);
    final WildFlyManagedConfiguration slaveConfig = createConfiguration("domain.xml", "host-slave.xml", getClass().getSimpleName(), "slave", slaveAddress, 19999);
    final DomainLifecycleUtil slaveUtils = new DomainLifecycleUtil(slaveConfig);
    try {
        masterUtils.start();
        slaveUtils.start();
        // Double-check server status by confirming server-one can accept a web request to the root
        URLConnection connection = new URL("http://" + TestSuiteEnvironment.formatPossibleIpv6Address(slaveAddress) + ":8080").openConnection();
        connection.connect();
    } finally {
        try {
            slaveUtils.stop();
        } finally {
            masterUtils.stop();
        }
    }
}
Also used : WildFlyManagedConfiguration(org.jboss.as.test.integration.domain.management.util.WildFlyManagedConfiguration) DomainLifecycleUtil(org.jboss.as.test.integration.domain.management.util.DomainLifecycleUtil) URLConnection(java.net.URLConnection) URL(java.net.URL) Test(org.junit.Test)

Aggregations

WildFlyManagedConfiguration (org.jboss.as.test.integration.domain.management.util.WildFlyManagedConfiguration)7 DomainLifecycleUtil (org.jboss.as.test.integration.domain.management.util.DomainLifecycleUtil)4 Test (org.junit.Test)3 URL (java.net.URL)2 URLConnection (java.net.URLConnection)2 File (java.io.File)1 CallbackHandler (javax.security.auth.callback.CallbackHandler)1 PathAddress (org.jboss.as.controller.PathAddress)1 ModelNode (org.jboss.dmr.ModelNode)1 Property (org.jboss.dmr.Property)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1