HBASE-19986 If HBaseTestClassRule timesout a test, thread dump
This commit is contained in:
parent
00f8877323
commit
c2ee82c909
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,6 +18,7 @@
|
|||
package org.apache.hadoop.hbase;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.hadoop.hbase;
|
||||
|
||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||
import org.apache.hadoop.hbase.util.Threads;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
@ -41,6 +42,18 @@ public class TestTimeout {
|
|||
*/
|
||||
@Ignore @Test
|
||||
public void infiniteLoop() {
|
||||
while (true) {}
|
||||
// Launch a background non-daemon thread.
|
||||
Thread t = new Thread("HangingThread") {
|
||||
public void run() {
|
||||
synchronized(this) {
|
||||
while(true) {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
while (true) {
|
||||
// Just hang out too.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,12 +55,13 @@ public class TimedOutTestsListener extends RunListener {
|
|||
|
||||
@Override
|
||||
public void testFailure(Failure failure) throws Exception {
|
||||
if (failure != null && failure.getMessage() != null
|
||||
if (failure != null && failure.getMessage() != null
|
||||
&& failure.getMessage().startsWith(TEST_TIMED_OUT_PREFIX)) {
|
||||
output.println("====> TEST TIMED OUT. PRINTING THREAD DUMP. <====");
|
||||
output.println();
|
||||
output.print(buildThreadDiagnosticString());
|
||||
}
|
||||
output.flush();
|
||||
}
|
||||
|
||||
public static String buildThreadDiagnosticString() {
|
2
pom.xml
2
pom.xml
|
@ -677,7 +677,7 @@
|
|||
<properties>
|
||||
<property>
|
||||
<name>listener</name>
|
||||
<value>org.apache.hadoop.hbase.HBaseClassTestRuleChecker,org.apache.hadoop.hbase.ResourceCheckerJUnitListener</value>
|
||||
<value>org.apache.hadoop.hbase.TimedOutTestsListener,org.apache.hadoop.hbase.HBaseClassTestRuleChecker,org.apache.hadoop.hbase.ResourceCheckerJUnitListener</value>
|
||||
</property>
|
||||
</properties>
|
||||
</configuration>
|
||||
|
|
Loading…
Reference in New Issue