private void compactAndWait() throws IOException, InterruptedException {
    LOG.debug("Compacting table " + tableName);
    HRegionServer rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0);
    Admin admin = TEST_UTIL.getAdmin();
    admin.majorCompact(tableName);

    // Waiting for the compaction to start, at least .5s.
    final long maxWaitime = EnvironmentEdgeManager.currentTime() + 500;
    boolean cont;
    do {
      cont = rs.getCompactSplitThread().getCompactionQueueSize() == 0;
      Threads.sleep(1);
    } while (cont && EnvironmentEdgeManager.currentTime() < maxWaitime);

    while (rs.getCompactSplitThread().getCompactionQueueSize() > 0) {
      Threads.sleep(1);
    }
    LOG.debug("Compaction queue size reached 0, continuing");
  }
A zero-based index of the current batch of test data being written
hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestChangingEncoding.java