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
* 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;

View File

@ -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.
}
}
}

View File

@ -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() {

View File

@ -614,7 +614,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>