Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARTEMIS-5232 Clean up on testsuite for speed #5430

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,13 @@
@RunWith(BlockJUnit4ClassRunner.class)
public class ExpiryHogTest extends JmsMultipleClientsTestSupport {

boolean sleep = false;

int numMessages = 4;

@Test(timeout = 2 * 60 * 1000)
public void testImmediateDispatchWhenCacheDisabled() throws Exception {
ConnectionFactory f = createConnectionFactory();
destination = createDestination();
startConsumers(f, destination);
sleep = true;
this.startProducers(f, destination, numMessages);
allMessagesList.assertMessagesReceived(numMessages);
}
Expand All @@ -55,7 +52,7 @@ protected BrokerService createBroker() throws Exception {
bs.setDeleteAllMessagesOnStartup(true);
PolicyMap policyMap = new PolicyMap();
PolicyEntry defaultEntry = new PolicyEntry();
defaultEntry.setExpireMessagesPeriod(5000);
defaultEntry.setExpireMessagesPeriod(500);
defaultEntry.setUseCache(false);
policyMap.setDefaultEntry(defaultEntry);
bs.setDestinationPolicy(policyMap);
Expand All @@ -65,11 +62,8 @@ protected BrokerService createBroker() throws Exception {

@Override
protected TextMessage createTextMessage(Session session, String initText) throws Exception {
if (sleep) {
TimeUnit.SECONDS.sleep(10);
}
TextMessage msg = super.createTextMessage(session, initText);
msg.setJMSExpiration(4000);
msg.setJMSExpiration(500);
return msg;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@
*/
package org.apache.activemq;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
import javax.jms.ServerSession;
import javax.jms.ServerSessionPool;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.util.concurrent.CountDownLatch;
Expand All @@ -36,7 +31,6 @@
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTextMessage;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.util.Wait;

public class RedeliveryPolicyTest extends JmsTestSupport {

Expand Down Expand Up @@ -494,84 +488,6 @@ public void testRepeatedRedeliveryOnMessageNoCommit() throws Exception {

}

public void testRepeatedRedeliveryServerSessionNoCommit() throws Exception {

connection.start();
Session dlqSession = connection.createSession(true, Session.SESSION_TRANSACTED);
ActiveMQQueue destination = new ActiveMQQueue("TEST");
MessageProducer producer = dlqSession.createProducer(destination);

// Send the messages
producer.send(dlqSession.createTextMessage("1st"));

dlqSession.commit();
MessageConsumer dlqConsumer = dlqSession.createConsumer(new ActiveMQQueue("ActiveMQ.DLQ"));

final int maxRedeliveries = 4;
final AtomicInteger receivedCount = new AtomicInteger(0);

for (int i = 0; i <= maxRedeliveries + 1; i++) {

connection = (ActiveMQConnection) factory.createConnection(userName, password);
connections.add(connection);

RedeliveryPolicy policy = connection.getRedeliveryPolicy();
policy.setInitialRedeliveryDelay(0);
policy.setUseExponentialBackOff(false);
policy.setMaximumRedeliveries(maxRedeliveries);

connection.start();
final CountDownLatch done = new CountDownLatch(1);

final ActiveMQSession session = (ActiveMQSession) connection.createSession(true, Session.SESSION_TRANSACTED);
session.setMessageListener(message -> {
try {
ActiveMQTextMessage m = (ActiveMQTextMessage) message;
assertEquals("1st", m.getText());
assertEquals(receivedCount.get(), m.getRedeliveryCounter());
receivedCount.incrementAndGet();
done.countDown();
} catch (Exception ignored) {
ignored.printStackTrace();
}
});

connection.createConnectionConsumer(destination, null, () -> new ServerSession() {
@Override
public Session getSession() throws JMSException {
return session;
}

@Override
public void start() throws JMSException {
}
}, 100, false);

Wait.waitFor(() -> {
session.run();
return done.await(10, TimeUnit.MILLISECONDS);
});

if (i <= maxRedeliveries) {
assertTrue("listener done @" + i, done.await(5, TimeUnit.SECONDS));
} else {
// final redlivery gets poisoned before dispatch
assertFalse("listener not done @" + i, done.await(1, TimeUnit.SECONDS));
}
connection.close();
connections.remove(connection);
}

// We should be able to get the message off the DLQ now.
TextMessage m = (TextMessage) dlqConsumer.receive(1000);
assertNotNull("Got message from DLQ", m);
assertEquals("1st", m.getText());
String cause = m.getStringProperty(ActiveMQMessage.DLQ_DELIVERY_FAILURE_CAUSE_PROPERTY);
assertTrue("cause exception has policy ref", cause.contains("RedeliveryPolicy"));
dlqSession.commit();

}

public void testInitialRedeliveryDelayZero() throws Exception {

// Receive a message with the JMS API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,18 @@
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.StoreConfiguration;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.LargeServerMessage;
import org.apache.activemq.artemis.core.server.MessageReference;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.DataConstants;
import org.apache.activemq.artemis.utils.DeflaterReader;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.collections.LinkedListIterator;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -65,20 +70,46 @@
@ExtendWith(ParameterizedTestExtension.class)
public abstract class LargeMessageTestBase extends ActiveMQTestBase {


private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

protected final SimpleString ADDRESS = SimpleString.of("SimpleAddress");

protected ServerLocator locator;

protected StoreConfiguration.StoreType storeType;

protected boolean isCompressedTest = false;

public LargeMessageTestBase(StoreConfiguration.StoreType storeType) {
this.storeType = storeType;
}

protected void validateLargeMessageComplete(ActiveMQServer server) throws Exception {
Queue queue = server.locateQueue(ADDRESS);

protected StoreConfiguration.StoreType storeType;
Wait.assertEquals(1, queue::getMessageCount);

public LargeMessageTestBase(StoreConfiguration.StoreType storeType) {
this.storeType = storeType;
LinkedListIterator<MessageReference> browserIterator = queue.browserIterator();

while (browserIterator.hasNext()) {
MessageReference ref = browserIterator.next();
Message message = ref.getMessage();

assertNotNull(message);
assertTrue(message instanceof LargeServerMessage);
}
browserIterator.close();
}

protected boolean isNetty() {
return false;
}

@Override
@BeforeEach
public void setUp() throws Exception {
super.setUp();
locator = createFactory(isNetty());
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public void tearDown() throws Exception {

factory = null;

ActiveMQTestBase.forceGC();

assertEquals(0, LibaioContext.getTotalMaxIO());

super.tearDown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ protected static final ClusterConnectionConfiguration basicClusterConnectionConf
setName("cluster1").setAddress("jms").setConnectorName(connectorName).
setRetryInterval(100).setDuplicateDetection(false).setMaxHops(1).
setConfirmationWindowSize(1).setMessageLoadBalancingType(MessageLoadBalancingType.STRICT).
setStaticConnectors(connectors0);
setStaticConnectors(connectors0).setCallTimeout(1000).setCallFailoverTimeout(1000);
clebertsuconic marked this conversation as resolved.
Show resolved Hide resolved

return clusterConnectionConfiguration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.apache.activemq.artemis.api.core.client.ClientProducer;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.config.StoreConfiguration;
import org.apache.activemq.artemis.core.filter.Filter;
import org.apache.activemq.artemis.core.paging.PagingManager;
Expand Down Expand Up @@ -87,8 +86,6 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase {

private final int LARGE_MESSAGE_SIZE = ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE * 3;

protected ServerLocator locator;

public InterruptedLargeMessageTest(StoreConfiguration.StoreType storeType) {
super(storeType);
}
Expand All @@ -98,9 +95,9 @@ public InterruptedLargeMessageTest(StoreConfiguration.StoreType storeType) {
public void setUp() throws Exception {
super.setUp();
LargeMessageTestInterceptorIgnoreLastPacket.clearInterrupt();
locator = createFactory(isNetty());
}

@Override
protected boolean isNetty() {
return false;
}
Expand Down Expand Up @@ -141,8 +138,6 @@ public void testInterruptLargeMessageSend() throws Exception {

server.fail(false);

ActiveMQTestBase.forceGC();

server.start();

server.stop();
Expand Down
Loading