@Test public void testServerGroupsTransformer() throws Exception { boolean is71x = modelVersion.getMajor() == 1 && modelVersion.getMinor() < 4; KernelServicesBuilder builder = createKernelServicesBuilder(TestModelType.DOMAIN) .setModelInitializer( StandardServerGroupInitializers.XML_MODEL_INITIALIZER, StandardServerGroupInitializers.XML_MODEL_WRITE_SANITIZER) .createContentRepositoryContent("12345678901234567890") .createContentRepositoryContent("09876543210987654321") .setXmlResource(is71x ? "servergroup_1_3.xml" : "servergroup-with-expressions.xml"); LegacyKernelServicesInitializer legacyInitializer = StandardServerGroupInitializers.addServerGroupInitializers( builder.createLegacyKernelServicesBuilder(modelVersion, testControllerVersion)); if (is71x) { // The 7.1.x descriptions are inaccurate so we can't validate the add ops against them legacyInitializer.setDontValidateOperations(); } KernelServices mainServices = builder.build(); Assert.assertTrue(mainServices.isSuccessfulBoot()); KernelServices legacyServices = mainServices.getLegacyServices(modelVersion); Assert.assertTrue(legacyServices.isSuccessfulBoot()); checkCoreModelTransformation(mainServices, modelVersion, MODEL_FIXER, MODEL_FIXER); }
@Test public void testDeploymentOverlaysIgnoredOnOlderVersionGetIgnoredButFailDueToServerGroupEntry() throws Exception { if (modelVersion.getMajor() > 1 || modelVersion.getMinor() >= 4) { return; } KernelServicesBuilder builder = createKernelServicesBuilder(TestModelType.DOMAIN) .setModelInitializer( StandardServerGroupInitializers.XML_MODEL_INITIALIZER, StandardServerGroupInitializers.XML_MODEL_WRITE_SANITIZER) .createContentRepositoryContent("12345678901234567890") .setXmlResource("domain.xml"); // Start up an empty legacy controller StandardServerGroupInitializers.addServerGroupInitializers( builder.createLegacyKernelServicesBuilder(modelVersion, testControllerVersion)) .setDontUseBootOperations() // Since the legacy controller does not know about deployment overlays, there will be not // boot ops for the reverse check .skipReverseControllerCheck(); KernelServices mainServices = builder.build(); Assert.assertTrue(mainServices.isSuccessfulBoot()); KernelServices legacyServices = mainServices.getLegacyServices(modelVersion); Assert.assertTrue(legacyServices.isSuccessfulBoot()); // Since the server group deployment deployment-overlay is there we should fail try { mainServices.applyMasterDomainModel(modelVersion, null); Assert.fail( "Should have failed to apply model since server group still has a deployment overlay"); } catch (Exception e) { Assert.assertTrue( e.getMessage(), e.getMessage().contains("WFLYCTL0147") || e.getMessage() .contains( "JBAS014738")); // WFLYCTL0147 comes from // ControllerMessages.noChildType(String) } }
@Test public void testDeploymentOverlaysTransformer() throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(TestModelType.DOMAIN) .setModelInitializer( StandardServerGroupInitializers.XML_MODEL_INITIALIZER, StandardServerGroupInitializers.XML_MODEL_WRITE_SANITIZER) .createContentRepositoryContent("12345678901234567890") .setXmlResource("domain.xml"); LegacyKernelServicesInitializer legacyInitializer = StandardServerGroupInitializers.addServerGroupInitializers( builder.createLegacyKernelServicesBuilder(modelVersion, testControllerVersion)); if (modelVersion.getMajor() == 1 && modelVersion.getMinor() < 4) { testDeploymentOverlaysTransformer_7_1_x(modelVersion, builder, legacyInitializer); } else { testDeploymentOverlaysTransformerMaster(modelVersion, builder, legacyInitializer); } }
@Test public void testRejectTransformers71x() throws Exception { if (modelVersion.getMajor() > 1 || modelVersion.getMinor() > 3) { return; } KernelServicesBuilder builder = createKernelServicesBuilder(TestModelType.DOMAIN) .setModelInitializer( StandardServerGroupInitializers.XML_MODEL_INITIALIZER, StandardServerGroupInitializers.XML_MODEL_WRITE_SANITIZER) .createContentRepositoryContent("12345678901234567890") .createContentRepositoryContent("09876543210987654321"); // Add legacy subsystems LegacyKernelServicesInitializer legacyInitializer = StandardServerGroupInitializers.addServerGroupInitializers( builder.createLegacyKernelServicesBuilder(modelVersion, testControllerVersion)) // The reverse stuff is tested in the other test .skipReverseControllerCheck(); // The 7.1.x descriptions are inaccurate so we can't validate the add ops against them legacyInitializer.setDontValidateOperations(); KernelServices mainServices = builder.build(); List<ModelNode> ops = builder.parseXmlResource("servergroup_1_3-with-expressions.xml"); ModelTestUtils.checkFailedTransformedBootOperations( mainServices, modelVersion, ops, new FailedOperationTransformationConfig() .addFailedAttribute( PathAddress.pathAddress(PathElement.pathElement(SERVER_GROUP)), new FailedOperationTransformationConfig.RejectExpressionsConfig( ServerGroupResourceDefinition.MANAGEMENT_SUBSYSTEM_ENDPOINT, ServerGroupResourceDefinition.SOCKET_BINDING_PORT_OFFSET) .setReadOnly(ServerGroupResourceDefinition.MANAGEMENT_SUBSYSTEM_ENDPOINT))); }
@Override protected boolean rejectAttribute( PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) { if (attributeValue.isDefined()) { ModelVersion version = context.getTarget().getVersion(); if (version.getMajor() == 1 && version.getMinor() == 2) { // 7.1.2 has model version 1.2.0 and should have this transformation // 7.1.3 has model version 1.3.0 and should not have this transformation if (attributeValue.getType() == ModelType.BOOLEAN) { return !attributeValue.asBoolean(); } else { if (!Boolean.parseBoolean(attributeValue.asString())) { return true; } } } } return false; }
@Test public void testDeploymentOverlaysIgnoredOnOlderVersionGetIgnored() throws Exception { if (modelVersion.getMajor() > 1 || modelVersion.getMinor() >= 4) { return; } KernelServicesBuilder builder = createKernelServicesBuilder(TestModelType.DOMAIN) .setModelInitializer( StandardServerGroupInitializers.XML_MODEL_INITIALIZER, StandardServerGroupInitializers.XML_MODEL_WRITE_SANITIZER) .createContentRepositoryContent("12345678901234567890") .setXmlResource("domain-no-servergroup-overlay.xml"); // Start up an empty legacy controller StandardServerGroupInitializers.addServerGroupInitializers( builder.createLegacyKernelServicesBuilder(modelVersion, testControllerVersion)) .setDontUseBootOperations() // Since the legacy controller does not know about deployment overlays, there will be not // boot ops for the reverse check .skipReverseControllerCheck(); KernelServices mainServices = builder.build(); Assert.assertTrue(mainServices.isSuccessfulBoot()); KernelServices legacyServices = mainServices.getLegacyServices(modelVersion); Assert.assertTrue(legacyServices.isSuccessfulBoot()); // This should pass since the deployment-overlay resource is ignored, and there is no use of // deployment-overlay in server-group mainServices.applyMasterDomainModel( modelVersion, Collections.singletonList( new IgnoreDomainResourceTypeResource( ModelDescriptionConstants.DEPLOYMENT_OVERLAY, new ModelNode(), true))); // Check deployment overlays exist in the master model but not in the legacy model ModelNode masterModel = mainServices.readWholeModel(); ModelNode legacyModel = legacyServices.readWholeModel(); Assert.assertTrue( masterModel.hasDefined(ModelDescriptionConstants.DEPLOYMENT_OVERLAY) && masterModel .get(ModelDescriptionConstants.DEPLOYMENT_OVERLAY) .hasDefined("test-overlay")); Assert.assertFalse(legacyModel.hasDefined(ModelDescriptionConstants.DEPLOYMENT_OVERLAY)); // Compare the transformed and legacy models checkCoreModelTransformation( mainServices, modelVersion, new ModelFixer() { @Override public ModelNode fixModel(ModelNode modelNode) { // This one is just noise due to a different format // Perhaps this should go into the model comparison itself? ModelNode socketBindingGroup = modelNode.get(SOCKET_BINDING_GROUP, "test-sockets"); if (socketBindingGroup.isDefined()) { Set<String> names = new HashSet<String>(); for (String key : socketBindingGroup.keys()) { if (!socketBindingGroup.get(key).isDefined()) { names.add(key); } } for (String name : names) { socketBindingGroup.remove(name); } if (socketBindingGroup.keys().size() == 0) { socketBindingGroup.clear(); } } return modelNode; } }, new ModelFixer() { @Override public ModelNode fixModel(ModelNode modelNode) { modelNode.remove(ModelDescriptionConstants.DEPLOYMENT_OVERLAY); return modelNode; } }); }