private void waitRegionsAfterMerge(final long numRegionsAfterMerge)
    throws IOException, InterruptedException {
    // Verify that there's one region less
    long startTime = EnvironmentEdgeManager.currentTime();
    while (admin.getRegions(TABLE_NAME).size() != numRegionsAfterMerge) {
      // This may be flaky... if after 15sec the merge is not complete give up
      // it will fail in the assertEquals(numRegionsAfterMerge).
      if ((EnvironmentEdgeManager.currentTime() - startTime) > 15000) {
        break;
      }
      Thread.sleep(100);
    }
    SnapshotTestingUtils.waitForTableToBeOnline(UTIL, TABLE_NAME);
  }
Basic end-to-end test of simple-flush-based snapshots
hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestFlushSnapshotFromClient.java