Skip to content

Commit ffed175

Browse files
committed
[AMQ-8525] run mqtt parallel-friendly tests into separate forks in parallel
1 parent 59eb831 commit ffed175

28 files changed

+152
-26
lines changed

Jenkinsfile

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pipeline {
4949
choice(name: 'nodeLabel', choices: [ 'ubuntu', 's390x', 'arm', 'Windows' ])
5050
choice(name: 'jdkVersion', choices: ['jdk_17_latest', 'jdk_21_latest', 'jdk_24_latest', 'jdk_17_latest_windows', 'jdk_21_latest_windows', 'jdk_24_latest_windows'])
5151
booleanParam(name: 'deployEnabled', defaultValue: false)
52-
booleanParam(name: 'parallelTestsEnabled', defaultValue: true)
5352
booleanParam(name: 'sonarEnabled', defaultValue: false)
5453
booleanParam(name: 'testsEnabled', defaultValue: true)
5554
}
@@ -131,20 +130,12 @@ pipeline {
131130
}
132131
when { expression { return params.testsEnabled } }
133132
steps {
133+
echo 'Running tests'
134134
sh 'java -version'
135135
sh 'mvn -version'
136-
137136
// all tests is very very long (10 hours on Apache Jenkins)
138137
// sh 'mvn -B -e test -pl activemq-unit-tests -Dactivemq.tests=all'
139-
script {
140-
if (params.parallelTestsEnabled == 'true') {
141-
sh 'echo "Running parallel-tests ..."'
142-
sh 'mvn -B -e -fae -Pparallel-tests test -Dsurefire.rerunFailingTestsCount=3'
143-
} else {
144-
sh 'echo "Running tests ..."'
145-
sh 'mvn -B -e -fae test -Dsurefire.rerunFailingTestsCount=3'
146-
}
147-
}
138+
sh 'mvn -B -e -fae test -Dsurefire.rerunFailingTestsCount=3'
148139
}
149140
post {
150141
always {

activemq-mqtt/pom.xml

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<artifactId>activemq-mqtt</artifactId>
2929
<packaging>jar</packaging>
3030
<name>ActiveMQ :: MQTT Protocol</name>
31+
3132
<description>The ActiveMQ MQTT Protocol Implementation</description>
3233

3334
<dependencies>
@@ -212,21 +213,56 @@
212213
<plugin>
213214
<artifactId>maven-surefire-plugin</artifactId>
214215
<configuration>
215-
<forkCount>1</forkCount>
216-
<reuseForks>false</reuseForks>
217216
<argLine>-javaagent:${org.mockito:mockito-core:jar}</argLine>
218217
<runOrder>alphabetical</runOrder>
219-
<systemPropertyValues>
220-
<org.apache.activemq.default.directory.prefix>target</org.apache.activemq.default.directory.prefix>
221-
</systemPropertyValues>
222-
<!-- includes>
223-
<include>**/*Test.*</include>
224-
</includes -->
225-
<excludes>
226-
<exclude>**/PahoMQTNioTTest.java</exclude>
227-
</excludes>
218+
<reportFormat>plain</reportFormat>
219+
<excludedGroups>org.apache.activemq.transport.mqtt.ParallelTest</excludedGroups>
220+
<systemPropertyVariables>
221+
<java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
222+
<org.apache.activemq.AutoFailTestSupport.disableSystemExit>true</org.apache.activemq.AutoFailTestSupport.disableSystemExit>
223+
<org.apache.activemq.broker.jmx.createConnector>false</org.apache.activemq.broker.jmx.createConnector>
224+
<org.apache.activemq.default.directory.prefix>${project.build.directory}/</org.apache.activemq.default.directory.prefix>
225+
</systemPropertyVariables>
226+
<consoleOutputReporter>
227+
<disable>true</disable>
228+
</consoleOutputReporter>
229+
<statelessTestsetInfoReporter
230+
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter">
231+
<printStacktraceOnError>true</printStacktraceOnError>
232+
<printStacktraceOnFailure>true</printStacktraceOnFailure>
233+
<printStdoutOnError>true</printStdoutOnError>
234+
<printStdoutOnFailure>true</printStdoutOnFailure>
235+
<printStderrOnError>true</printStderrOnError>
236+
<printStderrOnFailure>true</printStderrOnFailure>
237+
</statelessTestsetInfoReporter>
238+
<excludes>
239+
<exclude>**/PahoMQTNioTTest.java</exclude>
240+
</excludes>
228241
</configuration>
242+
<executions>
243+
<execution>
244+
<id>parallel</id>
245+
<phase>test</phase>
246+
<goals>
247+
<goal>test</goal>
248+
</goals>
249+
<configuration>
250+
<!-- drop the default excludedGroups -->
251+
<excludedGroups combine.self="override"/>
252+
<groups>org.apache.activemq.transport.mqtt.ParallelTest</groups>
253+
<forkCount>2C</forkCount>
254+
<reuseForks>false</reuseForks>
255+
<forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
256+
<systemPropertyVariables>
257+
<org.apache.activemq.default.directory.prefix>${project.build.directory}/parallel-tests-${surefire.forkNumber}/</org.apache.activemq.default.directory.prefix>
258+
<!-- when running MQTT tests in parallel in the CI (quite slow) we need to bump the wireformat negotiation timeout (5s by default) -->
259+
<org.apache.activemq.transport.wireFormatNegotiationTimeout>20000</org.apache.activemq.transport.wireFormatNegotiationTimeout>
260+
</systemPropertyVariables>
261+
</configuration>
262+
</execution>
263+
</executions>
229264
</plugin>
265+
230266
<plugin>
231267
<groupId>org.apache.activemq.protobuf</groupId>
232268
<artifactId>activemq-protobuf</artifactId>

activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTAuthTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,16 @@
4747
import org.fusesource.mqtt.codec.CONNACK;
4848
import org.fusesource.mqtt.codec.MQTTFrame;
4949
import org.junit.Test;
50+
import org.junit.experimental.categories.Category;
5051
import org.junit.runner.RunWith;
5152
import org.junit.runners.Parameterized;
5253
import org.junit.runners.Parameterized.Parameters;
5354
import org.slf4j.Logger;
5455
import org.slf4j.LoggerFactory;
55-
5656
/**
5757
* Tests various use cases that require authentication or authorization over MQTT
5858
*/
59+
@Category(ParallelTest.class)
5960
@RunWith(Parameterized.class)
6061
public class MQTTAuthTest extends MQTTAuthTestSupport {
6162

activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTCodecTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@
4141
import org.fusesource.mqtt.codec.UNSUBSCRIBE;
4242
import org.junit.Before;
4343
import org.junit.Test;
44+
import org.junit.experimental.categories.Category;
4445
import org.slf4j.Logger;
4546
import org.slf4j.LoggerFactory;
4647

4748
/**
4849
* Tests the functionality of the MQTTCodec class.
4950
*/
51+
@Category(ParallelTest.class)
5052
public class MQTTCodecTest {
5153

5254
private static final Logger LOG = LoggerFactory.getLogger(MQTTCodecTest.class);

activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTCompositeQueueRetainedTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@
4242
import org.apache.activemq.util.ByteSequence;
4343
import org.junit.Test;
4444

45+
import org.junit.experimental.categories.Category;
46+
4547
/**
4648
*
4749
*/
50+
@Category(ParallelTest.class)
4851
public class MQTTCompositeQueueRetainedTest extends MQTTTestSupport {
4952

5053
// configure composite topic

activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTConnectTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.junit.After;
3636
import org.junit.Ignore;
3737
import org.junit.Test;
38+
import org.junit.experimental.categories.Category;
3839
import org.junit.runner.RunWith;
3940
import org.junit.runners.Parameterized;
4041
import org.junit.runners.Parameterized.Parameters;
@@ -45,6 +46,7 @@
4546
* Test that connection attempts that don't send a CONNECT frame will
4647
* get cleaned up by the inactivity monitor.
4748
*/
49+
@Category(ParallelTest.class)
4850
@RunWith(Parameterized.class)
4951
public class MQTTConnectTest extends MQTTTestSupport {
5052

activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTMaxFrameSizeTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
import org.slf4j.Logger;
3232
import org.slf4j.LoggerFactory;
3333

34+
import org.junit.experimental.categories.Category;
3435
/**
3536
* Test that the maxFrameSize configuration value is applied across the transports.
3637
*/
38+
@Category(ParallelTest.class)
3739
@RunWith(Parameterized.class)
3840
public class MQTTMaxFrameSizeTest extends MQTTTestSupport {
3941

activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTNIOSSLTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
*/
1717
package org.apache.activemq.transport.mqtt;
1818

19+
import org.junit.experimental.categories.Category;
20+
1921
/**
2022
* Run the basic tests with the NIO Transport.
2123
*/
24+
@Category(ParallelTest.class)
2225
public class MQTTNIOSSLTest extends MQTTTest {
2326

2427
@Override

activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTNIOTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
*/
1717
package org.apache.activemq.transport.mqtt;
1818

19+
import org.junit.experimental.categories.Category;
20+
1921
/**
2022
* Run the basic tests with the NIO Transport.
2123
*/
24+
@Category(ParallelTest.class)
2225
public class MQTTNIOTest extends MQTTTest {
2326

2427
@Override

activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTOverlapedSubscriptionsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
import org.junit.After;
3030
import org.junit.Before;
3131
import org.junit.Test;
32+
import org.junit.experimental.categories.Category;
3233

34+
@Category(ParallelTest.class)
3335
public class MQTTOverlapedSubscriptionsTest {
3436

3537
private BrokerService brokerService;

0 commit comments

Comments
 (0)