private static void loadData(final Table ht, final byte[][] families, final int rows,
    final int flushes) throws IOException {
    List<Put> puts = new ArrayList<>(rows);
    byte[] qualifier = Bytes.toBytes("val");
    Random rand = ThreadLocalRandom.current();
    for (int i = 0; i < flushes; i++) {
      for (int k = 0; k < rows; k++) {
        byte[] row = Bytes.toBytes(rand.nextLong());
        Put p = new Put(row);
        for (int j = 0; j < families.length; ++j) {
          p.addColumn(families[j], qualifier, row);
        }
        puts.add(p);
      }
      ht.put(puts);
      TEST_UTIL.flush();
      puts.clear();
    }
  }
Load data to a table, flush it to disk, trigger compaction, confirm the compaction state is
right and wait till it is done.
@param singleFamily otherwise, run compaction on all cfs
@param stateSource  get the state by Admin or Master
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionState.java