private void waitForAllRegionsAssigned() throws IOException {
    while (true) {
      int regionCount = HBaseTestingUtil.getAllOnlineRegions(cluster).size();
      if (regionCount >= totalRegionNum) break;
      LOG.debug("Waiting for there to be " + totalRegionNum + " regions, but there are "
        + regionCount + " right now.");
      try {
        Thread.sleep(100);
      } catch (InterruptedException e) {
      }
    }
  }
Wait until all the regions are assigned.
hbase-server/src/test/java/org/apache/hadoop/hbase/TestGlobalMemStoreSize.java