diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/trace/TestHTraceHooks.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/trace/TestHTraceHooks.java index faf015cb347..3595c392e34 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/trace/TestHTraceHooks.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/trace/TestHTraceHooks.java @@ -25,6 +25,7 @@ import java.util.Collection; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.MediumTests; +import org.apache.hadoop.hbase.Waiter; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Put; import org.cloudera.htrace.Sampler; @@ -71,6 +72,15 @@ public class TestHTraceHooks { tableCreationSpan.close(); } + // Some table creation is async. Need to make sure that everything is full in before + // checking to see if the spans are there. + TEST_UTIL.waitFor(1000, new Waiter.Predicate() { + @Override + public boolean evaluate() throws Exception { + return rcvr.getSpans().size() >= 5; + } + }); + Collection spans = rcvr.getSpans(); TraceTree traceTree = new TraceTree(spans); Collection roots = traceTree.getRoots();