Reputation: 1
I am trying to parallelize the execution of tests using the maven-surefire-plugin
in a GitHub action. The action looks like this:
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
name: Run tests on ${{ matrix.os }}
...
To run tests, the action uses mvn clean verify
. In general, the action runner creates 3 jobs that run the tests from the Maven projects at the same time. However, to increase the performance, I tried to add some parallelization to the execution by using the following configuration in the pom
file:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<reportsDirectory>${project.basedir}/testresults</reportsDirectory>
<trimStackTrace>false</trimStackTrace>
<parallel>classes</parallel> <!-- Adding these 3 lines causes the jobs to block
<forkCount>3</forkCount> and wait until one job has finished
<reuseForks>true</reuseForks> -->
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
</dependencies>
</plugin>
Without the elements <parallel>
, <forkCount>
, and <reuseForks>
, the jobs run at the same time, that is, the tests are executes at the same time. However, adding the three elements, the problem is that, although the GitHub action starts the jobs at the same time, they wait for each other to finish as soon as they try to execute the tests. More precisely, they build the project (e.g. load all dependencies) until they reach the test execution. At this time, only one jobs continues and executes all tests, while the other two are blocking. When the first job has finished, the next job continues with the test execution, and after the second one has finished, the third one starts.
I am wondering what the problem is and whether there is a way to increase the performance of the test execution while running the jobs at the same time.
I played around with the <forkCount>
and <parallel>
elements but couldn't solve the problem
Upvotes: 0
Views: 69