private void verifyStorePostCompaction(List<LogSegmentName> segmentsCompacted,
      List<LogSegmentName> unaffectedSegments, long targetSegmentsExpectedValidSize,
      List<LogEntry> validLogEntriesInOrder) throws StoreException {
    long highestGeneration = 0;
    for (LogSegmentName segmentCompacted : segmentsCompacted) {
      highestGeneration = Math.max(highestGeneration, segmentCompacted.getGeneration());
    }
    highestGeneration++;
    long lowestPosition = segmentsCompacted.get(0).getPosition();
    long highestPosition = segmentsCompacted.get(segmentsCompacted.size() - 1).getPosition();
    long sizeOfTargetSegments = 0;
    Set<Long> positionsEncountered = new HashSet<>();
    Set<LogSegmentName> allSegmentNames = new HashSet<>();
    List<LogSegmentName> nonTargetSegmentNames = new ArrayList<>();
    List<LogSegmentName> targetSegmentNames = new ArrayList<>();
    LogSegment segment = state.log.getFirstSegment();
    while (segment != null) {
      LogSegmentName segmentName = segment.getName();
      allSegmentNames.add(segmentName);
      assertFalse("Segment " + segmentName + " should not exist", segmentsCompacted.contains(segmentName));
      long pos = segmentName.getPosition();
      assertFalse("Encountered two log segments with the same position", positionsEncountered.contains(pos));
      positionsEncountered.add(pos);
      long gen = segmentName.getGeneration();
      if (pos >= lowestPosition && pos <= highestPosition) {
        assertEquals("Generation should have changed", highestGeneration, gen);
        sizeOfTargetSegments += segment.getEndOffset() - LogSegment.HEADER_SIZE;
        targetSegmentNames.add(segmentName);
      } else {
        nonTargetSegmentNames.add(segmentName);
      }
      segment = state.log.getNextSegment(segment);
    }
    assertEquals("Valid size of target segments not as expected", targetSegmentsExpectedValidSize,
        sizeOfTargetSegments);
    // if the target segments have no valid size, there should be no entries in targetSegmentNames
    if (targetSegmentsExpectedValidSize == 0) {
      assertEquals("There should be no target segments since valid size is 0", 0, targetSegmentNames.size());
    }
    assertEquals("Segments not under compaction missing", unaffectedSegments, nonTargetSegmentNames);
    // TODO: verify that the number of index segments in mem == on disk.
    Offset lastIndexSegmentStartOffset = state.index.getIndexSegments().lastKey();
    for (Map.Entry<Offset, IndexSegment> indexSegmentEntry : state.index.getIndexSegments().entrySet()) {
      Offset indexSegmentStartOffset = indexSegmentEntry.getKey();
      assertTrue("Index segment does not refer to any active log segments",
          allSegmentNames.contains(indexSegmentEntry.getKey().getName()));
      assertEquals("Index segment sealed state not as expected",
          !indexSegmentStartOffset.equals(lastIndexSegmentStartOffset), indexSegmentEntry.getValue().isSealed());
    }
    // verify sanity of compacted index
    state.verifyRealIndexSanity();
    // verify ordering
    assertEquals("Ordering after compaction is inconsistent", validLogEntriesInOrder,
        getLogEntriesInOrder(targetSegmentNames));
    // no clean shutdown file should exist
    assertFalse("Clean shutdown file not deleted",
        new File(tempDirStr, BlobStoreCompactor.TARGET_INDEX_CLEAN_SHUTDOWN_FILE_NAME).exists());
    // there should be no temp files
    assertEquals("There are some temp log segments", 0,
        tempDir.listFiles(BlobStoreCompactor.TEMP_LOG_SEGMENTS_FILTER).length);
  }
Verifies integrity of store post compaction.
1. Checks that there aren't two log segments at the same position.
2. Checks that the generation number of the compacted segments has been incremented.
3. Checks that the valid size of data in the new segments is as expected.
4. Checks that {@code unaffectedSegments} have been left untouched.
5. Checks that all existing index segments refer to valid log segments are mapped correctly/
6. Verifies sanity of the new index by calling {@link CuratedLogIndexState#verifyRealIndexSanity()}.
7. Verifies that the ordering of data in the log segments has not changed.
8. Verifies that no temporary files have been left behind.
@param segmentsCompacted the names of the log segments that were compacted.
@param unaffectedSegments the names of the log segments that should have been unaffected.
@param targetSegmentsExpectedValidSize the expected valid size of all the new segments that were created due to
                                       compaction.
@param validLogEntriesInOrder the log entries for valid data before compaction in order. The new segments should
                              have all of these entries and in the same order.
@throws StoreException
ambry-store/src/test/java/com/github/ambry/store/BlobStoreCompactorTest.java