@Test
  public void iterationWithoutReloadTest() throws IOException {
    String storeName = "store";
    List<CompactionDetails> detailsList = getCompactionDetailsList(5);
    CompactionDetails combined = combineListOfDetails(detailsList);
    assertFalse("Compaction should not be in progress", CompactionLog.isCompactionInProgress(tempDirStr, storeName));
    CompactionLog cLog = new CompactionLog(tempDirStr, storeName, time, combined, config);
    assertTrue("Compaction should be in progress", CompactionLog.isCompactionInProgress(tempDirStr, storeName));
    int currentIdx = 0;
    Iterator<CompactionDetails> detailsIterator = detailsList.iterator();
    CompactionDetails currDetails = detailsIterator.next();
    while (currDetails != null) {
      detailsIterator.remove();
      assertEquals("CurrentIdx not as expected", currentIdx, cLog.getCurrentIdx());
      verifyEquality(combined, cLog.getCompactionDetails());
      assertEquals("Should be in the PREPARE phase", CompactionLog.Phase.PREPARE, cLog.getCompactionPhase());
      cLog.markCopyStart();
      assertEquals("Should be in the COPY phase", CompactionLog.Phase.COPY, cLog.getCompactionPhase());
      Offset offset = new Offset(LogSegmentName.generateFirstSegmentName(true),
          Utils.getRandomLong(TestUtils.RANDOM, Long.MAX_VALUE));
      cLog.setStartOffsetOfLastIndexSegmentForDeleteCheck(offset);
      assertEquals("Offset that was set was not the one returned", offset,
          cLog.getStartOffsetOfLastIndexSegmentForDeleteCheck());
      StoreFindToken safeToken =
          new StoreFindToken(new MockId("dummy"), new Offset(LogSegmentName.generateFirstSegmentName(true), 0),
              new UUID(1, 1), new UUID(1, 1), null, null, UNINITIALIZED_RESET_KEY_VERSION);
      cLog.setSafeToken(safeToken);
      assertEquals("Returned token not the same as the one that was set", safeToken, cLog.getSafeToken());
      assertTrue(cLog.isIndexSegmentOffsetsPersisted());
      int sizeBefore = cLog.getBeforeAndAfterIndexSegmentOffsets().size();
      Pair<Offset, Offset> pair = addOneIndexSegmentOffsetPair(cLog);
      cLog.addBeforeAndAfterIndexSegmentOffsetPair(pair.getFirst(), pair.getSecond());
      assertEquals(sizeBefore + 1, cLog.getBeforeAndAfterIndexSegmentOffsets().size());
      try {
        LogSegmentName logSegmentName = StoreTestUtils.getRandomLogSegmentName(generatedSegmentNames);
        Offset before = new Offset(logSegmentName, LogSegment.HEADER_SIZE);
        Offset after = new Offset(logSegmentName.getNextGenerationName(), LogSegment.HEADER_SIZE);
        cLog.addBeforeAndAfterIndexSegmentOffsetPair(before, after);
        fail("Offset " + before + " doesn't belong to under compaction log segment, should fail");
      } catch (Exception e) {
        // Expect to see exception
      }
      CompactionDetails nextDetails = detailsIterator.hasNext() ? detailsIterator.next() : null;
      if (nextDetails != null) {
        cLog.splitCurrentCycle(nextDetails.getLogSegmentsUnderCompaction().get(0));
        verifyEquality(currDetails, cLog.getCompactionDetails());
      }
      cLog.markCommitStart();
      assertEquals("Should be in the SWITCH phase", CompactionLog.Phase.COMMIT, cLog.getCompactionPhase());
      cLog.markCleanupStart();
      assertEquals("Should be in the CLEANUP phase", CompactionLog.Phase.CLEANUP, cLog.getCompactionPhase());
      cLog.markCycleComplete();
      currentIdx++;
      currDetails = nextDetails;
      if (nextDetails != null) {
        combined = combineListOfDetails(detailsList);
      }
    }
    assertEquals("CurrentIdx not as expected", -1, cLog.getCurrentIdx());
    assertEquals("Should be in the DONE phase", CompactionLog.Phase.DONE, cLog.getCompactionPhase());
    cLog.close();
    assertFalse("Compaction should not be in progress", CompactionLog.isCompactionInProgress(tempDirStr, storeName));
  }
Tests the use of {@link CompactionLog} when it is used without closing b/w operations and compaction cycles.
@throws IOException
ambry-store/src/test/java/com/github/ambry/store/CompactionLogTest.java