use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class OperationsTestCase method testTransportPropertyReadWriteOperation.
@Test
public void testTransportPropertyReadWriteOperation() throws Exception {
KernelServices services = this.buildKernelServices();
// read the enable_bundling transport property
ModelNode result = services.executeOperation(getTransportGetPropertyOperation("maximal", "TCP", "enable_bundling"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals("true", result.get(RESULT).resolve().asString());
// write the enable_bundling transport property
result = services.executeOperation(getTransportPutPropertyOperation("maximal", "TCP", "enable_bundling", "false"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
// re-read the enable_bundling transport property
result = services.executeOperation(getTransportGetPropertyOperation("maximal", "TCP", "enable_bundling"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals("false", result.get(RESULT).asString());
// remove the enable_bundling transport property
result = services.executeOperation(getTransportRemovePropertyOperation("maximal", "TCP", "enable_bundling"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
// re-read the enable_bundling transport property
result = services.executeOperation(getTransportGetPropertyOperation("maximal", "TCP", "enable_bundling"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
// Validate that add/read/write/remove via legacy property resource
result = services.executeOperation(getTransportPropertyAddOperation("maximal", "TCP", "shared", "false"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
result = services.executeOperation(getTransportPropertyReadOperation("maximal", "TCP", "shared"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals("false", result.get(RESULT).asString());
result = services.executeOperation(getTransportGetPropertyOperation("maximal", "TCP", "shared"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals("false", result.get(RESULT).asString());
result = services.executeOperation(getTransportPropertyWriteOperation("maximal", "TCP", "shared", "true"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
result = services.executeOperation(getTransportPropertyReadOperation("maximal", "TCP", "shared"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals("true", result.get(RESULT).asString());
result = services.executeOperation(getTransportGetPropertyOperation("maximal", "TCP", "shared"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals("true", result.get(RESULT).asString());
result = services.executeOperation(getTransportPropertyRemoveOperation("maximal", "TCP", "shared"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
result = services.executeOperation(getTransportGetPropertyOperation("maximal", "TCP", "shared"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertFalse(result.get(RESULT).isDefined());
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class SingletonTransformersTestCase method testRejections.
private void testRejections(final ModelTestControllerVersion controller) throws Exception {
final ModelVersion version = getModelVersion(controller).getVersion();
final String subsystemXmlResource = String.format("subsystem-reject-%d_%d_%d.xml", version.getMajor(), version.getMinor(), version.getMicro());
final String[] dependencies = getDependencies(controller);
// create builder for current subsystem version
KernelServicesBuilder builder = createKernelServicesBuilder();
// initialize the legacy services
builder.createLegacyKernelServicesBuilder(this.createAdditionalInitialization(), controller, version).addSingleChildFirstClass(AdditionalInitialization.class).addMavenResourceURL(dependencies);
KernelServices services = builder.build();
KernelServices legacyServices = services.getLegacyServices(version);
Assert.assertNotNull(legacyServices);
Assert.assertTrue(services.isSuccessfulBoot());
Assert.assertTrue(legacyServices.isSuccessfulBoot());
// test failed operations involving backups
List<ModelNode> xmlOps = builder.parseXmlResource(subsystemXmlResource);
ModelTestUtils.checkFailedTransformedBootOperations(services, version, xmlOps, createFailedOperationConfig(version));
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class SingletonXMLReader method parseSimpleElectionPolicy.
private void parseSimpleElectionPolicy(XMLExtendedStreamReader reader, PathAddress policyAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException {
PathAddress address = policyAddress.append(SimpleElectionPolicyResourceDefinition.PATH);
ModelNode operation = Util.createAddOperation(address);
operations.put(address, operation);
for (int i = 0; i < reader.getAttributeCount(); ++i) {
XMLAttribute attribute = XMLAttribute.forName(reader, i);
switch(attribute) {
case POSITION:
{
readAttribute(reader, i, operation, SimpleElectionPolicyResourceDefinition.Attribute.POSITION);
break;
}
default:
{
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
this.parsePreferences(reader, operation);
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class SingletonXMLReader method parseRandomElectionPolicy.
private void parseRandomElectionPolicy(XMLExtendedStreamReader reader, PathAddress policyAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException {
PathAddress address = policyAddress.append(RandomElectionPolicyResourceDefinition.PATH);
ModelNode operation = Util.createAddOperation(address);
operations.put(address, operation);
ParseUtils.requireNoAttributes(reader);
this.parsePreferences(reader, operation);
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class OperationSequencesTestCase method testLegacyTransportAliasSequence.
/**
* Test for https://issues.jboss.org/browse/WFLY-5290 where server/test hangs when using legacy TRANSPORT alias:
*
* Create a simple stack, then remove, re-add a different transport, remove twice expecting the 2nd remove to fail.
* Tests both situations when stack in inferred from :add operation and when its inferred from the existing resource.
*/
@Test
public void testLegacyTransportAliasSequence() throws Exception {
KernelServices services = buildKernelServices();
String stackName = "legacyStack";
// add a sample stack to test legacy paths on
ModelNode result = services.executeOperation(getProtocolStackAddOperationWithParameters(stackName));
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
// add a thread pool
result = services.executeOperation(getLegacyThreadPoolAddOperation(stackName, "default"));
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
ModelNode op = getLegacyThreadPoolAddOperation(stackName, "default");
op.get("operation").set("write-attribute");
op.get("name").set("keepalive-time");
op.get("value").set(999);
result = services.executeOperation(op);
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
op = Operations.createReadResourceOperation(getSubsystemAddress());
op.get(ModelDescriptionConstants.INCLUDE_ALIASES).set("true");
op.get(ModelDescriptionConstants.RECURSIVE).set("true");
result = services.executeOperation(op);
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
op = Util.createOperation(ModelDescriptionConstants.READ_RESOURCE_DESCRIPTION_OPERATION, getSubsystemAddress());
op.get(ModelDescriptionConstants.INCLUDE_ALIASES).set("true");
op.get(ModelDescriptionConstants.RECURSIVE).set("true");
result = services.executeOperation(op);
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
result = services.executeOperation(getLegacyTransportRemoveOperation(stackName));
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
result = services.executeOperation(getLegacyTransportAddOperation(stackName, "TCP"));
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
result = services.executeOperation(getLegacyTransportRemoveOperation(stackName));
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
result = services.executeOperation(getLegacyTransportRemoveOperation(stackName));
Assert.assertEquals(FAILED, result.get(OUTCOME).asString());
}
Aggregations