Skip to content

Commit

Permalink
Mixed domain test for rejection of profile:clone in old versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kabir committed Sep 16, 2015
1 parent dbdd3aa commit 348aaf1
Showing 1 changed file with 82 additions and 11 deletions.
Expand Up @@ -22,27 +22,33 @@
package org.jboss.as.test.integration.domain.mixed; package org.jboss.as.test.integration.domain.mixed;


import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.BLOCKING; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.BLOCKING;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CLONE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.COMPOSITE; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.COMPOSITE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CORE_SERVICE; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CORE_SERVICE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.EXTENSION; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.EXTENSION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.HOST; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.HOST;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.IGNORED_RESOURCES;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.IGNORED_RESOURCE_TYPE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.INCLUDE_ALIASES; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.INCLUDE_ALIASES;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.INCLUDE_RUNTIME; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.INCLUDE_RUNTIME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.INTERFACE; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.INTERFACE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.MANAGEMENT_CLIENT_CONTENT; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.MANAGEMENT_CLIENT_CONTENT;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAMES;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PROFILE; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PROFILE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PROXIES; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PROXIES;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_RESOURCE_OPERATION; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_RESOURCE_OPERATION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RECURSIVE; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RECURSIVE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESTART; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESTART;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESTART_SERVERS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SERVER_CONFIG; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SERVER_CONFIG;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SERVER_GROUP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SERVER_GROUP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SOCKET_BINDING_GROUP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SOCKET_BINDING_GROUP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.STEPS; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.STEPS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SYSTEM_PROPERTY; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SYSTEM_PROPERTY;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.TO_PROFILE;
import static org.jboss.as.test.integration.domain.management.util.DomainTestSupport.validateResponse; import static org.jboss.as.test.integration.domain.management.util.DomainTestSupport.validateResponse;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;


Expand All @@ -63,6 +69,7 @@
import org.jboss.as.model.test.ModelTestUtils; import org.jboss.as.model.test.ModelTestUtils;
import org.jboss.as.security.Constants; import org.jboss.as.security.Constants;
import org.jboss.as.security.SecurityExtension; import org.jboss.as.security.SecurityExtension;
import org.jboss.as.test.integration.domain.management.util.DomainLifecycleUtil;
import org.jboss.as.test.integration.domain.management.util.DomainTestSupport; import org.jboss.as.test.integration.domain.management.util.DomainTestSupport;
import org.jboss.as.test.integration.domain.management.util.DomainTestUtils; import org.jboss.as.test.integration.domain.management.util.DomainTestUtils;
import org.jboss.as.test.shared.TestSuiteEnvironment; import org.jboss.as.test.shared.TestSuiteEnvironment;
Expand Down Expand Up @@ -99,13 +106,13 @@ public synchronized static void afterClass() {
} }


@Test @Test
public void test1ServerRunning() throws Exception { public void test00001_ServerRunning() throws Exception {
URLConnection connection = new URL("http://" + TestSuiteEnvironment.formatPossibleIpv6Address(DomainTestSupport.slaveAddress) + ":8080").openConnection(); URLConnection connection = new URL("http://" + TestSuiteEnvironment.formatPossibleIpv6Address(DomainTestSupport.slaveAddress) + ":8080").openConnection();
connection.connect(); connection.connect();
} }


