Skip to content

Commit 0d5df8a

Browse files
3.5.x/bug/cherry pick embedded mode its (#3328)
* Execute ITs in embedded mode by default (#3323) * Execute ITs in embedded mode by default * More memory for ITs * more forkJvm Signed-off-by: Olivier Lamy <olamy@apache.org> --------- Signed-off-by: Olivier Lamy <olamy@apache.org> Co-authored-by: Slawomir Jaranowski <s.jaranowski@gmail.com>
1 parent 04ad9a2 commit 0d5df8a

15 files changed

Lines changed: 55 additions & 22 deletions

surefire-its/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@
216216
<forkCount>${its.forkCount}</forkCount>
217217
<threadCount>${its.threadCount}</threadCount>
218218
<perCoreThreadCount>false</perCoreThreadCount>
219-
<argLine>-server -Xmx64m -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Djava.awt.headless=true -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
219+
<argLine>-Xmx512m -XX:+UseG1GC -Djava.awt.headless=true -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
220220
<!-- Pass current surefire version to the main suite so that it -->
221221
<!-- can forward to all integration test projects. SUREFIRE-513 -->
222222
<systemPropertyVariables>

surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private OutputValidator prepare(String description, String profile, Map<String,
9595
if (failures != 0 || errors != 0) {
9696
launcher.withFailure();
9797
}
98-
98+
launcher.setForkJvm(true);
9999
return launcher.sysProp(properties).executeTest();
100100
}
101101

surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractTestMultipleMethodPatterns.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ protected SurefireLauncher prepare(String tests) {
6464
throw new IllegalArgumentException(
6565
"Unsupported configuration " + getSettings().getConfiguration());
6666
}
67+
launcher.setForkJvm();
6768
return launcher;
6869
}
6970

@@ -105,6 +106,7 @@ public void simpleNameTestAsParallel() {
105106
assumeThat(getSettings().getFramework(), anyOf(is(JUNIT47), is(TestNG)));
106107
prepare("TestTwo")
107108
.parallel("classes")
109+
.setForkJvm()
108110
.useUnlimitedThreads()
109111
.executeTest()
110112
.verifyErrorFree(2)

surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public void shouldNotBeVerbose() throws Exception {
5555
@Test
5656
public void shouldBeVerbose() throws Exception {
5757
unpack("/testng-simple")
58+
.setForkJvm()
5859
.sysProp("testNgVersion", "5.10")
5960
.sysProp("testNgClassifier", "jdk15")
6061
.sysProp("surefire.testng.verbose", "10")

surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountIT.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static void installDumpPidPlugin() {
4949

5050
@Test
5151
public void testForkNever() {
52-
String[] pids = doTest(unpack(getProject()).forkNever());
52+
String[] pids = doTest(unpack(getProject()).setForkJvm().forkNever());
5353
assertSamePids(pids);
5454
assertEndWith(pids, "_1_1", 3);
5555
assertEquals("my pid is equal to pid 1 of the test", getMainPID(), pids[0]);
@@ -69,6 +69,7 @@ public void testForkOncePerThreadSingleThread() {
6969
public void testForkOncePerThreadTwoThreads() {
7070
int threadCount = 2;
7171
String[] pids = doTest(unpack(getProject())
72+
.setForkJvm()
7273
.forkPerThread(threadCount)
7374
.threadCount(threadCount)
7475
.addGoal("-DsleepLength=7200"));
@@ -102,8 +103,8 @@ public void testForkCountTwoNoReuse() {
102103

103104
@Test
104105
public void testForkCountTwoReuse() {
105-
String[] pids =
106-
doTest(unpack(getProject()).forkCount(2).reuseForks(true).addGoal("-DsleepLength=7200"));
106+
String[] pids = doTest(
107+
unpack(getProject()).setForkJvm().forkCount(2).reuseForks(true).addGoal("-DsleepLength=7200"));
107108
assertDifferentPids(pids, 2);
108109
assertNotEquals("pid 1 is not the same as the main process' pid", pids[0], getMainPID());
109110
}
@@ -126,7 +127,7 @@ private void assertDifferentPids(String[] pids, int numOfDifferentPids) {
126127

127128
@Test
128129
public void testForkOnce() {
129-
String[] pids = doTest(unpack(getProject()).forkOnce());
130+
String[] pids = doTest(unpack(getProject()).setForkJvm().forkOnce());
130131
assertSamePids(pids);
131132
assertNotEquals("pid 1 is not the same as the main process' pid", pids[0], getMainPID());
132133
}

surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ public void testCategoriesABForkAlways() {
4141

4242
@Test
4343
public void testCategoriesACFullyQualifiedClassName() {
44-
runACFullyQualifiedClassName(unpacked());
44+
runACFullyQualifiedClassName(unpacked().setForkJvm());
4545
}
4646

4747
@Test
4848
public void testCategoriesACFullyQualifiedClassNameForkAlways() {
49-
runACFullyQualifiedClassName(unpacked().forkAlways());
49+
runACFullyQualifiedClassName(unpacked().setForkJvm().forkAlways());
5050
}
5151

5252
@Test
5353
public void testCategoriesACClassNameSuffix() {
54-
runACClassNameSuffix(unpacked());
54+
runACClassNameSuffix(unpacked().setForkJvm());
5555
}
5656

5757
@Test
5858
public void testCategoriesACClassNameSuffixForkAlways() {
59-
runACClassNameSuffix(unpacked().forkAlways());
59+
runACClassNameSuffix(unpacked().setForkJvm().forkAlways());
6060
}
6161

6262
@Test

surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4IgnoreIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public void testJunit4Ignore() {
3737
@Test
3838
public void testJunit47ParallelIgnore() {
3939
unpack().setJUnitVersion("4.8.1")
40+
.setForkJvm()
4041
.parallelClasses()
4142
.executeTest()
4243
.verifyErrorFreeLog()

surefire-its/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodPatternsIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ protected Settings getSettings() {
5656

5757
@Override
5858
protected SurefireLauncher unpack() {
59-
return unpack("junit48-multiple-method-patterns", "_" + settings.path());
59+
return unpack("junit48-multiple-method-patterns", "_" + settings.path()).setForkJvm();
6060
}
6161
}

surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ public final class MavenLauncher {
6969

7070
private boolean expectFailure;
7171

72+
private boolean forkJvm;
73+
7274
MavenLauncher(Class<?> testClass, String resourceName, String suffix, String[] cli) {
7375
this.testCaseBeingRun = testClass;
7476
this.resourceName = resourceName;
7577
this.suffix = suffix != null ? suffix : "";
7678
this.cli = cli == null ? null : cli.clone();
79+
// by default use embedded mode
80+
this.forkJvm = false;
7781
resetGoals();
7882
resetCliOptions();
7983
}
@@ -264,6 +268,11 @@ public OutputValidator executeCurrentGoals() {
264268
getVerifier().addCliArguments(goals.toArray(new String[] {}));
265269
getVerifier().setSystemProperties(props);
266270
getVerifier().setEnvironmentVariables(envVars);
271+
if (envVars.isEmpty()) {
272+
getVerifier().setForkJvm(forkJvm);
273+
} else {
274+
getVerifier().setForkJvm(true);
275+
}
267276
getVerifier().execute();
268277
return getValidator();
269278
} catch (VerificationException e) {
@@ -318,7 +327,7 @@ public OutputValidator getValidator() {
318327
}
319328

320329
public void setForkJvm(boolean forkJvm) {
321-
getVerifier().setForkJvm(forkJvm);
330+
this.forkJvm = forkJvm;
322331
}
323332

324333
public String getLocalRepository() {

surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1053SystemPropertiesIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
public class Surefire1053SystemPropertiesIT extends SurefireJUnit4IntegrationTestCase {
3434
@Test
3535
public void checkWarningsFileEncoding() {
36-
unpack().sysProp("file.encoding", "ISO-8859-1")
36+
unpack().setForkJvm()
37+
.sysProp("file.encoding", "ISO-8859-1")
3738
.executeTest()
3839
.verifyErrorFree(1)
3940
.verifyTextInLog("file.encoding cannot be set as system property, use <argLine>-D"

0 commit comments

Comments
 (0)