Skip to content
Permalink
Browse files

[WFLY-11896] Improve ability of mixed-domain testsuite to deal with d…

…ifferent JVMs

MisxedDomainTestSupport will trigger caller (i.e a TestSuite) being ignored if the version under test can't handle the JVMs on offer.

Test jobs can be configured with different java home paths for different JVMs. If this is done MixedDomainTestSupport will try and use an appropriate one for the legacy host.
  • Loading branch information
bstansberry committed Mar 23, 2019
1 parent 5429efb commit 50968bcc587695ab9cf4b5c22dded03d4c62b368
@@ -199,8 +199,28 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<jboss.test.host.slave.jvmhome>${java8.home}</jboss.test.host.slave.jvmhome>
<jboss.test.host.slave.controller.jvmhome>${java8.home}</jboss.test.host.slave.controller.jvmhome>
<jboss.test.legacy.host.java8.home>${java8.home}</jboss.test.legacy.host.java8.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>legacy-slave-java11-home</id>
<activation>
<jdk>[12,)</jdk>
<property>
<name>java11.home</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<jboss.test.legacy.host.java11.home>${java11.home}</jboss.test.legacy.host.java11.home>
</systemPropertyVariables>
</configuration>
</plugin>
@@ -68,7 +68,7 @@ protected static MixedDomainTestSupport getSupport(Class<?> testClass) {
return getSupport(testClass, Profile.FULL_HA, false);
}

protected static MixedDomainTestSupport getSupport(Class<?> testClass, boolean withMasterServers) {
protected static MixedDomainTestSupport getSupport(Class<?> testClass, boolean withMasterServers) {
return getSupport(testClass, Profile.FULL_HA, withMasterServers);
}

@@ -79,6 +79,7 @@ protected static MixedDomainTestSupport getSupport(Class<?> testClass, Profile p
}
return support;
}

/**
* Call this from a @BeforeClass method
*
@@ -91,6 +92,7 @@ protected static MixedDomainTestSupport getSupport(Class<?> testClass, String ma
protected static MixedDomainTestSupport getSupport(Class<?> testClass, String masterConfig, boolean adjustDomain, boolean legacyConfig, boolean withMasterServers) {
return getSupport(testClass, masterConfig, null, Profile.FULL_HA, adjustDomain, legacyConfig, withMasterServers);
}

/**
* Call this from a @BeforeClass method
*
@@ -147,7 +149,8 @@ static MixedDomainTestSupport getSupport(Class<?> testClass, String domainConfig
testSupport = MixedDomainTestSupport.create(testClass.getSimpleName(), version);
}
} catch (Exception e) {
throw new RuntimeException(e);
MixedDomainTestSuite.version = null;
throw (e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e));
}
try {
//Start the the domain with adjustments to domain.xml
@@ -43,6 +43,7 @@
import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.dmr.ModelNode;
import org.junit.Assert;
import org.junit.Assume;


/**
@@ -52,6 +53,12 @@

public static final String STANDARD_DOMAIN_CONFIG = "copied-master-config/domain.xml";
private static final String JBOSS_DOMAIN_SERVER_ARGS = "jboss.domain.server.args";
private static final int TEST_VM_VERSION;

static {
String spec = System.getProperty("java.specification.version");
TEST_VM_VERSION = "1.8".equals(spec) ? 8 : Integer.parseInt(spec);
}

private final Version.AsVersion version;
private final boolean adjustDomain;
@@ -69,6 +76,7 @@ private MixedDomainTestSupport(Version.AsVersion version, String testClass, Stri
this.legacyConfig = legacyConfig;
this.withMasterServers = withMasterServers;
this.profile = profile;
configureSlaveJavaHome();
}

private static WildFlyManagedConfiguration configWithDisabledAsserts(String jbossHome){
@@ -158,6 +166,29 @@ private void startSlaveServer() {
Assert.fail("Slave server-one did not start within " + timeout + " ms");
}

private void configureSlaveJavaHome() {
// Look for properties pointing to a java home to use for the legacy host.
// Look for homes for the max JVM version the host can handle, working back to the min it can handle.
// We could start with the oldest and work forward, but that would likely result in all versions testing
// against the oldest VM. Starting with the newest will increase coverage by increasing the probability
// of different VM versions being used across the overall set of legacy host versions.
String javaHome = null;
for (int i = Math.min(version.getMaxVMVersion(), TEST_VM_VERSION - 1); i >= version.getMinVMVersion() && javaHome == null; i--) {
javaHome = System.getProperty("jboss.test.legacy.host.java" + i + ".home");
}

if (javaHome != null) {
WildFlyManagedConfiguration cfg = getDomainSlaveConfiguration();
cfg.setJavaHome(javaHome);
cfg.setControllerJavaHome(javaHome);
System.out.println("Set legacy host controller to use " + javaHome + " as JAVA_HOME");
} else {
// Ignore the test if the slave cannot run using the current VM version
Assume.assumeTrue(TEST_VM_VERSION <= version.getMaxVMVersion());
Assume.assumeTrue(TEST_VM_VERSION >= version.getMinVMVersion());
}
}

private void startAndAdjust() {

String jbossDomainServerArgsValue = null;
@@ -21,6 +21,8 @@
*/
package org.jboss.as.test.integration.domain.mixed;