@Test @Test
public void test2Versioning() throws Exception { public void test00002_Versioning() throws Exception {
if (version == Version.AsVersion.EAP_6_2_0) { if (version == Version.AsVersion.EAP_6_2_0) {
//6.2.0 has the slave report back its own version, rather than the one from the DC, //6.2.0 has the slave report back its own version, rather than the one from the DC,
//which is what happens in more recent slaves //which is what happens in more recent slaves
Expand Down Expand Up @@ -133,7 +140,7 @@ public void test2Versioning() throws Exception {
} }


@Test @Test
public void test9SecurityTransformers() throws Exception { public void test00009_SecurityTransformers() throws Exception {
final DomainClient masterClient = support.getDomainMasterLifecycleUtil().createDomainClient(); final DomainClient masterClient = support.getDomainMasterLifecycleUtil().createDomainClient();
final DomainClient slaveClient = support.getDomainSlaveLifecycleUtil().createDomainClient(); final DomainClient slaveClient = support.getDomainSlaveLifecycleUtil().createDomainClient();
try { try {
Expand Down Expand Up @@ -188,17 +195,81 @@ public void test9SecurityTransformers() throws Exception {
} }


@Test @Test
public void testJgroupsTransformers() throws Exception { public void test00010_JgroupsTransformers() throws Exception {
final DomainClient masterClient = support.getDomainMasterLifecycleUtil().createDomainClient(); 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);
}
}

//Do this one last since it changes the host model of the slaves
@Test
public void test99999_ProfileClone() throws Exception {
//For an EAP 7 slave we will need another test since 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 fullHaAddress = PathAddress.pathAddress(PROFILE, "new-profile");

//Create a new profile (so that we can ignore it on the host later)
DomainTestUtils.executeForResult(Util.createAddOperation(fullHaAddress), masterClient);

//Attempt to clone it. It should fail since the transformers reject it.
final ModelNode clone = Util.createEmptyOperation(CLONE, fullHaAddress);
clone.get(TO_PROFILE).set("cloned");
DomainTestUtils.executeForFailure(clone, masterClient);

//Ignore the new profile on the slave and reload
final PathAddress ignoredResourceAddress = PathAddress.pathAddress(HOST, "slave")
.append(CORE_SERVICE, IGNORED_RESOURCES).append(IGNORED_RESOURCE_TYPE, PROFILE);
final ModelNode ignoreNewProfile = Util.createAddOperation(ignoredResourceAddress);
ignoreNewProfile.get(NAMES).add("new-profile");
DomainTestUtils.executeForResult(ignoreNewProfile, slaveClient);

//Reload slave so ignore takes effect
reloadHost(support.getDomainSlaveLifecycleUtil(), "slave");

//Clone should work now that the new profile is ignored
DomainTestUtils.executeForResult(clone, masterClient);

//Adding a subsystem to the cloned profile should fail since the profile does not exist on the slave
DomainTestUtils.executeForFailure(Util.createAddOperation(PathAddress.pathAddress(PROFILE, "cloned").append(SUBSYSTEM, "jmx")), masterClient);

//Reload slave
reloadHost(support.getDomainSlaveLifecycleUtil(), "slave");

//Reloading should have brought over the cloned profile, so adding a subsystem should now work
DomainTestUtils.executeForResult(Util.createAddOperation(PathAddress.pathAddress(PROFILE, "cloned").append(SUBSYSTEM, "jmx")), masterClient);
} finally {
IoUtils.safeClose(slaveClient);
IoUtils.safeClose(masterClient);
}
}

/*
!!!!!!!!! ADD TESTS IN NUMERICAL ORDER !!!!!!!!!!
Please observe the test<5 digits>_ pattern for the names to ensure the order
*/


// 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"));


ModelNode masterResource = DomainTestUtils.executeForResult(compositeOp, masterClient); private DomainClient reloadHost(DomainLifecycleUtil lifecycleUtil, String host) throws Exception {
ModelNode reload = Util.createEmptyOperation("reload", PathAddress.pathAddress(HOST, host));
reload.get(RESTART_SERVERS).set(false);
lifecycleUtil.executeAwaitConnectionClosed(reload);
lifecycleUtil.connect();
lifecycleUtil.awaitHostController(System.currentTimeMillis());
return lifecycleUtil.createDomainClient();
} }


private static ModelNode createProtocolPutPropertyOperation(String stackName, String protocolName, String propertyName, String propertyValue) { private static ModelNode createProtocolPutPropertyOperation(String stackName, String protocolName, String propertyName, String propertyValue) {
Expand Down

0 comments on commit 348aaf1

Please sign in to comment.