Search in sources :

Example 36 with ModelNode

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());
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 37 with ModelNode

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));
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) AdditionalInitialization(org.jboss.as.clustering.subsystem.AdditionalInitialization)

Example 38 with ModelNode

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);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 39 with ModelNode

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);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 40 with ModelNode

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());
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Aggregations

ModelNode (org.jboss.dmr.ModelNode)1634 PathAddress (org.jboss.as.controller.PathAddress)351 Test (org.junit.Test)344 KernelServices (org.jboss.as.subsystem.test.KernelServices)102 Property (org.jboss.dmr.Property)92 OperationFailedException (org.jboss.as.controller.OperationFailedException)89 OperationContext (org.jboss.as.controller.OperationContext)68 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)68 ArrayList (java.util.ArrayList)58 Resource (org.jboss.as.controller.registry.Resource)54 PathElement (org.jboss.as.controller.PathElement)53 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)52 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)50 IOException (java.io.IOException)49 ServiceName (org.jboss.msc.service.ServiceName)49 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)47 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)44 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)42 OperationBuilder (org.jboss.as.controller.client.OperationBuilder)42 Map (java.util.Map)38