Skip to content

Commit 6001086

Browse files
committed
Merge branch 'main' into AMQ-9824
2 parents 6cd775e + 433c395 commit 6001086

File tree

64 files changed

+408
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+408
-25
lines changed

activemq-amqp/pom.xml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,80 @@
180180
</dependency>
181181
</dependencies>
182182

183+
<build>
184+
<plugins>
185+
<plugin>
186+
<groupId>org.apache.maven.plugins</groupId>
187+
<artifactId>maven-surefire-plugin</artifactId>
188+
<version>${surefire.version}</version>
189+
<configuration>
190+
<argLine>${surefire.argLine}</argLine>
191+
<runOrder>alphabetical</runOrder>
192+
<reportFormat>plain</reportFormat>
193+
<failIfNoTests>false</failIfNoTests>
194+
<excludedGroups>org.apache.activemq.transport.amqp.ParallelTest</excludedGroups>
195+
<systemPropertyVariables>
196+
<org.apache.activemq.default.directory.prefix>${project.build.directory}/</org.apache.activemq.default.directory.prefix>
197+
</systemPropertyVariables>
198+
<consoleOutputReporter>
199+
<disable>true</disable>
200+
</consoleOutputReporter>
201+
<statelessTestsetInfoReporter
202+
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter">
203+
<printStacktraceOnError>true</printStacktraceOnError>
204+
<printStacktraceOnFailure>true</printStacktraceOnFailure>
205+
<printStdoutOnError>true</printStdoutOnError>
206+
<printStdoutOnFailure>true</printStdoutOnFailure>
207+
<printStderrOnError>true</printStderrOnError>
208+
<printStderrOnFailure>true</printStderrOnFailure>
209+
</statelessTestsetInfoReporter>
210+
<includes>
211+
<include>**/*Test.*</include>
212+
</includes>
213+
<excludes>
214+
<exclude>**/*LoadTest.java</exclude>
215+
<exclude>**/*StressTest.java</exclude>
216+
</excludes>
217+
</configuration>
218+
<executions>
219+
<execution>
220+
<id>parallel</id>
221+
<phase>test</phase>
222+
<goals>
223+
<goal>test</goal>
224+
</goals>
225+
<configuration>
226+
<!-- drop the default excludedGroups -->
227+
<excludedGroups combine.self="override"/>
228+
<groups>org.apache.activemq.transport.amqp.ParallelTest</groups>
229+
<forkCount>2C</forkCount>
230+
<reuseForks>false</reuseForks>
231+
<forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
232+
<failIfNoTests>false</failIfNoTests>
233+
<systemPropertyVariables>
234+
<org.apache.activemq.default.directory.prefix>${project.build.directory}/parallel-tests-${surefire.forkNumber}/</org.apache.activemq.default.directory.prefix>
235+
<!-- when running tests in parallel in the CI (quite slow) we need to bump the wireformat negotiation timeout (5s by default) -->
236+
<org.apache.activemq.transport.wireFormatNegotiationTimeout>30000</org.apache.activemq.transport.wireFormatNegotiationTimeout>
237+
</systemPropertyVariables>
238+
</configuration>
239+
</execution>
240+
</executions>
241+
<dependencies>
242+
<dependency>
243+
<groupId>org.apache.maven.surefire</groupId>
244+
<artifactId>surefire-junit47</artifactId>
245+
<version>${surefire.version}</version>
246+
</dependency>
247+
<dependency>
248+
<groupId>me.fabriciorby</groupId>
249+
<artifactId>maven-surefire-junit5-tree-reporter</artifactId>
250+
<version>1.5.1</version>
251+
</dependency>
252+
</dependencies>
253+
</plugin>
254+
</plugins>
255+
</build>
256+
183257
<profiles>
184258
<profile>
185259
<!-- profile which is activated is the swiftmq-client-home prop is defined.

activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpAndMqttTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
import org.junit.After;
4040
import org.junit.Before;
4141
import org.junit.Test;
42+
import org.junit.experimental.categories.Category;
4243

44+
@Category(ParallelTest.class)
4345
public class AmqpAndMqttTest {
4446

4547
protected BrokerService broker;

activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpAndStompInteropTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@
4040
import org.junit.Ignore;
4141
import org.junit.Rule;
4242
import org.junit.Test;
43+
import org.junit.experimental.categories.Category;
4344
import org.junit.rules.TestName;
4445
import org.slf4j.Logger;
4546
import org.slf4j.LoggerFactory;
4647

48+
@Category(ParallelTest.class)
4749
public class AmqpAndStompInteropTest {
4850

4951
private static final Logger LOG = LoggerFactory.getLogger(AmqpAndStompInteropTest.class);

activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpTestSupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.apache.activemq.spring.SpringSslContext;
5252
import org.apache.activemq.store.kahadb.KahaDBStore;
5353
import org.apache.activemq.transport.amqp.protocol.AmqpConnection;
54+
import org.apache.activemq.util.IOHelper;
5455
import org.junit.After;
5556
import org.junit.Before;
5657
import org.junit.Rule;
@@ -61,7 +62,6 @@
6162
public class AmqpTestSupport {
6263

6364
public static final String MESSAGE_NUMBER = "MessageNumber";
64-
public static final String KAHADB_DIRECTORY = "target/activemq-data/";
6565

6666
@Rule public TestName name = new TestName();
6767

@@ -120,7 +120,7 @@ protected void createBroker(boolean deleteAllMessages) throws Exception {
120120
brokerService.setDeleteAllMessagesOnStartup(deleteAllMessages);
121121
if (isPersistent()) {
122122
KahaDBStore kaha = new KahaDBStore();
123-
kaha.setDirectory(new File(KAHADB_DIRECTORY + getTestName()));
123+
kaha.setDirectory(new File(IOHelper.getDefaultDataDirectory() + getTestName()));
124124
brokerService.setPersistenceAdapter(kaha);
125125
}
126126
brokerService.setSchedulerSupport(isSchedulerEnabled());

activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpTransformerTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@
4545
import org.apache.activemq.transport.amqp.client.AmqpSession;
4646
import org.junit.After;
4747
import org.junit.Test;
48+
import org.junit.experimental.categories.Category;
4849
import org.slf4j.Logger;
4950
import org.slf4j.LoggerFactory;
5051

52+
@Category(ParallelTest.class)
5153
public class AmqpTransformerTest {
5254

5355
private static final Logger LOG = LoggerFactory.getLogger(AmqpTransformerTest.class);

activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientSimpleAuthTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@
3939
import org.junit.Before;
4040
import org.junit.Rule;
4141
import org.junit.Test;
42+
import org.junit.experimental.categories.Category;
4243
import org.junit.rules.TestName;
4344
import org.slf4j.Logger;
4445
import org.slf4j.LoggerFactory;
4546

47+
@Category(ParallelTest.class)
4648
public class JMSClientSimpleAuthTest {
4749

4850
@Rule public TestName name = new TestName();

activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@
6161
import org.apache.activemq.util.Wait;
6262
import org.apache.qpid.jms.JmsConnectionFactory;
6363
import org.junit.Test;
64+
import org.junit.experimental.categories.Category;
6465
import org.objectweb.jtests.jms.framework.TestConfig;
6566
import org.slf4j.Logger;
6667
import org.slf4j.LoggerFactory;
6768

69+
@Category(ParallelTest.class)
6870
public class JMSClientTest extends JMSClientTestSupport {
6971

7072
protected static final Logger LOG = LoggerFactory.getLogger(JMSClientTest.class);
@@ -631,7 +633,7 @@ public void testBrokerRestartWontHangConnectionClose() throws Exception {
631633
@Test(timeout=30 * 1000)
632634
public void testProduceAndConsumeLargeNumbersOfMessages() throws Exception {
633635
int count = 1000;
634-
connection = createConnection();
636+
connection = createConnectionWithRetry(name.toString(), false);
635637
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
636638
Queue queue = session.createQueue(getDestinationName());
637639
connection.start();

activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTestSupport.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,37 @@ protected Connection createConnection(String clientId, boolean syncPublish) thro
145145
connection.start();
146146
return connection;
147147
}
148+
149+
/**
150+
* Some SSL/NIO test combinations can occasionally fail the initial frame negotiation
151+
* when brokers are started in parallel forks. Retry once on the specific framing error
152+
* to smooth out that transient race without hiding other issues.
153+
*/
154+
protected Connection createConnectionWithRetry(String clientId, boolean syncPublish) throws JMSException, InterruptedException {
155+
JMSException lastException = null;
156+
for (int attempt = 0; attempt < 2; attempt++) {
157+
try {
158+
return createConnection(clientId, syncPublish);
159+
} catch (JMSException ex) {
160+
lastException = ex;
161+
if (!containsAmqpHeaderMismatch(ex)) {
162+
throw ex;
163+
}
164+
LOG.warn("AMQP header mismatch on connection attempt {} for {}, retrying once", attempt + 1, getBrokerURI());
165+
Thread.sleep(500);
166+
}
167+
}
168+
throw lastException;
169+
}
170+
171+
private boolean containsAmqpHeaderMismatch(Throwable throwable) {
172+
Throwable current = throwable;
173+
while (current != null) {
174+
if (current.getMessage() != null && current.getMessage().contains("AMQP header mismatch")) {
175+
return true;
176+
}
177+
current = current.getCause();
178+
}
179+
return false;
180+
}
148181
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.activemq.transport.amqp;
18+
19+
20+
/**
21+
* Marker interface used with {@code @Category(ParallelTest.class)} to opt a
22+
* test class or method into the {@code all-parallel} Maven profile. Only tests
23+
* explicitly tagged with this category execute when the profile is enabled,
24+
* which allows a gradual migration toward full parallelism.
25+
*/
26+
public interface ParallelTest {
27+
}

activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpAnonymousSenderTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@
2828
import org.apache.activemq.transport.amqp.client.AmqpReceiver;
2929
import org.apache.activemq.transport.amqp.client.AmqpSender;
3030
import org.apache.activemq.transport.amqp.client.AmqpSession;
31+
import org.apache.activemq.transport.amqp.ParallelTest;
3132
import org.junit.Test;
33+
import org.junit.experimental.categories.Category;
3234

3335
/**
3436
* Test for support of Anonymous sender links.
3537
*/
38+
@Category(ParallelTest.class)
3639
public class AmqpAnonymousSenderTest extends AmqpClientTestSupport {
3740

3841
@Test(timeout = 60000)

0 commit comments

Comments
 (0)