@Test
  public void testProcessCompactionLogs() throws Exception {
    // First create some compaction logs
    time.setCurrentMilliseconds(System.currentTimeMillis());
    String storeName = "store";
    List<CompactionDetails> detailsList = getCompactionDetailsList(10);
    List<Long> expectedStartTimes = new ArrayList<>();
    Map<Offset, Offset> expectedIndexSegmentOffsets = new HashMap<>();
    for (CompactionDetails details : detailsList) {
      CompactionLog cLog = new CompactionLog(tempDirStr, storeName, time, details, config);
      Pair<Offset, Offset> pair = addOneIndexSegmentOffsetPair(cLog);
      expectedIndexSegmentOffsets.put(pair.getFirst(), pair.getSecond());
      expectedStartTimes.add(0, time.milliseconds());
      cLog.markCopyStart();
      cLog.markCommitStart();
      cLog.markCleanupStart();
      cLog.markCycleComplete();
      cLog.close();
      Assert.assertFalse(CompactionLog.isCompactionInProgress(tempDirStr, storeName));
      long sleepTime = 3 * Integer.MAX_VALUE;
      time.sleep(sleepTime);
    }

    CompactionDetails details = getCompactionDetailsList(1).get(0);
    CompactionLog cLog = new CompactionLog(tempDirStr, storeName, time, details, config);
    Pair<Offset, Offset> pair = addOneIndexSegmentOffsetPair(cLog);
    expectedIndexSegmentOffsets.put(pair.getFirst(), pair.getSecond());
    expectedStartTimes.add(0, time.milliseconds());
    cLog.close();
    Assert.assertTrue(CompactionLog.isCompactionInProgress(tempDirStr, storeName));

    // Now we have 10 completed compaction logs and one in progress compaction log
    List<Long> obtainedStartTimes = new ArrayList<>();
    Map<Offset, Offset> obtainedIndexSegmentOffsets = new HashMap<>();
    CompactionLog.processCompactionLogs(tempDirStr, storeName, STORE_KEY_FACTORY, time, config, log -> {
      obtainedStartTimes.add(log.getStartTime());
      obtainedIndexSegmentOffsets.putAll(log.getBeforeAndAfterIndexSegmentOffsets());
      return true;
    });

    Assert.assertEquals(11, obtainedStartTimes.size());
    Assert.assertEquals(11, obtainedIndexSegmentOffsets.size());

    Assert.assertEquals(expectedIndexSegmentOffsets, obtainedIndexSegmentOffsets);
    Assert.assertEquals(expectedStartTimes, obtainedStartTimes);
  }
Test {@link CompactionLog#processCompactionLogs}.
@throws Exception
ambry-store/src/test/java/com/github/ambry/store/CompactionLogTest.java