private void doComprehensiveTest(long logCapacity, long segmentCapacity, long writeSize,
      List<LogSegmentName> expectedSegmentNames, int segmentIdxToMarkActive, Appender appender)
      throws IOException, StoreException {
    long numSegments = (logCapacity - 1) / segmentCapacity + 1;
    Log log = new Log(tempDir.getAbsolutePath(), logCapacity, StoreTestUtils.DEFAULT_DISK_SPACE_ALLOCATOR,
        createStoreConfig(segmentCapacity, setFilePermissionEnabled), metrics, null);
    assertEquals("Total capacity not as expected", logCapacity, log.getCapacityInBytes());
    assertEquals("Segment capacity not as expected", Math.min(logCapacity, segmentCapacity), log.getSegmentCapacity());
    try {
      // only preloaded segments should be in expectedSegmentNames.
      checkLog(log, Math.min(logCapacity, segmentCapacity), expectedSegmentNames);
      LogSegmentName activeSegmentName = expectedSegmentNames.get(segmentIdxToMarkActive);
      log.setActiveSegment(activeSegmentName);
      // all segment files from segmentIdxToMarkActive + 1 to expectedSegmentNames.size() - 1 will be freed.
      List<LogSegmentName> prunedSegmentNames = expectedSegmentNames.subList(0, segmentIdxToMarkActive + 1);
      checkLog(log, Math.min(logCapacity, segmentCapacity), prunedSegmentNames);
      List<LogSegmentName> allSegmentNames = getSegmentNames(numSegments, prunedSegmentNames);
      writeAndCheckLog(log, logCapacity, Math.min(logCapacity, segmentCapacity), numSegments - segmentIdxToMarkActive,
          writeSize, allSegmentNames, segmentIdxToMarkActive, appender);
      // log full - so all segments should be there
      assertEquals("Unexpected number of segments", numSegments, allSegmentNames.size());
      checkLog(log, Math.min(logCapacity, segmentCapacity), allSegmentNames);
      flushCloseAndValidate(log);
      checkLogReload(logCapacity, Math.min(logCapacity, segmentCapacity), allSegmentNames);
    } finally {
      log.close(false);
      cleanDirectory(tempDir);
    }
  }
Does the comprehensive test.
1. Creates the log.
2. Checks that the pre created segment files (if any) have been picked up.
3. Sets the active segment.
4. Performs writes until the log is filled and checks end offsets and segment names/counts.
5. Flushes, closes and validates close.
@param logCapacity the log capacity.
@param segmentCapacity the capacity of each segment.
@param writeSize the size of each write to the log.
@param expectedSegmentNames the expected names of the segments in the log.
@param segmentIdxToMarkActive the index of the name of the active segment in {@code expectedSegmentNames}. Also its
                              absolute index in the {@link Log}.
@param appender the {@link Appender} to use.
@throws IOException
ambry-store/src/test/java/com/github/ambry/store/LogTest.java