private void setupAndDoComprehensiveTest(long logCapacity, long segmentCapacity, Appender appender)
      throws IOException, StoreException {
    long numSegments = (logCapacity - 1) / segmentCapacity + 1;
    long maxWriteSize = Math.min(logCapacity, segmentCapacity);
    if (numSegments > 1) {
      // backwards compatibility.
      maxWriteSize -= LogSegment.HEADER_SIZE;
    }
    long[] writeSizes = {1, maxWriteSize, Utils.getRandomLong(TestUtils.RANDOM, maxWriteSize - 2) + 2};
    // the number of segment files to create before creating the log.
    for (int i = 0; i <= numSegments; i++) {
      // the sizes of the writes to the log.
      for (long writeSize : writeSizes) {
        // the index of the pre-created segment file that will be marked as active.
        for (int j = 0; j <= i; j++) {
          List<LogSegmentName> expectedSegmentNames;
          if (i == 0) {
            // first startup case - segment file is not pre-created but will be created by the Log.
            expectedSegmentNames = new ArrayList<>();
            expectedSegmentNames.add(LogSegmentName.generateFirstSegmentName(numSegments > 1));
          } else if (i == j) {
            // invalid index for anything other than i == 0.
            break;
          } else {
            // subsequent startup cases where there have been a few segments created and maybe some are filled.
            expectedSegmentNames = createSegmentFiles(i, numSegments, segmentCapacity);
          }
          expectedSegmentNames = Collections.unmodifiableList(expectedSegmentNames);
          doComprehensiveTest(logCapacity, segmentCapacity, writeSize, expectedSegmentNames, j, appender);
        }
      }
    }
  }
Sets up all the required variables for the comprehensive test.
@param logCapacity the capacity of the log.
@param segmentCapacity the capacity of a single segment in the log.
@param appender the {@link Appender} to use.
@throws IOException
ambry-store/src/test/java/com/github/ambry/store/LogTest.java