HBASE-19986 If HBaseTestClassRule timesout a test, thread dump

This commit is contained in:
Michael Stack 2018-02-12 14:00:35 -08:00
parent 1ae64ccee0
commit e94f082776
4 changed files with 19 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/** /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
@ -18,6 +18,7 @@
package org.apache.hadoop.hbase; package org.apache.hadoop.hbase;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.testclassification.SmallTests;

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.hbase; package org.apache.hadoop.hbase;
import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Threads;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
@ -41,6 +42,18 @@ public class TestTimeout {
*/ */
@Ignore @Test @Ignore @Test
public void infiniteLoop() { 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.
}
} }
} }

View File

@ -61,6 +61,7 @@ public class TimedOutTestsListener extends RunListener {
output.println(); output.println();
output.print(buildThreadDiagnosticString()); output.print(buildThreadDiagnosticString());
} }
output.flush();
} }
public static String buildThreadDiagnosticString() { public static String buildThreadDiagnosticString() {

View File

@ -614,7 +614,7 @@
<properties> <properties>
<property> <property>
<name>listener</name> <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> </property>
</properties> </properties>
</configuration> </configuration>