mirror of https://github.com/apache/activemq.git
make amq-2183 test auto fail as it hangs in hudson, add a thread dump to help diagnose
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@812394 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a33f73e202
commit
2b0a194416
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.activemq;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -78,6 +80,7 @@ public abstract class AutoFailTestSupport extends TestCase {
|
|||
if (!isTestSuccess.get()) {
|
||||
LOG.error("Test case has exceeded the maximum allotted time to run of: " + getMaxTestTime() + " ms.");
|
||||
LOG.fatal("Test case has exceeded the maximum allotted time to run of: " + getMaxTestTime() + " ms.");
|
||||
dumpAllThreads(getName());
|
||||
System.exit(EXIT_ERROR);
|
||||
}
|
||||
}
|
||||
|
@ -138,4 +141,15 @@ public abstract class AutoFailTestSupport extends TestCase {
|
|||
public long getMaxTestTime() {
|
||||
return this.maxTestTime;
|
||||
}
|
||||
|
||||
|
||||
public static void dumpAllThreads(String prefix) {
|
||||
Map<Thread, StackTraceElement[]> stacks = Thread.getAllStackTraces();
|
||||
for (Entry<Thread, StackTraceElement[]> stackEntry : stacks.entrySet()) {
|
||||
System.err.println(prefix + " " + stackEntry.getKey());
|
||||
for(StackTraceElement element : stackEntry.getValue()) {
|
||||
System.err.println(" " + element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.activemq.bugs;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.AutoFailTestSupport;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.util.Wait;
|
||||
import org.apache.log4j.Logger;
|
||||
|
@ -200,23 +201,14 @@ public class AMQ1936Test extends TestCase{
|
|||
}
|
||||
}, 1*60*1000);
|
||||
if (!ok) {
|
||||
dumpAllThreads("--STUCK?--");
|
||||
AutoFailTestSupport.dumpAllThreads("--STUCK?--");
|
||||
}
|
||||
assertEquals( "Number of messages received does not match the number sent", TEST_MESSAGE_COUNT, messages.size( ) );
|
||||
assertEquals( TEST_MESSAGE_COUNT, messageCount.get() );
|
||||
}
|
||||
|
||||
|
||||
private void dumpAllThreads(String prefix) {
|
||||
Map<Thread, StackTraceElement[]> stacks = Thread.getAllStackTraces();
|
||||
for (Entry<Thread, StackTraceElement[]> stackEntry : stacks.entrySet()) {
|
||||
System.err.println(prefix + stackEntry.getKey());
|
||||
for(StackTraceElement element : stackEntry.getValue()) {
|
||||
System.err.println(" " + element);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private final static class ThreadedMessageReceiver implements Runnable {
|
||||
|
||||
private String queueName = null;
|
||||
|
|
|
@ -32,6 +32,7 @@ import javax.jms.Session;
|
|||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.AutoFailTestSupport;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.apache.activemq.command.ActiveMQTopic;
|
||||
|
@ -40,7 +41,7 @@ import org.apache.activemq.util.Wait.Condition;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class AMQ2183Test extends TestCase implements UncaughtExceptionHandler, MessageListener {
|
||||
public class AMQ2183Test extends AutoFailTestSupport implements UncaughtExceptionHandler, MessageListener {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(AMQ2183Test.class);
|
||||
private static final int maxSent = 2000;
|
||||
|
@ -55,7 +56,8 @@ public class AMQ2183Test extends TestCase implements UncaughtExceptionHandler, M
|
|||
}
|
||||
|
||||
public void setUp() throws Exception {
|
||||
|
||||
setAutoFail(true);
|
||||
super.setUp();
|
||||
master = new BrokerService();
|
||||
slave = new BrokerService();
|
||||
|
||||
|
|
Loading…
Reference in New Issue