You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2024/07/18 18:16:08 UTC
(activemq-artemis) 01/02: NO-JIRA Speending up a failover test
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/activemq-artemis.git
commit 79708749e8d540b4243cdb4216adb07a2e9e6d22
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Jul 18 11:07:06 2024 -0400
NO-JIRA Speending up a failover test
No need for the iterations, and a few minor improvements to the test.
This method was taking up to 15 seconds on the CI and the same method is reused a couple times, resulting in many minutes wasted
---
.../failover/ReplicatedPagedFailoverTest.java | 73 ++++++++++------------
1 file changed, 34 insertions(+), 39 deletions(-)
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedPagedFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedPagedFailoverTest.java
index 3d267dd068..787d0d0579 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedPagedFailoverTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedPagedFailoverTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.activemq.artemis.tests.integration.cluster.failover;
+import java.lang.invoke.MethodHandles;
import java.util.HashMap;
import org.apache.activemq.artemis.api.core.QueueConfiguration;
@@ -29,13 +30,18 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.NodeManager;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.utils.Wait;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class ReplicatedPagedFailoverTest extends ReplicatedFailoverTest {
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
@Override
protected ActiveMQServer createInVMFailoverServer(final boolean realFiles,
final Configuration configuration,
@@ -78,74 +84,63 @@ public class ReplicatedPagedFailoverTest extends ReplicatedFailoverTest {
// 0 - no tamper
// 1 - close files
// 2 - remove files
- private void internalBrowser(int temperMode) throws Exception {
+ private void internalBrowser(int tamperMode) throws Exception {
int numMessages = 50;
int messagesPerPage = 10;
- int iterations = 10;
createSessionFactory();
ClientSession session = createSession(sf, true, true);
- session.createQueue(QueueConfiguration.of(FailoverTestBase.ADDRESS).setDurable(false));
+ session.createQueue(QueueConfiguration.of(FailoverTestBase.ADDRESS).setDurable(true));
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
Queue queue = primaryServer.getServer().locateQueue(FailoverTest.ADDRESS);
- for (int j = 0; j < iterations; j++) {
- System.err.println("#iteration " + j);
- queue.getPageSubscription().getPagingStore().startPaging();
- assertNotNull(queue);
+ queue.getPageSubscription().getPagingStore().startPaging();
+ assertNotNull(queue);
- for (int i = 0; i < numMessages; i++) {
- // some are durable, some are not!
- producer.send(createMessage(session, i, i % 2 == 0));
- if (i > 0 && i % messagesPerPage == 0) {
- queue.getPageSubscription().getPagingStore().forceAnotherPage();
- }
+ for (int i = 0; i < numMessages; i++) {
+ // some are durable, some are not!
+ producer.send(createMessage(session, i, i % 2 == 0));
+ if (i > 0 && i % messagesPerPage == 0) {
+ queue.getPageSubscription().getPagingStore().forceAnotherPage();
}
+ }
- ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS, true);
-
+ try (ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS, true)) {
session.start();
- while (true) {
+ for (int i = 0; i < numMessages; i++) {
ClientMessage msg = consumer.receive(500);
- if (msg == null) {
- break;
- }
+ Assertions.assertNotNull(msg);
}
- consumer.close();
+ }
- PagingStore store = queue.getPageSubscription().getPagingStore();
+ PagingStore store = queue.getPageSubscription().getPagingStore();
- if (temperMode == 1) {
- // this is tampering with the system causing an artifical issue. The system should still heal itself.
- for (long pageID = store.getFirstPage(); pageID <= store.getCurrentPage().getPageId() + 10; pageID++) {
- primaryServer.getServer().getStorageManager().pageClosed(store.getStoreName(), (int) pageID);
- }
- } else if (temperMode == 2) {
- // this is tampering with the system causing an artifical issue. The system should still heal itself.
- for (long pageID = store.getFirstPage(); pageID <= store.getCurrentPage().getPageId() + 10; pageID++) {
- primaryServer.getServer().getStorageManager().pageDeleted(store.getStoreName(), (int) pageID);
- }
+ // tampering with the system's file
+ if (tamperMode == 1) {
+ for (long pageID = store.getFirstPage(); pageID <= store.getCurrentPage().getPageId() + 10; pageID++) {
+ primaryServer.getServer().getStorageManager().pageClosed(store.getStoreName(), (int) pageID);
+ }
+ } else if (tamperMode == 2) {
+ for (long pageID = store.getFirstPage(); pageID <= store.getCurrentPage().getPageId() + 10; pageID++) {
+ primaryServer.getServer().getStorageManager().pageDeleted(store.getStoreName(), (int) pageID);
}
- store.getFirstPage();
- store.getCurrentPage().getPageId();
+ }
- consumer = session.createConsumer(FailoverTestBase.ADDRESS, false);
+ try (ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS, false)) {
session.start();
- while (true) {
+ for (int i = 0; i < numMessages; i++) {
ClientMessage msg = consumer.receive(500);
- if (msg == null) {
+ if (msg == null) { // the system was tampered, we will receive fewer messages than expected
break;
}
msg.acknowledge();
}
- consumer.close();
-
- Wait.assertFalse(queue.getPageSubscription().getPagingStore()::isPaging);
}
+ Wait.assertFalse(queue.getPageSubscription().getPagingStore()::isPaging);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@activemq.apache.org
For additional commands, e-mail: commits-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact