NO-JIRA: Test fixes and speed ups

This commit is contained in:
Clebert Suconic 2016-11-07 17:25:00 -05:00
parent a84a51f9cb
commit b8104f6b7e
7 changed files with 61 additions and 57 deletions

View File

@ -1053,14 +1053,9 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
@Override @Override
public void run() { public void run() {
try {
logger.debug("stopping bridge " + BridgeImpl.this); logger.debug("stopping bridge " + BridgeImpl.this);
queue.removeConsumer(BridgeImpl.this); queue.removeConsumer(BridgeImpl.this);
if (!pendingAcks.await(10, TimeUnit.SECONDS)) {
ActiveMQServerLogger.LOGGER.timedOutWaitingCompletions(BridgeImpl.this.toString(), pendingAcks.getCount());
}
synchronized (BridgeImpl.this) { synchronized (BridgeImpl.this) {
logger.debug("Closing Session for bridge " + BridgeImpl.this.name); logger.debug("Closing Session for bridge " + BridgeImpl.this.name);
@ -1103,9 +1098,6 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
logger.trace("Removing consumer on stopRunnable " + this + " from queue " + queue); logger.trace("Removing consumer on stopRunnable " + this + " from queue " + queue);
} }
ActiveMQServerLogger.LOGGER.bridgeStopped(name); ActiveMQServerLogger.LOGGER.bridgeStopped(name);
} catch (InterruptedException | RuntimeException e) {
ActiveMQServerLogger.LOGGER.error("Failed to stop bridge", e);
}
} }
} }

View File

