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 9, 2017
1 parent 3ab92c5 commit 3893aa1
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 12 deletions.
26 changes: 17 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ cache:
directories:
- $HOME/.m2

env:
- TEST_PROFILE=units GENERATE_DOC=1
- TEST_PROFILE=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" ] || [ ! -z "${TRAVIS_PULL_REQUEST// }" -a "${TRAVIS_PULL_REQUEST}" != "false" ] && GENERATE_DOC=0 || GENERATE_DOC=1'
- '[ $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" ] || [ ! -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 +39,11 @@ before_install:
docker pull rochdev/alpine-asciidoctor:mini;
fi'

install:
- 'if [[ -n $TEST_PROFILE ]]; 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 +71,12 @@ 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_PROFILE ]]; then
./mvnw clean verify -P travis,${TEST_PROFILE} -DJAVA_OPTS="-XX:-UseLoopPredicate" -T 100;
elif [ $GENERATE_DOC -eq 0 ]; then
./.asciidoctor/generate.sh --keep;
fi'

after_success:
- 'if [ $GENERATE_DOC -eq 0 ]; then
Expand Down
16 changes: 16 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,20 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>functional</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
15 changes: 15 additions & 0 deletions functional-tests/git-rules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,19 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>functional</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
16 changes: 16 additions & 0 deletions functional-tests/test-bed/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,20 @@
</plugins>
</build>

<profiles>
<profile>
<id>units</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ 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 boolean useThreads = true;

BuildConfigurator(ProjectBuilder projectBuilder) {
systemProperties.put("surefire.exitTimeout", "-1"); // see http://bit.ly/2vARQ5p
Expand Down Expand Up @@ -181,6 +182,11 @@ public BuildConfigurator excludeProjects(String... projects) {
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 @@ -256,6 +262,10 @@ int getSurefireDebugPort() {
boolean isIgnoreBuildFailure() {
return ignoreBuildFailure;
}

boolean useThreads(){
return useThreads;
}

private int getAvailableLocalPort() {
ServerSocket socket = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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 @@ -38,7 +38,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 @@ -58,10 +58,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){
verifyTestSuiteExecution(true, systemPropertiesPairs);
}

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

Expand All @@ -79,6 +83,7 @@ private void verifyTestSuiteExecution(String... systemPropertiesPairs){
.options()
.withSystemProperties(systemPropertiesPairs)
.withSystemProperties(SMART_TESTING_REPORT_ENABLE, "true")
.useThreads(useThreads)
.configure()
.run();
// then
Expand Down
15 changes: 15 additions & 0 deletions junit-test-result-parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,19 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>functional</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
16 changes: 16 additions & 0 deletions mvn-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,20 @@
</resources>
</build>

<profiles>
<profile>
<id>functional</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
15 changes: 15 additions & 0 deletions strategies/affected/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,19 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>functional</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
15 changes: 15 additions & 0 deletions strategies/changed/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,19 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>functional</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
15 changes: 15 additions & 0 deletions strategies/failed/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,19 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>functional</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
16 changes: 16 additions & 0 deletions surefire-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,20 @@
</plugins>
</build>

<profiles>
<profile>
<id>functional</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

0 comments on commit 3893aa1

Please sign in to comment.