diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java index ab68c8d91b..436ec3c6c7 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java @@ -292,6 +292,8 @@ public abstract class ActiveMQTestBase extends Assert { boolean failed = true; + boolean failedOnce = false; + long timeout = System.currentTimeMillis() + 60000; while (failed && timeout > System.currentTimeMillis()) { buffer = new StringBuffer(); @@ -299,6 +301,7 @@ public abstract class ActiveMQTestBase extends Assert { failed = checkThread(buffer); if (failed) { + failedOnce = true; forceGC(); Thread.sleep(500); log.info("There are still threads running, trying again"); @@ -309,10 +312,15 @@ public abstract class ActiveMQTestBase extends Assert { if (failed) { logAndSystemOut("Thread leaked on test " + this.getClass().getName() + "::" + this.getName() + "\n" + buffer); - logAndSystemOut("Thread leakage"); + logAndSystemOut("Thread leakage! Failure!!!"); fail("Thread leaked"); } + else if (failedOnce) { + System.out.println("******************** Threads cleared after retries ********************"); + System.out.println(); + } + } else { @@ -598,12 +606,12 @@ public abstract class ActiveMQTestBase extends Assert { * Sends the message to both logger and System.out (for unit report) */ public void logAndSystemOut(String message, Exception e) { - ActiveMQServerLogger log0 = ActiveMQServerLogger.LOGGER; - log0.info(message, e); System.out.println(message); if (e != null) { e.printStackTrace(System.out); } + ActiveMQServerLogger log0 = ActiveMQServerLogger.LOGGER; + log0.debug(message, e); } /** diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java index 49e89310a9..01dafe0f0c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java @@ -16,10 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.openwire; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -27,11 +23,15 @@ import javax.jms.Message; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException; import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.command.ActiveMQDestination; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -91,8 +91,15 @@ public class BasicOpenWireTest extends OpenWireTestBase { Iterator iterQueues = testQueues.values().iterator(); while (iterQueues.hasNext()) { SimpleString coreQ = iterQueues.next(); - if (server.locateQueue(coreQ) != null) { - this.server.destroyQueue(coreQ); + try { + this.server.destroyQueue(coreQ, null, false, true); + } + catch (ActiveMQNonExistentQueueException idontcare) { + // i don't care if this failed. it means it didn't find the queue + } + catch (Throwable e) { + // just print, what else can we do? + e.printStackTrace(); } System.out.println("Destroyed queue: " + coreQ); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerFlowControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerFlowControlTest.java index a195097881..cc4d3f0218 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerFlowControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerFlowControlTest.java @@ -29,11 +29,11 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.transport.tcp.TcpTransport; import org.junit.After; import org.junit.Before; @@ -340,9 +340,16 @@ public class ProducerFlowControlTest extends BasicOpenWireTest { try { if (flowControlConnection != null) { TcpTransport t = (TcpTransport) flowControlConnection.getTransport().narrow(TcpTransport.class); + try { + flowControlConnection.getTransport().stop(); + flowControlConnection.close(); + } + catch (Throwable ignored) { + // sometimes the disposed up can make the test to fail + // even worse I have seen this breaking every single test after this + // if not caught here + } t.getTransportListener().onException(new IOException("Disposed.")); - flowControlConnection.getTransport().stop(); - flowControlConnection.close(); } if (asyncThread != null) { asyncThread.join();