private static CompactionState getCompactionState(StateSource stateSource, HMaster master,
    Admin admin, TableName table) throws IOException {
    CompactionState state = stateSource == StateSource.ADMIN
      ? admin.getCompactionState(table)
      : master.getCompactionState(table);
    return state;
  }
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