Skip to content

Commit

Permalink
feat: Introduced additonal parallelism to the test suite execution
Browse files Browse the repository at this point in the history
* the test-bed build uses Maven parallelism with 50 threads per cpu core
* the same is used for build invocation on Travis (could be used locally)
* the Travis is building in three virtual machines at once:
  * one for unit tests
  * one for functional tests - to separate unit tests and functional tests I had to introduce two profiles inside of the pom files
  * one for generating documentation - no to do it in the previous builds/vm twice
* speeding up Java startup using properties: -XX:+TieredCompilation -XX:TieredStopAtLevel=1
  • Loading branch information
MatousJobanek committed Oct 11, 2017
1 parent 09c84d0 commit 52d5817
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 23 deletions.
31 changes: 22 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ cache:
directories:
- $HOME/.m2

env:
- TEST_SUITE=units GENERATE_DOC=1
- TEST_SUITE=functional TEST_BED_M2_HOME=/home/travis/.arquillian/mvn/apache-maven-3.3.9 GENERATE_DOC=1
- GENERATE_DOC=0

before_install:
- BRANCH=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}
- MODIFIED_DOCS=$(git diff --name-only $TRAVIS_COMMIT_RANGE | grep -E 'README.adoc|^docs/.*.adoc$' | wc -l)
- COMMITS_WITH_FORCED_GEN=$(git log --format=%B $TRAVIS_COMMIT_RANGE | grep -i "\[gen docs\]" | wc -l)
- git describe --tags --exact-match HEAD >/dev/null 2>&1 && TAGGED=0 || TAGGED=1
- '[ $TAGGED -eq 0 ] || [ $COMMITS_WITH_FORCED_GEN -gt 0 ] || [ $MODIFIED_DOCS -ge 1 ] && GENERATE_DOC=0 || GENERATE_DOC=1'
- '[ "${BRANCH}" == "master" ] && [ "${TRAVIS_REPO_SLUG}" == "arquillian/smart-testing" ] || [ ! -z "${TRAVIS_PULL_REQUEST// }" -a "${TRAVIS_PULL_REQUEST}" != "false" ] && GENERATE_DOC=0 || GENERATE_DOC=1'
<<<<<<< 09c84d03175f87a1fa19fceff84d2d5f5da47b34
- '[ $TAGGED -eq 0 ] || [ $COMMITS_WITH_FORCED_GEN -gt 0 ] || [ $MODIFIED_DOCS -ge 1 ] && [ $GENERATE_DOC -eq 0 ] && GENERATE_DOC=0 || GENERATE_DOC=1'
- '[ "${BRANCH}" == "master" ] && [ "${TRAVIS_REPO_SLUG}" == "arquillian/smart-testing" ] || [ ! -z "${TRAVIS_PULL_REQUEST// }" -a "${TRAVIS_PULL_REQUEST}" != "false" ] && [ $GENERATE_DOC -eq 0 ] && GENERATE_DOC=0 || GENERATE_DOC=1'
- 'if [ $GENERATE_DOC -eq 0 ]; then
git config user.name "${GH_USER}";
git config user.email "${GH_EMAIL}";
Expand All @@ -34,6 +40,11 @@ before_install:
docker pull rochdev/alpine-asciidoctor:mini;
fi'

install:
- 'if [[ -n $TEST_SUITE ]]; then
./mvnw clean install -DskipTests;
fi'

before_script:
- mkdir -p /home/travis/.arquillian/mvn
- wget https://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz -P /home/travis/.arquillian/resolver/maven/download
Expand Down Expand Up @@ -61,14 +72,16 @@ before_script:
fi
'

env:
- TEST_BED_M2_HOME=/home/travis/.arquillian/mvn/apache-maven-3.3.9

script:
- ./mvnw clean verify -P travis -DJAVA_OPTS="-XX:-UseLoopPredicate"
- 'if [ $GENERATE_DOC -eq 0 ]; then
./.asciidoctor/generate.sh --keep;
fi'
- 'if [[ -n $TEST_SUITE ]]; then
if [[ "$TEST_SUITE" == "units" ]]; then
./mvnw clean package -P travis -DJAVA_OPTS="-XX:-UseLoopPredicate" -T 100;
else
./mvnw clean verify -pl functional-tests/test-bed -P travis -DJAVA_OPTS="-XX:-UseLoopPredicate" -T 100;
fi
elif [ $GENERATE_DOC -eq 0 ]; then
./.asciidoctor/generate.sh --keep;
fi'

after_success:
- 'if [ $GENERATE_DOC -eq 0 ]; then
Expand Down
1 change: 0 additions & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@
<version>${version.snakeyaml}</version>
</dependency>
</dependencies>

</project>
1 change: 0 additions & 1 deletion functional-tests/git-rules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@
<scope>test</scope>
</dependency>
</dependencies>

