ARTEMIS-1753 Fixing intermittent failure on OldAddressSpaceTest

This commit is contained in:
Clebert Suconic 2018-03-22 14:58:46 -04:00
parent e26c051617
commit 37657f22fa
4 changed files with 13 additions and 5 deletions

View File

@ -1,4 +1,4 @@
package servers
package oldAddressSpace
import org.apache.activemq.artemis.api.core.RoutingType
import org.apache.activemq.artemis.api.core.SimpleString

View File

@ -1,4 +1,4 @@
package meshTest
package oldAddressSpace
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
import org.apache.activemq.artemis.tests.compatibility.GroovyRun
@ -46,6 +46,8 @@ System.out.println("Receiving...");
MessageConsumer topicConsumer = session.createDurableSubscriber(topic, "myDurableSub")
MessageConsumer queueConsumer = session.createConsumer(queue)
subscriptionCreated.countDown();
connection.start()
for (int i = 0; i < 500; i++) {
BytesMessage bytesMessage = (BytesMessage) queueConsumer.receive(5000);

View File

@ -1,4 +1,4 @@
package meshTest
package oldAddressSpace
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory

View File

@ -63,10 +63,12 @@ public class OldAddressSpaceTest extends VersionedBaseTest {
public void testClientSenderServerAddressSettings() throws Throwable {
evaluate(serverClassloader, "oldAddressSpace/artemisServer.groovy", serverFolder.getRoot().getAbsolutePath(), server);
CountDownLatch subscriptionCreated = new CountDownLatch(1);
CountDownLatch receiverLatch = new CountDownLatch(1);
CountDownLatch senderLatch = new CountDownLatch(1);
setVariable(receiverClassloader, "latch", receiverLatch);
setVariable(receiverClassloader, "subscriptionCreated", subscriptionCreated);
AtomicInteger errors = new AtomicInteger(0);
Thread t1 = new Thread() {
@ -75,12 +77,15 @@ public class OldAddressSpaceTest extends VersionedBaseTest {
try {
evaluate(receiverClassloader, "oldAddressSpace/receiveMessages.groovy", receiver);
} catch (Throwable e) {
e.printStackTrace();
errors.incrementAndGet();
}
}
};
t1.start();
Assert.assertTrue(subscriptionCreated.await(10, TimeUnit.SECONDS));
setVariable(senderClassloader, "senderLatch", senderLatch);
Thread t2 = new Thread() {
@Override
@ -88,6 +93,7 @@ public class OldAddressSpaceTest extends VersionedBaseTest {
try {
evaluate(senderClassloader, "oldAddressSpace/sendMessagesAddress.groovy", sender);
} catch (Throwable e) {
e.printStackTrace();
errors.incrementAndGet();
}
}
@ -96,8 +102,8 @@ public class OldAddressSpaceTest extends VersionedBaseTest {
try {
Assert.assertTrue("Sender is blocking by mistake", senderLatch.await(100, TimeUnit.SECONDS));
Assert.assertTrue("Receiver did not receive messages", receiverLatch.await(100, TimeUnit.SECONDS));
Assert.assertTrue("Sender is blocking by mistake", senderLatch.await(10, TimeUnit.SECONDS));
Assert.assertTrue("Receiver did not receive messages", receiverLatch.await(10, TimeUnit.SECONDS));
} finally {
t1.join(TimeUnit.SECONDS.toMillis(1));