@ -1616,7 +1616,7 @@ public class JMSBridgeTest extends BridgeTestBase {
} }
try { try {
final long MAX_BATCH_TIME = 3000; final long MAX_BATCH_TIME = 300;
final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it
@ -1655,7 +1655,7 @@ public class JMSBridgeTest extends BridgeTestBase {
} }
try { try {
final long MAX_BATCH_TIME = 3000; final long MAX_BATCH_TIME = 300;
final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it

View File

@ -28,6 +28,8 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.MessageHandler;
import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.tests.integration.mqtt.imported.util.Wait;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
@ -144,6 +146,15 @@ public class ReceiveTest extends ActiveMQTestBase {
cp.send(sendSession.createMessage(false)); cp.send(sendSession.createMessage(false));
sendSession.commit(); sendSession.commit();
final Queue queue = server.locateQueue(queueA);
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return queue.getMessageCount() == 3;
}
});
Assert.assertNotNull(cc2.receive(5000)); Assert.assertNotNull(cc2.receive(5000));
Assert.assertNotNull(cc.receive(5000)); Assert.assertNotNull(cc.receive(5000));
if (cc.receiveImmediate() == null) { if (cc.receiveImmediate() == null) {

View File

@ -166,7 +166,7 @@ public class BridgeTest extends ActiveMQTestBase {
connectors.put(server1tc.getName(), server1tc); connectors.put(server1tc.getName(), server1tc);
server0.getConfiguration().setConnectorConfigurations(connectors); server0.getConfiguration().setConnectorConfigurations(connectors);
final int messageSize = 1024 * 1024 * 5; final int messageSize = 1024 * 200;
final int numMessages = 10; final int numMessages = 10;
@ -220,7 +220,7 @@ public class BridgeTest extends ActiveMQTestBase {
} }
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
ClientMessage message = consumer1.receive(500000); ClientMessage message = consumer1.receive(5000);
Assert.assertNotNull(message); Assert.assertNotNull(message);

View File

@ -1175,6 +1175,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
ClientSession session = addClientSession(factory.createSession()); ClientSession session = addClientSession(factory.createSession());
server.createQueue(queueName, queueName, null, false, false); server.createQueue(queueName, queueName, null, false, false);
addClientConsumer(session.createConsumer(queueName)); addClientConsumer(session.createConsumer(queueName));
Thread.sleep(100); // We check the timestamp for the creation time. We need to make sure it's different
addClientConsumer(session.createConsumer(queueName, SimpleString.toSimpleString(filter), true)); addClientConsumer(session.createConsumer(queueName, SimpleString.toSimpleString(filter), true));
String jsonString = serverControl.listConsumersAsJSON(factory.getConnection().getID().toString()); String jsonString = serverControl.listConsumersAsJSON(factory.getConnection().getID().toString());

View File

@ -1616,7 +1616,7 @@ public class QueueControlTest extends ManagementTestBase {
ActiveMQServerControl serverControl = ManagementControlHelper.createActiveMQServerControl(mbeanServer); ActiveMQServerControl serverControl = ManagementControlHelper.createActiveMQServerControl(mbeanServer);
serverControl.enableMessageCounters(); serverControl.enableMessageCounters();
serverControl.setMessageCounterSamplePeriod(MessageCounterManagerImpl.MIN_SAMPLE_PERIOD); serverControl.setMessageCounterSamplePeriod(100);
String jsonString = queueControl.listMessageCounter(); String jsonString = queueControl.listMessageCounter();
MessageCounterInfo info = MessageCounterInfo.fromJSON(jsonString); MessageCounterInfo info = MessageCounterInfo.fromJSON(jsonString);
@ -1627,7 +1627,7 @@ public class QueueControlTest extends ManagementTestBase {
ClientProducer producer = session.createProducer(address); ClientProducer producer = session.createProducer(address);
producer.send(session.createMessage(false)); producer.send(session.createMessage(false));
Thread.sleep(MessageCounterManagerImpl.MIN_SAMPLE_PERIOD * 2); Thread.sleep(200);
jsonString = queueControl.listMessageCounter(); jsonString = queueControl.listMessageCounter();
info = MessageCounterInfo.fromJSON(jsonString); info = MessageCounterInfo.fromJSON(jsonString);
Assert.assertEquals(1, info.getDepth()); Assert.assertEquals(1, info.getDepth());
@ -1637,7 +1637,7 @@ public class QueueControlTest extends ManagementTestBase {
producer.send(session.createMessage(false)); producer.send(session.createMessage(false));
Thread.sleep(MessageCounterManagerImpl.MIN_SAMPLE_PERIOD * 2); Thread.sleep(200);
jsonString = queueControl.listMessageCounter(); jsonString = queueControl.listMessageCounter();
info = MessageCounterInfo.fromJSON(jsonString); info = MessageCounterInfo.fromJSON(jsonString);
Assert.assertEquals(2, info.getDepth()); Assert.assertEquals(2, info.getDepth());
@ -1647,7 +1647,7 @@ public class QueueControlTest extends ManagementTestBase {
consumeMessages(2, session, queue); consumeMessages(2, session, queue);
Thread.sleep(MessageCounterManagerImpl.MIN_SAMPLE_PERIOD * 2); Thread.sleep(200);
jsonString = queueControl.listMessageCounter(); jsonString = queueControl.listMessageCounter();
info = MessageCounterInfo.fromJSON(jsonString); info = MessageCounterInfo.fromJSON(jsonString);
Assert.assertEquals(0, info.getDepth()); Assert.assertEquals(0, info.getDepth());

View File

@ -279,7 +279,7 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase {
public void testValidateDeliveryAndCounters() throws Exception { public void testValidateDeliveryAndCounters() throws Exception {
startLive(); startLive();
ServerLocator locator = SpawnedServerSupport.createLocator(PORT1).setInitialConnectAttempts(100).setReconnectAttempts(-1).setRetryInterval(100); ServerLocator locator = SpawnedServerSupport.createLocator(PORT1).setInitialConnectAttempts(-1).setReconnectAttempts(-1).setRetryInterval(100);
ClientSessionFactory factory = locator.createSessionFactory(); ClientSessionFactory factory = locator.createSessionFactory();