This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/artemis.git
The following commit(s) were added to refs/heads/main by this push:
new 240c390882 NO-JIRA extending timeout on
DualMirrorSingleAcceptorRunningTest
240c390882 is described below
commit 240c3908825266f531a9a49a8eb5924a3a5085d9
Author: Clebert Suconic <[email protected]>
AuthorDate: Thu Feb 26 09:20:24 2026 -0500
NO-JIRA extending timeout on DualMirrorSingleAcceptorRunningTest
---
.../DualMirrorSingleAcceptorRunningTest.java | 43 +++++++++++-----------
1 file changed, 21 insertions(+), 22 deletions(-)
diff --git
a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/lockmanager/DualMirrorSingleAcceptorRunningTest.java
b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/lockmanager/DualMirrorSingleAcceptorRunningTest.java
index 750ad87ebd..716f4b263a 100644
---
a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/lockmanager/DualMirrorSingleAcceptorRunningTest.java
+++
b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/lockmanager/DualMirrorSingleAcceptorRunningTest.java
@@ -33,6 +33,7 @@ import java.util.Properties;
import java.util.function.Consumer;
import org.apache.activemq.artemis.api.core.management.SimpleManagement;
+import org.apache.activemq.artemis.cli.commands.Connect;
import org.apache.activemq.artemis.cli.commands.helper.HelperCreate;
import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil;
@@ -44,6 +45,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
public class DualMirrorSingleAcceptorRunningTest extends SmokeTestBase {
@@ -181,7 +183,6 @@ public class DualMirrorSingleAcceptorRunningTest extends
SmokeTestBase {
public void testAlternating(String nameServerA, String nameServerB, File
brokerPropertiesA, File brokerPropertiesB) throws Throwable {
processA = startServer(nameServerA, 0, -1, brokerPropertiesA);
- waitForXToStart();
processB = startServer(nameServerB, 0, -1, brokerPropertiesB);
ConnectionFactory cfX = CFUtil.createConnectionFactory("amqp",
"tcp://localhost:61616");
@@ -191,11 +192,9 @@ public class DualMirrorSingleAcceptorRunningTest extends
SmokeTestBase {
if (i % 2 == 0) {
// Even iteration: Server A active, kill Server B
killServer(processB);
- waitForXToStart();
} else {
// Odd iteration: Server B active, kill Server A
killServer(processA);
- waitForXToStart();
}
// Send messages through the shared acceptor
@@ -219,7 +218,7 @@ public class DualMirrorSingleAcceptorRunningTest extends
SmokeTestBase {
}
private static void sendMessages(ConnectionFactory cfX, int nmessages)
throws JMSException {
- try (Connection connectionX = cfX.createConnection("A", "A")) {
+ try (Connection connectionX = retryUntilIsLive(cfX)) {
Session sessionX = connectionX.createSession(true,
Session.SESSION_TRANSACTED);
Queue queue = sessionX.createQueue("myQueue");
MessageProducer producerX = sessionX.createProducer(queue);
@@ -230,8 +229,25 @@ public class DualMirrorSingleAcceptorRunningTest extends
SmokeTestBase {
}
}
+ private static Connection retryUntilIsLive(ConnectionFactory cfX) {
+ final int maxRetry = 1000;
+ for (int i = 0; i < maxRetry; i++) {
+ try {
+ return cfX.createConnection();
+ } catch (Exception ex) {
+ logger.info("Exception during connection, retrying the
connection... {} out of {} retries, message = {}", i, maxRetry,
ex.getMessage());
+ try {
+ Thread.sleep(500);
+ } catch (Throwable e) {
+ }
+ }
+ }
+ fail("Could not connect after " + maxRetry + " retries");
+ return null; // never happening, fail will throw an exception
+ }
+
private static void receiveMessages(ConnectionFactory cfX, int nmessages)
throws JMSException {
- try (Connection connectionX = cfX.createConnection("A", "A")) {
+ try (Connection connectionX = retryUntilIsLive(cfX)) {
connectionX.start();
Session sessionX = connectionX.createSession(true,
Session.SESSION_TRANSACTED);
Queue queue = sessionX.createQueue("myQueue");
@@ -244,23 +260,6 @@ public class DualMirrorSingleAcceptorRunningTest extends
SmokeTestBase {
}
}
- private void waitForXToStart() {
- for (int i = 0; i < 20; i++) {
- try {
- ConnectionFactory factory = CFUtil.createConnectionFactory("AMQP",
"tcp://localhost:61616");
- Connection connection = factory.createConnection();
- connection.close();
- return;
- } catch (Throwable e) {
- logger.debug(e.getMessage(), e);
- try {
- Thread.sleep(500);
- } catch (Throwable ignored) {
- }
- }
- }
- }
-
protected void assertMessageCount(String uri, String queueName, int count)
throws Exception {
SimpleManagement simpleManagement = new SimpleManagement(uri, null,
null);
Wait.assertEquals(count, () -> {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]