From 37657f22fa5ae1ff43b752c5823e8097e5db9e6c Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Thu, 22 Mar 2018 14:58:46 -0400 Subject: [PATCH] ARTEMIS-1753 Fixing intermittent failure on OldAddressSpaceTest --- .../resources/oldAddressSpace/artemisServer.groovy | 2 +- .../resources/oldAddressSpace/receiveMessages.groovy | 4 +++- .../oldAddressSpace/sendMessagesAddress.groovy | 2 +- .../tests/compatibility/OldAddressSpaceTest.java | 10 ++++++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/compatibility-tests/src/main/resources/oldAddressSpace/artemisServer.groovy b/tests/compatibility-tests/src/main/resources/oldAddressSpace/artemisServer.groovy index 6ffa086c06..85f661918d 100644 --- a/tests/compatibility-tests/src/main/resources/oldAddressSpace/artemisServer.groovy +++ b/tests/compatibility-tests/src/main/resources/oldAddressSpace/artemisServer.groovy @@ -1,4 +1,4 @@ -package servers +package oldAddressSpace import org.apache.activemq.artemis.api.core.RoutingType import org.apache.activemq.artemis.api.core.SimpleString diff --git a/tests/compatibility-tests/src/main/resources/oldAddressSpace/receiveMessages.groovy b/tests/compatibility-tests/src/main/resources/oldAddressSpace/receiveMessages.groovy index 149a6b79ee..1594cc8a1a 100644 --- a/tests/compatibility-tests/src/main/resources/oldAddressSpace/receiveMessages.groovy +++ b/tests/compatibility-tests/src/main/resources/oldAddressSpace/receiveMessages.groovy @@ -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); diff --git a/tests/compatibility-tests/src/main/resources/oldAddressSpace/sendMessagesAddress.groovy b/tests/compatibility-tests/src/main/resources/oldAddressSpace/sendMessagesAddress.groovy index afd30b1696..9ade9bbb0f 100644 --- a/tests/compatibility-tests/src/main/resources/oldAddressSpace/sendMessagesAddress.groovy +++ b/tests/compatibility-tests/src/main/resources/oldAddressSpace/sendMessagesAddress.groovy @@ -1,4 +1,4 @@ -package meshTest +package oldAddressSpace import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/OldAddressSpaceTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/OldAddressSpaceTest.java index 4b439a8224..a0803b8cd0 100644 --- a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/OldAddressSpaceTest.java +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/OldAddressSpaceTest.java @@ -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));