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
This commit is contained in:
parent
58f9e00874
commit
79708749e8
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
try (ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS, true)) {
|
||||
session.start();
|
||||
|
||||
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();
|
||||
}
|
||||
ClientMessage msg = consumer.receive(500);
|
||||
Assertions.assertNotNull(msg);
|
||||
}
|
||||
}
|
||||
|
||||
ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS, true);
|
||||
PagingStore store = queue.getPageSubscription().getPagingStore();
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
consumer.close();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
store.getFirstPage();
|
||||
store.getCurrentPage().getPageId();
|
||||
|
||||
consumer = session.createConsumer(FailoverTestBase.ADDRESS, false);
|
||||
session.start();
|
||||
|
||||
while (true) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue