Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
~ under the License.
-->
<extensions>
<extension>
<!--extension>
<groupId>eu.maveniverse.maven.mimir</groupId>
<artifactId>extension3</artifactId>
<version>0.11.2</version>
</extension>
</extension-->
<!--
cannot use the cache because of shaded artifact surefire-shared-utils
the primary artifact is in the cache but the shaded one is not replacing it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
package org.apache.maven.plugin.surefire.booterclient;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.maven.surefire.api.booter.Shutdown;
import org.apache.maven.surefire.api.cli.CommandLineOption;
import org.apache.maven.surefire.api.report.ReporterConfiguration;
Expand All @@ -45,18 +46,17 @@
import org.apache.maven.surefire.booter.PropertiesWrapper;
import org.apache.maven.surefire.booter.ProviderConfiguration;
import org.apache.maven.surefire.booter.StartupConfiguration;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import static org.apache.maven.surefire.api.cli.CommandLineOption.LOGGING_LEVEL_DEBUG;
import static org.apache.maven.surefire.api.cli.CommandLineOption.REACTOR_FAIL_FAST;
import static org.apache.maven.surefire.api.cli.CommandLineOption.SHOW_ERRORS;
import static org.apache.maven.surefire.booter.ProcessCheckerType.ALL;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Performs roundtrip testing of serialization/deserialization of The StartupConfiguration
Expand All @@ -65,44 +65,29 @@
*/
public class BooterDeserializerStartupConfigurationTest {

private static int idx = 0;

private File basedir;

private final ClasspathConfiguration classpathConfiguration = createClasspathConfiguration();

private final List<CommandLineOption> cli = Arrays.asList(LOGGING_LEVEL_DEBUG, SHOW_ERRORS, REACTOR_FAIL_FAST);

@BeforeEach
public void setupDirectories() throws IOException {
File target = new File(System.getProperty("user.dir"), "target");
basedir = new File(target, "BooterDeserializerProviderConfigurationTest-" + ++idx);
FileUtils.deleteDirectory(basedir);
assertTrue(basedir.mkdirs());
}

@AfterEach
public void deleteDirectories() throws IOException {
FileUtils.deleteDirectory(basedir);
}

@Test
public void testProvider() throws IOException {
assertEquals("com.provider", getReloadedStartupConfiguration().getProviderClassName());
public void testProvider(@TempDir Path tempDir) throws IOException {
assertEquals(
"com.provider",
getReloadedStartupConfiguration(tempDir.toFile()).getProviderClassName());
}

@Test
public void testClassPathConfiguration() throws IOException {
public void testClassPathConfiguration(@TempDir Path tempDir) throws IOException {
AbstractPathConfiguration reloadedClasspathConfiguration =
getReloadedStartupConfiguration().getClasspathConfiguration();
getReloadedStartupConfiguration(tempDir.toFile()).getClasspathConfiguration();

assertTrue(reloadedClasspathConfiguration instanceof ClasspathConfiguration);
assertInstanceOf(ClasspathConfiguration.class, reloadedClasspathConfiguration);
assertCpConfigEquals(classpathConfiguration, (ClasspathConfiguration) reloadedClasspathConfiguration);
}

@Test
public void testProcessChecker() throws IOException {
assertEquals(ALL, getReloadedStartupConfiguration().getProcessChecker());
public void testProcessChecker(@TempDir Path tempDir) throws IOException {
assertEquals(ALL, getReloadedStartupConfiguration(tempDir.toFile()).getProcessChecker());
}

private void assertCpConfigEquals(
Expand All @@ -117,32 +102,34 @@ private void assertCpConfigEquals(
}

@Test
public void testClassLoaderConfiguration() throws IOException {
assertFalse(getReloadedStartupConfiguration().isManifestOnlyJarRequestedAndUsable());
public void testClassLoaderConfiguration(@TempDir Path tempDir) throws IOException {
assertFalse(getReloadedStartupConfiguration(tempDir.toFile()).isManifestOnlyJarRequestedAndUsable());
}

@Test
public void testClassLoaderConfigurationTrues() throws IOException {
public void testClassLoaderConfigurationTrues(@TempDir Path tempDir) throws IOException {
final StartupConfiguration testStartupConfiguration =
getTestStartupConfiguration(getManifestOnlyJarForkConfiguration());
boolean current = testStartupConfiguration.isManifestOnlyJarRequestedAndUsable();
assertEquals(current, saveAndReload(testStartupConfiguration).isManifestOnlyJarRequestedAndUsable());
assertEquals(
current,
saveAndReload(testStartupConfiguration, tempDir.toFile()).isManifestOnlyJarRequestedAndUsable());
}

@Test
public void testProcessCheckerAll() throws IOException {
assertEquals(ALL, getReloadedStartupConfiguration().getProcessChecker());
public void testProcessCheckerAll(@TempDir Path tempDir) throws IOException {
assertEquals(ALL, getReloadedStartupConfiguration(tempDir.toFile()).getProcessChecker());
}

@Test
public void testProcessCheckerNull() throws IOException {
public void testProcessCheckerNull(@TempDir Path tempDir) throws IOException {
StartupConfiguration startupConfiguration = new StartupConfiguration(
"com.provider",
classpathConfiguration,
getManifestOnlyJarForkConfiguration(),
null,
Collections.<String[]>emptyList());
assertNull(saveAndReload(startupConfiguration).getProcessChecker());
Collections.emptyList());
assertNull(saveAndReload(startupConfiguration, tempDir.toFile()).getProcessChecker());
}

private ClasspathConfiguration createClasspathConfiguration() {
Expand All @@ -159,14 +146,15 @@ private static ClassLoaderConfiguration getManifestOnlyJarForkConfiguration() {
return new ClassLoaderConfiguration(true, true);
}

private StartupConfiguration getReloadedStartupConfiguration() throws IOException {
private StartupConfiguration getReloadedStartupConfiguration(File basedir) throws IOException {
ClassLoaderConfiguration classLoaderConfiguration = getSystemClassLoaderConfiguration();
return saveAndReload(getTestStartupConfiguration(classLoaderConfiguration));
return saveAndReload(getTestStartupConfiguration(classLoaderConfiguration), basedir);
}

private StartupConfiguration saveAndReload(StartupConfiguration startupConfiguration) throws IOException {
private StartupConfiguration saveAndReload(StartupConfiguration startupConfiguration, File basedir)
throws IOException {
final ForkConfiguration forkConfiguration = ForkConfigurationTest.getForkConfiguration(basedir, null);
PropertiesWrapper props = new PropertiesWrapper(new HashMap<String, String>());
PropertiesWrapper props = new PropertiesWrapper(new HashMap<>());
BooterSerializer booterSerializer = new BooterSerializer(forkConfiguration);
String aTest = "aTest";
File propsTest = booterSerializer.serialize(
Expand All @@ -178,10 +166,12 @@ private StartupConfiguration saveAndReload(StartupConfiguration startupConfigura
null,
1,
"tcp://localhost:63003");
BooterDeserializer booterDeserializer = new BooterDeserializer(new FileInputStream(propsTest));
assertNull(booterDeserializer.getPluginPid());
assertEquals("tcp://localhost:63003", booterDeserializer.getConnectionString());
return booterDeserializer.getStartupConfiguration();
try (InputStream inputStream = Files.newInputStream(propsTest.toPath())) {
BooterDeserializer booterDeserializer = new BooterDeserializer(inputStream);
assertNull(booterDeserializer.getPluginPid());
assertEquals("tcp://localhost:63003", booterDeserializer.getConnectionString());
return booterDeserializer.getStartupConfiguration();
}
}

private ProviderConfiguration getProviderConfiguration() {
Expand All @@ -199,7 +189,7 @@ private ProviderConfiguration getProviderConfiguration() {
reporterConfiguration,
new TestArtifactInfo("5.0", "ABC"),
testSuiteDefinition,
new HashMap<String, String>(),
new HashMap<>(),
BooterDeserializerProviderConfigurationTest.TEST_TYPED,
true,
cli,
Expand All @@ -210,11 +200,7 @@ private ProviderConfiguration getProviderConfiguration() {

private StartupConfiguration getTestStartupConfiguration(ClassLoaderConfiguration classLoaderConfiguration) {
return new StartupConfiguration(
"com.provider",
classpathConfiguration,
classLoaderConfiguration,
ALL,
Collections.<String[]>emptyList());
"com.provider", classpathConfiguration, classLoaderConfiguration, ALL, Collections.emptyList());
}

private File getTestSourceDirectory() {
Expand Down
14 changes: 14 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@

<properties>
<javaVersion>8</javaVersion>
<junit.jupiter.execution.parallel.config.dynamic.factor>0.8</junit.jupiter.execution.parallel.config.dynamic.factor>
<junit.jupiter.execution.parallel.config.fixed.parallelism>2</junit.jupiter.execution.parallel.config.fixed.parallelism>
<junit.jupiter.execution.parallel.config.strategy>dynamic</junit.jupiter.execution.parallel.config.strategy>
<junit.jupiter.execution.parallel.enabled>true</junit.jupiter.execution.parallel.enabled>
<junit.jupiter.execution.parallel.mode.classes.default>concurrent</junit.jupiter.execution.parallel.mode.classes.default>
<junit.jupiter.execution.parallel.mode.default>same_thread</junit.jupiter.execution.parallel.mode.default>
<mavenVersion>3.6.3</mavenVersion>
<resolverVersion>1.4.1</resolverVersion>
<commonsLang3Version>3.20.0</commonsLang3Version>
Expand Down Expand Up @@ -303,6 +309,14 @@
<version>3.5.2</version>
<!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
<configuration>
<properties>
<configurationParameters>junit.jupiter.execution.parallel.enabled=${junit.jupiter.execution.parallel.enabled}
junit.jupiter.execution.parallel.mode.default=${junit.jupiter.execution.parallel.mode.default}
junit.jupiter.execution.parallel.mode.classes.default=${junit.jupiter.execution.parallel.mode.classes.default}
junit.jupiter.execution.parallel.config.strategy=${junit.jupiter.execution.parallel.config.strategy}
junit.jupiter.execution.parallel.config.fixed.parallelism=${junit.jupiter.execution.parallel.config.fixed.parallelism}
junit.jupiter.execution.parallel.config.dynamic.factor=${junit.jupiter.execution.parallel.config.dynamic.factor}</configurationParameters>
</properties>
<!-- NOTE: Be sure to isolate the Surefire version under test from the version running the tests! -->
<useSystemClassLoader>false</useSystemClassLoader>
<argLine>${jvm.args.tests}</argLine>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.maven.surefire.api.util.SureFireFileManager;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.parallel.Isolated;

import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
Expand All @@ -45,6 +46,7 @@
* Tests for {@link ForkedBooter}.
*/
@SuppressWarnings("checkstyle:magicnumber")
@Isolated
public class ForkedBooterTest {

private static Object invokeMethod(Class<?> clazz, String methodName, Object... args) throws Exception {
Expand Down
71 changes: 44 additions & 27 deletions surefire-its/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<surefire.rerunFailingTestsCount>0</surefire.rerunFailingTestsCount>
<its.forkCount>0.5C</its.forkCount>
<its.threadCount>1</its.threadCount>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.install.skip>true</maven.install.skip>
<maven.javadoc.skip>true</maven.javadoc.skip>
<junit.vintage.execution.parallel.enabled>false</junit.vintage.execution.parallel.enabled>
<junit.vintage.execution.parallel.classes>false</junit.vintage.execution.parallel.classes>
<junit.vintage.execution.parallel.methods>false</junit.vintage.execution.parallel.methods>
<junit.vintage.execution.parallel.pool>5</junit.vintage.execution.parallel.pool>
<maven.clean.fast>true</maven.clean.fast>
<!-- can be 'fixed' or 'dynamic` -->
<junit.jupiter.execution.parallel.config.strategy>fixed</junit.jupiter.execution.parallel.config.strategy>
<junit.jupiter.execution.parallel.config.fixed.parallelism>2</junit.jupiter.execution.parallel.config.fixed.parallelism>
<junit.jupiter.execution.parallel.config.dynamic.factor>0.2</junit.jupiter.execution.parallel.config.dynamic.factor>
<junit.jupiter.execution.parallel.config.dynamic.max-pool-size-factor>0.2</junit.jupiter.execution.parallel.config.dynamic.max-pool-size-factor>
<junit.jupiter.execution.parallel.config.fixed.max-pool-size>4</junit.jupiter.execution.parallel.config.fixed.max-pool-size>
</properties>

<dependencies>
Expand All @@ -59,18 +59,18 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-surefire-plugin</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- <scope>runtime</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-failsafe-plugin</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- <scope>runtime</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-verifier</artifactId>
Expand Down Expand Up @@ -232,16 +232,17 @@
<!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
<configuration>
<properties>
<configurationParameters>junit.vintage.execution.parallel.enabled=${junit.vintage.execution.parallel.enabled}
junit.vintage.execution.parallel.classes=${junit.vintage.execution.parallel.classes}
junit.vintage.execution.parallel.methods=${junit.vintage.execution.parallel.methods}
junit.vintage.execution.parallel.pool-size=${junit.vintage.execution.parallel.pool}</configurationParameters>
<configurationParameters>junit.jupiter.execution.parallel.enabled=${junit.jupiter.execution.parallel.enabled}
junit.jupiter.execution.parallel.mode.default=${junit.jupiter.execution.parallel.mode.default}
junit.jupiter.execution.parallel.mode.classes.default=${junit.jupiter.execution.parallel.mode.classes.default}
junit.jupiter.execution.parallel.config.strategy=${junit.jupiter.execution.parallel.config.strategy}
junit.jupiter.execution.parallel.config.fixed.parallelism=${junit.jupiter.execution.parallel.config.fixed.parallelism}
junit.jupiter.execution.parallel.config.fixed.max-pool-size=${junit.jupiter.execution.parallel.config.fixed.max-pool-size}
junit.jupiter.execution.parallel.config.dynamic.factor=${junit.jupiter.execution.parallel.config.dynamic.factor}</configurationParameters>
</properties>
<skipTests>${skipTests}</skipTests>
<runOrder>alphabetical</runOrder>
<forkCount>${its.forkCount}</forkCount>
<threadCount>${its.threadCount}</threadCount>
<perCoreThreadCount>false</perCoreThreadCount>
<forkCount>1</forkCount>
<argLine>-Xmx128m -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Djava.awt.headless=true -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
<!-- Pass current surefire version to the main suite so that it -->
<!-- can forward to all integration test projects. SUREFIRE-513 -->
Expand All @@ -258,6 +259,18 @@
<!-- <forkedProcessTimeoutInSeconds>5400</forkedProcessTimeoutInSeconds> -->
<shutdown>kill</shutdown>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.14.3</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
<version>1.14.3</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
Expand Down Expand Up @@ -289,9 +302,10 @@
<profile>
<id>apache.ci</id>
<properties>
<its.forkCount>0.4C</its.forkCount>
<its.threadCount>1</its.threadCount>
<surefire.rerunFailingTestsCount>1</surefire.rerunFailingTestsCount>
<junit.jupiter.execution.parallel.config.strategy>fixed</junit.jupiter.execution.parallel.config.strategy>
<junit.jupiter.execution.parallel.config.fixed.parallelism>3</junit.jupiter.execution.parallel.config.fixed.parallelism>
<junit.jupiter.execution.parallel.config.fixed.max-pool-size>4</junit.jupiter.execution.parallel.config.fixed.max-pool-size>
</properties>
</profile>
<profile>
Expand All @@ -302,6 +316,9 @@
</property>
</activation>
<properties>
<junit.jupiter.execution.parallel.config.fixed.parallelism>4</junit.jupiter.execution.parallel.config.fixed.parallelism>
<junit.jupiter.execution.parallel.config.strategy>fixed</junit.jupiter.execution.parallel.config.strategy>
<junit.jupiter.execution.parallel.config.fixed.max-pool-size>4</junit.jupiter.execution.parallel.config.fixed.max-pool-size>
<!-- workaround for SUREFIRE-2269 -->
<maven.clean.failOnError>false</maven.clean.failOnError>
<maven.clean.verbose>true</maven.clean.verbose>
Expand Down
Loading