Repository: activemq-artemis
Updated Branches:
  refs/heads/master dbd8bdbd8 -> 90d05bb17


Improving openwire tests on the integration-testsuite

In one situation I have seen a failrue on ProducerFlowControl to break 
everything else from here
This change will both avoid the failure and change the report of leaked threads 
so we can find them easily on the system.out when it happens (for future 
debugging)


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/90d05bb1
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/90d05bb1
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/90d05bb1

Branch: refs/heads/master
Commit: 90d05bb17d348935643ed807a2eee5019ba69c07
Parents: dbd8bdb
Author: Clebert Suconic <clebertsuco...@apache.org>
Authored: Thu Sep 3 19:16:17 2015 -0400
Committer: Clebert Suconic <clebertsuco...@apache.org>
Committed: Thu Sep 3 19:16:19 2015 -0400

----------------------------------------------------------------------
 .../artemis/tests/util/ActiveMQTestBase.java    | 14 ++++++++++---
 .../integration/openwire/BasicOpenWireTest.java | 21 +++++++++++++-------
 .../openwire/amq/ProducerFlowControlTest.java   | 13 +++++++++---
 3 files changed, 35 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/90d05bb1/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
----------------------------------------------------------------------
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 ab68c8d..436ec3c 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);
    }
 
    /**

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/90d05bb1/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java
----------------------------------------------------------------------
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 49e8931..01dafe0 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<SimpleString> 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);
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/90d05bb1/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/ProducerFlowControlTest.java
----------------------------------------------------------------------
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 a195097..cc4d3f0 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();

Reply via email to