private void waitForAllRegionsAssigned() throws IOException {
    int totalRegions = HBaseTestingUtil.KEYS.length;
    try {
      Thread.sleep(200);
    } catch (InterruptedException e) {
      throw new InterruptedIOException();
    }
    while (UTIL.getMiniHBaseCluster().countServedRegions() < totalRegions) {
      // while (!cluster.getMaster().allRegionsAssigned()) {
      LOG.debug("Waiting for there to be " + totalRegions + " regions, but there are "
        + UTIL.getMiniHBaseCluster().countServedRegions() + " right now.");
      try {
        Thread.sleep(200);
      } catch (InterruptedException e) {
        throw new InterruptedIOException();
      }
    }
    UTIL.waitUntilNoRegionsInTransition();
  }
Wait until all the regions are assigned.
hbase-server/src/test/java/org/apache/hadoop/hbase/TestRegionRebalancing.java