@Test
  public void testCompactionHighWatermarkIsHonored() throws Exception {
    String dbName = "default";
    String tblName = "trfcp";
    String partName = "ds=today";
    Table t = newTable(dbName, tblName, true);
    Partition p = newPartition(t, "today");

    // minor compaction
    addBaseFile(t, p, 19L, 19);
    addDeltaFile(t, p, 20L, 20L, 1);
    addDeltaFile(t, p, 21L, 21L, 1);
    addDeltaFile(t, p, 22L, 22L, 1);
    burnThroughTransactions(dbName, tblName, 22);

    CompactionRequest rqst = new CompactionRequest(dbName, tblName, CompactionType.MINOR);
    rqst.setPartitionname(partName);
    long ctxnid = compactInTxn(rqst);
    addDeltaFile(t, p, 20, 22, 3, ctxnid);

    // block cleaner with an open txn
    long openTxnId = openTxn();

    //2nd minor
    addDeltaFile(t, p, 23L, 23L, 1);
    addDeltaFile(t, p, 24L, 24L, 1);
    burnThroughTransactions(dbName, tblName, 2);

    rqst = new CompactionRequest(dbName, tblName, CompactionType.MINOR);
    rqst.setPartitionname(partName);
    ctxnid = compactInTxn(rqst);
    addDeltaFile(t, p, 20, 24, 5, ctxnid);

    startCleaner();
    txnHandler.abortTxn(new AbortTxnRequest(openTxnId));

    ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest());
    Assert.assertEquals(2, rsp.getCompactsSize());
    Assert.assertEquals(TxnStore.SUCCEEDED_RESPONSE, rsp.getCompacts().get(0).getState());
    Assert.assertEquals(TxnStore.CLEANING_RESPONSE, rsp.getCompacts().get(1).getState());

    List<String> actualDirs = getDirectories(conf, t, p).stream()
      .map(Path::getName).sorted()
      .collect(Collectors.toList());
    
    List<String> expectedDirs = Arrays.asList(
      "base_19",
      addVisibilitySuffix(makeDeltaDirName(20, 22), 23),
      addVisibilitySuffix(makeDeltaDirName(20, 24), 27),
      makeDeltaDirName(23, 23),
      makeDeltaDirName(24, 24)
    );
    Assert.assertEquals("Directories do not match", expectedDirs, actualDirs);
  }
Tests for the compactor Cleaner thread
ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestCleaner.java