From 8915130dd7f3e497083c9fa9a25c511dd3787082 Mon Sep 17 00:00:00 2001 From: stack Date: Thu, 9 Oct 2014 16:12:07 -0700 Subject: [PATCH] HBASE-12212 HBaseTestingUtility#waitUntilAllRegionsAssigned should wait for RegionStates Signed-off-by: stack --- .../org/apache/hadoop/hbase/HBaseTestingUtility.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index 238282727ea..bbd9dbe3c3f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -3045,6 +3045,17 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { } finally { meta.close(); } + // So, all regions are in the meta table but make sure master knows of the assignments before + // returing -- sometimes this can lag. + HMaster master = getHBaseCluster().getMaster(); + final RegionStates states = master.getAssignmentManager().getRegionStates(); + waitFor(timeout, 200, new Predicate() { + @Override + public boolean evaluate() throws IOException { + List hris = states.getRegionsOfTable(tableName); + return hris != null && !hris.isEmpty(); + } + }); } /**