Search in sources :

Example 6 with KernelServices

use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.

the class SingletonTransformersTestCase method buildKernelServices.

private KernelServices buildKernelServices(String subsystemXml, ModelTestControllerVersion controllerVersion, ModelVersion version, String... mavenResourceURLs) throws Exception {
    KernelServicesBuilder builder = this.createKernelServicesBuilder().setSubsystemXmlResource(subsystemXml);
    builder.createLegacyKernelServicesBuilder(this.createAdditionalInitialization(), controllerVersion, version).addSingleChildFirstClass(AdditionalInitialization.class).addMavenResourceURL(mavenResourceURLs).skipReverseControllerCheck();
    KernelServices services = builder.build();
    Assert.assertTrue(ModelTestControllerVersion.MASTER + " boot failed", services.isSuccessfulBoot());
    Assert.assertTrue(controllerVersion.getMavenGavVersion() + " boot failed", services.getLegacyServices(version).isSuccessfulBoot());
    return services;
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 7 with KernelServices

use of org.jboss.as.subsystem.test.KernelServices 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 8 with KernelServices

use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.

the class JGroupsTransformersTestCase method testTransformation.

/**
     * Tests transformation of model from current version into specified version.
     */
private void testTransformation(final ModelTestControllerVersion controller) throws Exception {
    final ModelVersion version = getModelVersion(controller).getVersion();
    final String[] dependencies = getDependencies(controller);
    // create builder for current subsystem version
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXmlResource("subsystem-jgroups-transform.xml");
    // initialize the legacy services and add required jars
    builder.createLegacyKernelServicesBuilder(null, controller, version).addMavenResourceURL(dependencies).skipReverseControllerCheck();
    KernelServices services = builder.build();
    Assert.assertTrue(services.isSuccessfulBoot());
    Assert.assertTrue(services.getLegacyServices(version).isSuccessfulBoot());
    // check that both versions of the legacy model are the same and valid
    checkSubsystemModelTransformation(services, version);
    if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
        // Test properties operations
        propertiesMapOperationsTest(services, version);
        testNonMapTransformersWork(services, version);
    }
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 9 with KernelServices

use of org.jboss.as.subsystem.test.KernelServices 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)

Example 10 with KernelServices

use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.

the class OperationSequencesTestCase method testProtocolStackAddRemoveAddSequence.

@Test
public void testProtocolStackAddRemoveAddSequence() throws Exception {
    KernelServices services = buildKernelServices();
    ModelNode operation = Operations.createCompositeOperation(addStackOp, addTransportOp, addProtocolOp);
    // add a protocol stack, its transport and a protocol as a batch
    ModelNode result = services.executeOperation(operation);
    Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
    // remove the stack
    result = services.executeOperation(removeStackOp);
    Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
    // add the same stack
    result = services.executeOperation(operation);
    Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Aggregations

KernelServices (org.jboss.as.subsystem.test.KernelServices)144 ModelNode (org.jboss.dmr.ModelNode)102 Test (org.junit.Test)86 KernelServicesBuilder (org.jboss.as.subsystem.test.KernelServicesBuilder)69 ModelVersion (org.jboss.as.controller.ModelVersion)30 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)29 PathAddress (org.jboss.as.controller.PathAddress)24 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)21 AbstractSubsystemTest (org.jboss.as.subsystem.test.AbstractSubsystemTest)11 ClusteringSubsystemTest (org.jboss.as.clustering.subsystem.ClusteringSubsystemTest)10 AdditionalInitialization (org.jboss.as.subsystem.test.AdditionalInitialization)8 ModelFixer (org.jboss.as.model.test.ModelFixer)7 ControllerInitializer (org.jboss.as.subsystem.test.ControllerInitializer)6 ModelTestControllerVersion (org.jboss.as.model.test.ModelTestControllerVersion)5 Properties (java.util.Properties)4 Session (javax.mail.Session)4 CompositeOperationBuilder (org.jboss.as.controller.client.helpers.Operations.CompositeOperationBuilder)3 ConnectorLogger (org.jboss.as.connector.logging.ConnectorLogger)2 Operation (org.jboss.as.controller.client.Operation)2 NewAttributesConfig (org.jboss.as.model.test.FailedOperationTransformationConfig.NewAttributesConfig)2