Permalink
Browse files

[WFLY-7759] Mixed domain with EAP 6 slaves: data sources operations b…

…roken
  • Loading branch information...
1 parent d2a72c5 commit 070981acb7be0d550f5cf51cf0fdebce7ee081ad @gaol gaol committed Dec 14, 2016
@@ -60,6 +60,7 @@
import org.jboss.as.controller.access.constraint.ApplicationTypeConfig;
import org.jboss.as.controller.access.management.AccessConstraintDefinition;
import org.jboss.as.controller.access.management.ApplicationTypeAccessConstraintDefinition;
+import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.transform.TransformationContext;
@@ -205,7 +206,7 @@ protected boolean isValueDiscardable(PathAddress address, String attributeName,
}
}, TRACKING)
.addRejectCheck(RejectAttributeChecker.DEFINED, TRACKING)
- .addRejectCheck(RejectAttributeChecker.UNDEFINED, CONNECTION_URL)
+ .addRejectCheck(createConnURLRejectChecker(), CONNECTION_URL)
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, ENABLED).end()
//We're rejecting operations when statistics-enabled=false, so let it through in the enable/disable ops which do not use that attribute
.addOperationTransformationOverride(DATASOURCE_ENABLE.getName())
@@ -225,7 +226,7 @@ protected boolean isValueDiscardable(PathAddress address, String attributeName,
}, TRACKING)
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, ENABLED)
.addRejectCheck(RejectAttributeChecker.DEFINED, TRACKING)
- .addRejectCheck(RejectAttributeChecker.UNDEFINED, CONNECTION_URL).end();
+ .addRejectCheck(createConnURLRejectChecker(), CONNECTION_URL).end();
}
static void registerTransformers200(ResourceTransformationDescriptionBuilder parentBuilder) {
@@ -260,7 +261,7 @@ protected boolean isValueDiscardable(PathAddress address, String attributeName,
}
}, TRACKING)
.addRejectCheck(RejectAttributeChecker.DEFINED, TRACKING)
- .addRejectCheck(RejectAttributeChecker.UNDEFINED, CONNECTION_URL)
+ .addRejectCheck(createConnURLRejectChecker(), CONNECTION_URL)
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, ENABLED).end()
//We're rejecting operations when statistics-enabled=false, so let it through in the enable/disable ops which do not use that attribute
.addOperationTransformationOverride(DATASOURCE_ENABLE.getName())
@@ -279,17 +280,42 @@ static void registerTransformers300(ResourceTransformationDescriptionBuilder par
.addRejectCheck(RejectAttributeChecker.DEFINED, org.jboss.as.connector.subsystems.common.pool.Constants.POOL_FAIR)
.addRejectCheck(RejectAttributeChecker.DEFINED, ENLISTMENT_TRACE)
.addRejectCheck(RejectAttributeChecker.DEFINED, MCP)
- .addRejectCheck(RejectAttributeChecker.UNDEFINED, CONNECTION_URL)
+ .addRejectCheck(createConnURLRejectChecker(), CONNECTION_URL)
.end();
}
static void registerTransformers400(ResourceTransformationDescriptionBuilder parentBuilder) {
ResourceTransformationDescriptionBuilder builder = parentBuilder.addChildResource(PATH_DATASOURCE);
builder.getAttributeBuilder()
- .addRejectCheck(RejectAttributeChecker.UNDEFINED, CONNECTION_URL)
+ .addRejectCheck(createConnURLRejectChecker(), CONNECTION_URL)
.setValueConverter(new AttributeConverter.DefaultValueAttributeConverter(ENLISTMENT_TRACE), ENLISTMENT_TRACE)
.end();
}
+ private static RejectAttributeChecker createConnURLRejectChecker() {
+ return new RejectAttributeChecker.DefaultRejectAttributeChecker() {
+
+ @Override
+ public String getRejectionLogMessage(Map<String, ModelNode> attributes) {
+ return RejectAttributeChecker.UNDEFINED.getRejectionLogMessage(attributes);
+ }
+
+ @Override
+ public boolean rejectOperationParameter(PathAddress address, String attributeName,
+ ModelNode attributeValue, ModelNode operation, TransformationContext context) {
+ if (operation.get(ModelDescriptionConstants.OP).asString().equals(ModelDescriptionConstants.ADD)
+ && !attributeValue.isDefined()) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected boolean rejectAttribute(PathAddress address, String attributeName, ModelNode attributeValue,
+ TransformationContext context) {
+ return !attributeValue.isDefined();
+ }
+ };
+ }
}
@@ -37,18 +37,21 @@
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_ADDR;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME;
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.READ_CHILDREN_NAMES_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.RESTART;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESTART_SERVERS;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RUNNING_SERVER;
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.SOCKET_BINDING_GROUP;
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.SUCCESS;
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;
@@ -218,6 +221,31 @@ public void test00010_JgroupsTransformers() throws Exception {
}
}
+
+ /**
+ * Tests test-connection-in-pool() of ExampleDS.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void test00011_ExampleDSConnection() throws Exception{
+ if (version == Version.AsVersion.EAP_6_2_0) {
+ // see: https://issues.jboss.org/browse/WFLY-7792
+ return;
+ }
+ 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);
+ }
+ }
+
//Do this one last since it changes the host model of the slaves
@Test
public void test99999_ProfileClone() throws Exception {

0 comments on commit 070981a

Please sign in to comment.