</project>
47 changes: 46 additions & 1 deletion functional-tests/test-bed/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,52 @@
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${version.surefire}</version>
<executions>
<execution>
<id>default-test</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<forkCount>${surefire.fork.count}</forkCount>
<threadCount>${surefire.thread.count}</threadCount>
<reuseForks>${surefire.reuse.forks}</reuseForks>
<argLine>-Xmx1024m</argLine>
<parallel>classesAndMethods</parallel>
<excludedGroups>net.jcip.annotations.NotThreadSafe</excludedGroups>
</configuration>
</execution>
<execution>
<id>not-thread-safe</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<reuseForks>false</reuseForks>
<groups>net.jcip.annotations.NotThreadSafe</groups>
</configuration>
</execution>
</executions>
<configuration>
<includes>
<include>**/*Test.java</include>
<include>**/Test*.java</include>
<include>**/*TestCase.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ public class BuildConfigurator {
private boolean ignoreBuildFailure = false;
private boolean skipTests = false;
private File workingDirectory;
private String mavenOpts = "-Xms512m -Xmx1024m";
private String mavenOpts = "-Xms512m -Xmx1024m -XX:+TieredCompilation -XX:TieredStopAtLevel=1";
private String mavenVersion;
private Using usingInstallation;
private boolean useThreads = true;

BuildConfigurator(ProjectBuilder projectBuilder) {
systemProperties.put("surefire.exitTimeout", "-1"); // see http://bit.ly/2vARQ5p
Expand Down Expand Up @@ -183,11 +184,16 @@ public BuildConfigurator excludeProjects(String... projects) {
return this;
}

public BuildConfigurator useMavenVersion(String mavenVersion){
public BuildConfigurator useMavenVersion(String mavenVersion) {
this.mavenVersion = mavenVersion;
return this;
}

public BuildConfigurator useThreads(boolean useThreads){
this.useThreads = useThreads;
return this;
}

void enableDebugOptions() {
if (isRemoteDebugEnabled()) {
final String debugOptions = String.format(MVN_DEBUG_AGENT, shouldSuspend(), getRemotePort());
Expand Down Expand Up @@ -268,6 +274,10 @@ String getMavenVersion() {
return mavenVersion;
}

boolean useThreads(){
return useThreads;
}

private int getAvailableLocalPort() {
ServerSocket socket = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private BuiltProject executeGoals(String... goals) {
final BuiltProject build = embeddedMaven
.setShowVersion(true)
.setGoals(goals)
.setThreads(buildConfigurator.useThreads() ? "50C" : null)
.setProjects(buildConfigurator.getModulesToBeBuilt())
.setDebug(buildConfigurator.isMavenDebugOutputEnabled())
.setQuiet(buildConfigurator.disableQuietWhenAnyDebugModeEnabled() && buildConfigurator.isQuietMode())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void test_with_reuse_forks_false() {

@Test
public void test_with_fork_count_zero() {
verifyTestSuiteExecution("forkCount", "0");
verifyTestSuiteExecution(false, "forkCount", "0");
}

@Test
Expand All @@ -57,10 +57,14 @@ public void test_with_multiple_forks_not_reusing_forks() {

@Test
public void test_with_fork_count_zero_not_reusing_forks() {
verifyTestSuiteExecution("forkCount", "0", "reuseForks", "false");
verifyTestSuiteExecution(false, "forkCount", "0", "reuseForks", "false");
}

private void verifyTestSuiteExecution(String... systemPropertiesPairs) {
private void verifyTestSuiteExecution(String... systemPropertiesPairs){
verifyTestSuiteExecution(true, systemPropertiesPairs);
}

private void verifyTestSuiteExecution(boolean useThreads, String... systemPropertiesPairs) {
// given
final Project project = testBed.getProject();

Expand All @@ -80,6 +84,7 @@ private void verifyTestSuiteExecution(String... systemPropertiesPairs) {
.logBuildOutput(false)
.withSystemProperties(systemPropertiesPairs)
.withSystemProperties(SMART_TESTING_REPORT_ENABLE, "true")
.useThreads(useThreads)
.configure()
.run();

Expand Down
1 change: 0 additions & 1 deletion junit-test-result-parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@
<artifactId>assertj-core</artifactId>
</dependency>
</dependencies>

</project>
1 change: 0 additions & 1 deletion mvn-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,4 @@
</resource>
</resources>
</build>

</project>
1 change: 0 additions & 1 deletion strategies/affected/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,4 @@
<scope>test</scope>
</dependency>
</dependencies>

</project>
1 change: 0 additions & 1 deletion strategies/changed/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@
<scope>test</scope>
</dependency>
</dependencies>

</project>
1 change: 0 additions & 1 deletion strategies/failed/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@
<scope>test</scope>
</dependency>
</dependencies>

</project>
1 change: 0 additions & 1 deletion surefire-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,4 @@
</plugin>
</plugins>
</build>

</project>

0 comments on commit 52d5817

Please sign in to comment.