import org.junit.Assume;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -41,10 +43,10 @@
String EAP = "jboss-eap-";

enum AsVersion {
EAP_6_4_0(EAP, 6, 4, 0),
EAP_7_0_0(EAP, 7, 0, 0),
EAP_7_1_0(EAP, 7, 1, 0),
EAP_7_2_0(EAP, 7, 2, 0),
EAP_6_4_0(EAP, 6, 4, 0, 8, 8),
EAP_7_0_0(EAP, 7, 0, 0, 8, 8),
EAP_7_1_0(EAP, 7, 1, 0, 8, 8),
EAP_7_2_0(EAP, 7, 2, 0, 11, 8),
;


@@ -53,14 +55,18 @@
private final int major;
private final int minor;
private final int micro;
private final int maxVM;
private final int minVM;
final String version;

AsVersion(String basename, int major, int minor, int micro){
AsVersion(String basename, int major, int minor, int micro, int maxVM, int minVM){
this.basename = basename;
this.major = major;
this.minor = minor;
this.micro = micro;
this.version = major + "." + minor + "." + micro;
this.maxVM = maxVM;
this.minVM = minVM;
}

public String getBaseName() {
@@ -99,6 +105,34 @@ public int getMicro() {
return micro;
}

/**
* Gets the maximum Java version under which a legacy host can properly
* execute tests.
*/
public int getMaxVMVersion() {
return maxVM;
}

/**
* Gets the minimum Java version under which a legacy host can properly
* execute tests.
*/
public int getMinVMVersion() {
return minVM;
}

/**
* Checks whether the current VM version exceeds the maximum version under which a legacy host can properly
* execute tests. The check is disabled if system property "jboss.test.host.slave.jvmhome" is set.
*/
public void assumeMaxVM() {
if (System.getProperty("jboss.test.host.slave.jvmhome") == null) {
String javaSpecVersion = System.getProperty("java.specification.version");
int vm = "1.8".equals(javaSpecVersion) ? 8 : Integer.parseInt(javaSpecVersion);
Assume.assumeFalse(vm > maxVM);
}
}

int compare(int major, int minor) {
if (this.major < major) {
return -1;
@@ -36,6 +36,7 @@

@BeforeClass
public static void initializeDomain() {
Version.AsVersion.EAP_6_4_0.assumeMaxVM();
ElytronOnlyMasterTestSuite.getSupport(ElytronOnlyMaster640TestSuite.class);
}
}

0 comments on commit 50968bc

Please sign in to comment.
You can’t perform that action at this time.