private void compactAndVerifyForContainerDeletion(List<LogSegmentName> segmentsUnderCompaction,
      long deleteReferenceTimeMs, boolean changeExpected) throws Exception {
    long logSegmentSizeSumBeforeCompaction = getSumOfLogSegmentEndOffsets();
    long logSegmentCountBeforeCompaction = state.index.getLogSegmentCount();
    CompactionDetails details = new CompactionDetails(deleteReferenceTimeMs, segmentsUnderCompaction, null);
    try {
      compactor.compact(details, bundleReadBuffer);
    } finally {
      if (changeExpected) {
        compactor.close(0);
      }
    }
    if (state.log.autoCloseLastLogSegmentIfQualified()) {
      //refresh journal.
      state.index.journal.cleanUpJournal();
    }
    if (!changeExpected) {
      assertEquals("Journal size should be cleaned up after last log segment closed", 0,
          state.index.journal.getCurrentNumberOfEntries());
    }
    long logSegmentSizeAfterCompaction = getSumOfLogSegmentEndOffsets();
    long logSegmentCountAfterCompaction = state.index.getLogSegmentCount();
    if (changeExpected) {
      assertTrue("Last index segment should be compacted",
          logSegmentSizeSumBeforeCompaction - logSegmentSizeAfterCompaction > 0);
      assertEquals("Log Segment count should be same due to no new index entry mapping to the last log segment.",
          logSegmentCountBeforeCompaction, logSegmentCountAfterCompaction);
    }
  }
Compacts the {@code segmentsUnderCompaction} and verifies sanity of store and data.
@param segmentsUnderCompaction the names of the log segments under compaction.
@param deleteReferenceTimeMs the reference time in ms to use to decide whether deletes are valid.
@param changeExpected {@code true} if compaction will cause a change in size of data. {@code false} otherwise.
@throws Exception
ambry-store/src/test/java/com/github/ambry/store/BlobStoreCompactorTest.java