Skip to content

Commit b5b0d7d

Browse files
authored
Merge pull request wildfly#6280 from yersan/WFCORE-7091
[WFCORE-7091] Create the ModelTestModelControllerService variants for the WF 31 controllers
2 parents 9a07bd9 + abea9d2 commit b5b0d7d

File tree

15 files changed

+348
-79
lines changed

15 files changed

+348
-79
lines changed

core-model-test/framework/src/main/java/org/jboss/as/core/model/bridge/impl/ChildFirstClassLoaderKernelServicesFactory.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.jboss.as.host.controller.HostRunningModeControl;
3030
import org.jboss.as.host.controller.RestartMode;
3131
import org.jboss.as.model.test.ModelTestOperationValidatorFilter;
32+
import org.jboss.as.version.Stability;
3233
import org.jboss.dmr.ModelNode;
3334
import org.jboss.staxmapper.XMLMapper;
3435

@@ -54,6 +55,28 @@ public static KernelServices create(List<ModelNode> bootOperations, ModelTestOpe
5455
return AbstractKernelServicesImpl.create(ProcessType.HOST_CONTROLLER, runningModeControl, validateOpsFilter, bootOperations, testParser, legacyModelVersion, type, modelInitializer, extensionRegistry, null);
5556
}
5657

58+
public static KernelServices create(List<ModelNode> bootOperations, ModelTestOperationValidatorFilter validateOpsFilter, ModelVersion legacyModelVersion,
59+
List<LegacyModelInitializerEntry> modelInitializerEntries, String stabilityStr) throws Exception {
60+
61+
Stability stability = Stability.fromString(stabilityStr);
62+
TestModelType type = TestModelType.DOMAIN;
63+
XMLMapper xmlMapper = XMLMapper.Factory.create();
64+
TestParser testParser = TestParser.create(stability, null, xmlMapper, type);
65+
ModelInitializer modelInitializer = null;
66+
if (modelInitializerEntries != null && !modelInitializerEntries.isEmpty()) {
67+
modelInitializer = new LegacyModelInitializer(modelInitializerEntries);
68+
}
69+
70+
RunningModeControl runningModeControl = new HostRunningModeControl(RunningMode.ADMIN_ONLY, RestartMode.HC_ONLY);
71+
72+
ExtensionRegistry extensionRegistry = ExtensionRegistry.builder(ProcessType.HOST_CONTROLLER)
73+
.withRunningMode(runningModeControl.getRunningMode())
74+
.withStability(stability)
75+
.build();
76+
77+
return AbstractKernelServicesImpl.create(ProcessType.HOST_CONTROLLER, runningModeControl, validateOpsFilter, bootOperations, testParser, legacyModelVersion, type, modelInitializer, extensionRegistry, null);
78+
}
79+
5780
private static class LegacyModelInitializer implements ModelInitializer {
5881

5982
private final List<LegacyModelInitializerEntry> entries;

core-model-test/framework/src/main/java/org/jboss/as/core/model/bridge/local/ScopedKernelServicesBootstrap.java

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,58 +14,89 @@
1414
import org.jboss.as.core.model.bridge.impl.LegacyControllerKernelServicesProxy;
1515
import org.jboss.as.core.model.test.LegacyModelInitializerEntry;
1616
import org.jboss.as.model.test.ModelTestOperationValidatorFilter;
17+
import org.jboss.as.version.Stability;
1718
import org.jboss.dmr.ModelNode;
1819

1920
/**
20-
*
2121
* @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
2222
*/
2323
public class ScopedKernelServicesBootstrap {
24+
Stability stability;
2425
ClassLoader legacyChildFirstClassLoader;
2526
ClassLoaderObjectConverter objectConverter;
2627

27-
public ScopedKernelServicesBootstrap(ClassLoader legacyChildFirstClassLoader) {
28+
public ScopedKernelServicesBootstrap(ClassLoader legacyChildFirstClassLoader, Stability stability) {
2829
this.legacyChildFirstClassLoader = legacyChildFirstClassLoader;
2930
this.objectConverter = new ClassLoaderObjectConverterImpl(this.getClass().getClassLoader(), legacyChildFirstClassLoader);
31+
this.stability = stability;
3032
}
3133

32-
3334
public LegacyControllerKernelServicesProxy createKernelServices(List<ModelNode> bootOperations, ModelTestOperationValidatorFilter validateOpsFilter, ModelVersion legacyModelVersion, List<LegacyModelInitializerEntry> modelInitializerEntries) throws Exception {
3435

3536
Object childClassLoaderKernelServices = createChildClassLoaderKernelServices(bootOperations, validateOpsFilter, legacyModelVersion, modelInitializerEntries);
3637
return new LegacyControllerKernelServicesProxy(legacyChildFirstClassLoader, childClassLoaderKernelServices, objectConverter);
3738
}
3839

39-
private Object createChildClassLoaderKernelServices(List<ModelNode> bootOperations, ModelTestOperationValidatorFilter validateOpsFilter, ModelVersion legacyModelVersion, List<LegacyModelInitializerEntry> modelInitializerEntries){
40+
private Object createChildClassLoaderKernelServices(List<ModelNode> bootOperations, ModelTestOperationValidatorFilter validateOpsFilter, ModelVersion legacyModelVersion, List<LegacyModelInitializerEntry> modelInitializerEntries) {
4041
try {
4142
Class<?> clazz = legacyChildFirstClassLoader.loadClass(ChildFirstClassLoaderKernelServicesFactory.class.getName());
43+
List<Object> convertedBootOps = getConvertedBootOps(bootOperations);
44+
List<Object> convertedModelInitializerEntries = convertModelInitializer(modelInitializerEntries);
4245

43-
Method m = clazz.getMethod("create",
44-
List.class,
45-
legacyChildFirstClassLoader.loadClass(ModelTestOperationValidatorFilter.class.getName()),
46-
legacyChildFirstClassLoader.loadClass(ModelVersion.class.getName()),
47-
List.class);
48-
49-
List<Object> convertedBootOps = new ArrayList<Object>();
50-
for (int i = 0 ; i < bootOperations.size() ; i++) {
51-
ModelNode node = bootOperations.get(i);
52-
if (node != null) {
53-
convertedBootOps.add(objectConverter.convertModelNodeToChildCl(node));
54-
}
55-
}
46+
Object convertedValidationFilter = objectConverter.convertValidateOperationsFilterToChildCl(validateOpsFilter);
47+
Object convertedLegacyModelVersion = objectConverter.convertModelVersionToChildCl(legacyModelVersion);
5648

57-
List<Object> convertedModelInitializerEntries = null;
58-
if (modelInitializerEntries != null) {
59-
convertedModelInitializerEntries = new ArrayList<Object>();
60-
for (LegacyModelInitializerEntry entry : modelInitializerEntries) {
61-
convertedModelInitializerEntries.add(objectConverter.convertLegacyModelInitializerEntryToChildCl(entry));
62-
}
63-
}
49+
if (!Stability.DEFAULT.equals(stability)) {
50+
Method m = clazz.getMethod("create",
51+
List.class,
52+
legacyChildFirstClassLoader.loadClass(ModelTestOperationValidatorFilter.class.getName()),
53+
legacyChildFirstClassLoader.loadClass(ModelVersion.class.getName()),
54+
List.class,
55+
String.class);
6456

65-
return m.invoke(null, convertedBootOps, objectConverter.convertValidateOperationsFilterToChildCl(validateOpsFilter), objectConverter.convertModelVersionToChildCl(legacyModelVersion), convertedModelInitializerEntries);
57+
return m.invoke(null,
58+
convertedBootOps,
59+
convertedValidationFilter,
60+
convertedLegacyModelVersion,
61+
convertedModelInitializerEntries,
62+
stability.toString());
63+
} else {
64+
Method m = clazz.getMethod("create",
65+
List.class,
66+
legacyChildFirstClassLoader.loadClass(ModelTestOperationValidatorFilter.class.getName()),
67+
legacyChildFirstClassLoader.loadClass(ModelVersion.class.getName()),
68+
List.class);
6669

70+
return m.invoke(null,
71+
convertedBootOps,
72+
convertedValidationFilter,
73+
convertedLegacyModelVersion,
74+
convertedModelInitializerEntries);
75+
}
6776
} catch (Exception e) {
6877
throw new RuntimeException(e);
6978
}
7079
}
80+
81+
private List<Object> convertModelInitializer(List<LegacyModelInitializerEntry> modelInitializerEntries) {
82+
List<Object> converted = null;
83+
if (modelInitializerEntries != null) {
84+
converted = new ArrayList<>();
85+
for (LegacyModelInitializerEntry entry : modelInitializerEntries) {
86+
converted.add(objectConverter.convertLegacyModelInitializerEntryToChildCl(entry));
87+
}
88+
}
89+
return converted;
90+
}
91+
92+
private List<Object> getConvertedBootOps(List<ModelNode> bootOperations) {
93+
List<Object> converted = new ArrayList<>();
94+
for (ModelNode node : bootOperations) {
95+
if (node != null) {
96+
converted.add(objectConverter.convertModelNodeToChildCl(node));
97+
}
98+
}
99+
return converted;
100+
}
71101
}
102+

core-model-test/framework/src/main/java/org/jboss/as/core/model/test/CoreModelTestDelegate.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
import org.jboss.dmr.Property;
9595
import org.jboss.staxmapper.XMLMapper;
9696
import org.junit.Assert;
97+
import org.junit.Assume;
9798
import org.wildfly.common.xml.XMLInputFactoryUtil;
9899
import org.wildfly.legacy.test.spi.Version;
99100

@@ -446,7 +447,10 @@ private class KernelServicesBuilderImpl implements KernelServicesBuilder, ModelT
446447
this.stability = stability;
447448
this.processType = type == TestModelType.HOST || type == TestModelType.DOMAIN ? ProcessType.HOST_CONTROLLER : ProcessType.STANDALONE_SERVER;
448449
runningModeControl = type == TestModelType.HOST ? new HostRunningModeControl(RunningMode.ADMIN_ONLY, RestartMode.HC_ONLY) : new RunningModeControl(RunningMode.ADMIN_ONLY);
449-
extensionRegistry = ExtensionRegistry.builder(this.processType).withRunningModeControl(this.runningModeControl).withStability(stability).build();
450+
extensionRegistry = ExtensionRegistry.builder(this.processType)
451+
.withRunningModeControl(this.runningModeControl)
452+
.withStability(stability)
453+
.build();
450454
testParser = TestParser.create(stability, extensionRegistry, xmlMapper, type);
451455
}
452456

@@ -680,16 +684,19 @@ private class LegacyKernelServicesInitializerImpl implements LegacyKernelService
680684
private final ModelVersion modelVersion;
681685
private final List<LegacyModelInitializerEntry> modelInitializerEntries = new ArrayList<LegacyModelInitializerEntry>();
682686
private final ModelTestControllerVersion testControllerVersion;
687+
private final Stability stability;
683688
private boolean dontUseBootOperations = false;
684689
private boolean skipReverseCheck;
685690
private ModelFixer reverseCheckMainModelFixer;
686691
private ModelFixer reverseCheckLegacyModelFixer;
687692
private ModelTestOperationValidatorFilter.Builder operationValidationExcludeFilterBuilder;
688693

689694
LegacyKernelServicesInitializerImpl(ModelVersion modelVersion, ModelTestControllerVersion version) {
695+
Assume.assumeFalse("This model controller version is ignored for this server.", version.isIgnored());
690696
this.classLoaderBuilder = new ChildFirstClassLoaderBuilder(version.isEap());
691697
this.modelVersion = modelVersion;
692698
this.testControllerVersion = version;
699+
this.stability = version.getStability();
693700
}
694701

695702
private LegacyControllerKernelServicesProxy install(AbstractKernelServicesImpl mainServices, ModelInitializer modelInitializer, ModelWriteSanitizer modelWriteSanitizer, List<String> contentRepositoryContents, List<ModelNode> bootOperations) throws Exception {
@@ -698,7 +705,7 @@ private LegacyControllerKernelServicesProxy install(AbstractKernelServicesImpl m
698705
}
699706

700707
if (!skipReverseCheck) {
701-
bootCurrentVersionWithLegacyBootOperations(bootOperations, modelInitializer, modelWriteSanitizer, contentRepositoryContents, mainServices);
708+
bootCurrentVersionWithLegacyBootOperations(bootOperations, modelInitializer, modelWriteSanitizer, contentRepositoryContents, mainServices, stability);
702709
}
703710

704711
final ClassLoader legacyCl;
@@ -733,7 +740,7 @@ private LegacyControllerKernelServicesProxy install(AbstractKernelServicesImpl m
733740
}
734741

735742

736-
ScopedKernelServicesBootstrap scopedBootstrap = new ScopedKernelServicesBootstrap(legacyCl);
743+
ScopedKernelServicesBootstrap scopedBootstrap = new ScopedKernelServicesBootstrap(legacyCl, stability);
737744
LegacyControllerKernelServicesProxy legacyServices = scopedBootstrap.createKernelServices(bootOperations, getOperationValidationFilter(), modelVersion, modelInitializerEntries);
738745

739746
return legacyServices;
@@ -793,8 +800,9 @@ public LegacyKernelServicesInitializer configureReverseControllerCheck(ModelFixe
793800
return this;
794801
}
795802

796-
private KernelServices bootCurrentVersionWithLegacyBootOperations(List<ModelNode> bootOperations, ModelInitializer modelInitializer, ModelWriteSanitizer modelWriteSanitizer, List<String> contentRepositoryHashes, KernelServices mainServices) throws Exception {
797-
KernelServicesBuilder reverseServicesBuilder = createKernelServicesBuilder(TestModelType.DOMAIN, Stability.DEFAULT)
803+
private KernelServices bootCurrentVersionWithLegacyBootOperations(List<ModelNode> bootOperations, ModelInitializer modelInitializer, ModelWriteSanitizer modelWriteSanitizer, List<String> contentRepositoryHashes, KernelServices mainServices, Stability stability) throws Exception {
804+
testControllerVersion.getCoreVersion();
805+
KernelServicesBuilder reverseServicesBuilder = createKernelServicesBuilder(TestModelType.DOMAIN, stability)
798806
.setBootOperations(bootOperations)
799807
.setModelInitializer(modelInitializer, modelWriteSanitizer);
800808
for (String hash : contentRepositoryHashes) {

core-model-test/framework/src/main/java/org/jboss/as/core/model/test/TestModelControllerService.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
4040
import org.jboss.as.controller.descriptions.NonResolvingResourceDescriptionResolver;
4141
import org.jboss.as.controller.extension.ExtensionRegistry;
42+
import org.jboss.as.controller.operations.common.ProcessEnvironment;
4243
import org.jboss.as.controller.persistence.ExtensibleConfigurationPersister;
4344
import org.jboss.as.controller.persistence.NullConfigurationPersister;
4445
import org.jboss.as.controller.registry.ManagementResourceRegistration;
@@ -80,6 +81,7 @@
8081
import org.jboss.as.server.controller.resources.VersionModelInitializer;
8182
import org.jboss.as.server.suspend.SuspendController;
8283
import org.jboss.as.version.ProductConfig;
84+
import org.jboss.as.version.Stability;
8385
import org.jboss.as.version.Version;
8486
import org.jboss.dmr.ModelNode;
8587
import org.jboss.msc.service.StartContext;
@@ -102,6 +104,7 @@ class TestModelControllerService extends ModelTestModelControllerService {
102104
private final ControlledProcessState processState;
103105
private final ExtensionRegistry extensionRegistry;
104106
private final CapabilityRegistry capabilityRegistry;
107+
private final Stability stability;
105108
private volatile Initializer initializer;
106109

107110
TestModelControllerService(ProcessType processType, RunningModeControl runningModeControl, StringConfigurationPersister persister, ModelTestOperationValidatorFilter validateOpsFilter,
@@ -110,6 +113,7 @@ class TestModelControllerService extends ModelTestModelControllerService {
110113
super(processType, extensionRegistry.getStability(), runningModeControl, null, persister, validateOpsFilter, rootResourceDefinition, processState,
111114
expressionResolver, capabilityRegistry);
112115
this.type = type;
116+
this.stability = extensionRegistry.getStability();
113117
this.runningModeControl = runningModeControl;
114118
this.pathManagerService = type == TestModelType.STANDALONE ? new ServerPathManagerService(capabilityRegistry) : new HostPathManagerService(capabilityRegistry);
115119
this.modelInitializer = modelInitializer;
@@ -191,13 +195,15 @@ private ServerEnvironment createStandaloneServerEnvironment() {
191195
throw new RuntimeException(e);
192196
}
193197
props.put(ServerEnvironment.JBOSS_SERVER_DEFAULT_CONFIG, "standalone.xml");
194-
ProductConfig pc = new ProductConfig("Test", Version.AS_VERSION, "main");
195-
return new ServerEnvironment(null, props, new HashMap<String, String>(), "standalone.xml", null, LaunchType.STANDALONE, runningModeControl.getRunningMode(), pc, false);
198+
props.put(ProcessEnvironment.STABILITY, this.stability.toString());
199+
200+
ProductConfig productConfig = new ProductConfig("Standalone-under-test", Version.AS_VERSION, "main", this.stability);
201+
return new ServerEnvironment(null, props, new HashMap<>(), "standalone.xml", null, LaunchType.STANDALONE, runningModeControl.getRunningMode(), productConfig, false);
196202
}
197203

198204
private HostControllerEnvironment createHostControllerEnvironment() {
199205
try {
200-
Map<String, String> props = new HashMap<String, String>();
206+
Map<String, String> props = new HashMap<>();
201207
File home = new File("target/jbossas");
202208
delete(home);
203209
home.mkdir();
@@ -230,7 +236,11 @@ private HostControllerEnvironment createHostControllerEnvironment() {
230236
RunningMode initialRunningMode = runningModeControl.getRunningMode();
231237
boolean backupDomainFiles = false;
232238
boolean useCachedDc = false;
233-
ProductConfig productConfig = ProductConfig.fromFilesystemSlot(null, "", props);
239+
240+
props.put(ProcessEnvironment.STABILITY, this.stability.toString());
241+
242+
ProductConfig productConfig = new ProductConfig("HostController-under-test", Version.AS_VERSION, "main", this.stability);
243+
234244
return new HostControllerEnvironment(props, isRestart, modulePath, processControllerAddress, processControllerPort,
235245
hostControllerAddress, hostControllerPort, defaultJVM, domainConfig, initialDomainConfig, hostConfig, initialHostConfig,
236246
initialRunningMode, backupDomainFiles, useCachedDc, productConfig);

core-model-test/tests/src/test/java/org/jboss/as/core/model/test/deployment/DomainDeploymentTransformersTestCase.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.jboss.as.model.test.ModelTestUtils;
3131
import org.jboss.dmr.ModelNode;
3232
import org.junit.Assert;
33+
import org.junit.AssumptionViolatedException;
3334
import org.junit.Test;
3435
import org.junit.runner.RunWith;
3536

@@ -66,6 +67,9 @@ public void domainDeployment() throws Exception {
6667
KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
6768
Assert.assertTrue("Legacy services didn't boot for version " + modelVersion, legacyServices.isSuccessfulBoot());
6869
checkCoreModelTransformation(mainServices, modelVersion);
70+
} catch (AssumptionViolatedException ex) {
71+
// If the test is ignored, we want to propagate the exception
72+
throw ex;
6973
} catch (Exception ex) {
7074
throw new RuntimeException("Error for version " + modelVersion + " " + ex.getMessage(), ex);
7175
}
@@ -86,10 +90,13 @@ public void domainExplodedDeployment() throws Exception {
8690

8791
List<ModelNode> operations = builder.parseXmlResource("domain-exploded-deployments.xml");
8892
//removing the ading of "management-client-content" => "rollout-plans
89-
operations = operations.subList(0, operations.size() -2);
93+
operations = operations.subList(0, operations.size() - 2);
9094
ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, operations, getConfig());
95+
} catch (AssumptionViolatedException ex) {
96+
// If the test is ignored, we want to propagate the exception
97+
throw ex;
9198
} catch (Exception ex) {
92-
throw new RuntimeException("Error for version " + modelVersion + " " + ex.getMessage(), ex);
99+
throw new Exception("Error for version " + modelVersion + " " + ex.getMessage(), ex);
93100
}
94101
}
95102

core-model-test/tests/src/test/java/org/jboss/as/core/model/test/util/TransformersTestParameter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public static List<TransformersTestParameter> setupVersions(){
4646
//we only test EAP 7.4 and newer
4747
data.add(new TransformersTestParameter(ModelVersion.create(16, 0, 0), ModelTestControllerVersion.EAP_7_4_0));
4848
data.add(new TransformersTestParameter(ModelVersion.create(22, 0, 0), ModelTestControllerVersion.EAP_8_0_0));
49+
// Requires an update of the wildfly legacy test version
50+
// data.add(new TransformersTestParameter(ModelVersion.create(24, 0, 0), ModelTestControllerVersion.WILDFLY_31_0_0));
4951
return data;
5052
}
5153

0 commit comments

Comments
 (0)