private List<LogSegmentName> createSegmentFiles(int numToCreate, long numFinalSegments, long segmentCapacity)
      throws IOException, StoreException {
    if (numToCreate > numFinalSegments) {
      throw new IllegalArgumentException("num segments to create cannot be more than num final segments");
    }
    List<LogSegmentName> segmentNames = new ArrayList<>(numToCreate);
    if (numFinalSegments == 1) {
      LogSegmentName name = LogSegmentName.generateFirstSegmentName(false);
      File file = create(name.toFilename());
      new LogSegment(name, file, segmentCapacity, createStoreConfig(segmentCapacity, setFilePermissionEnabled), metrics,
          false).close(false);
      segmentNames.add(name);
    } else {
      for (int i = 0; i < numToCreate; i++) {
        long pos;
        do {
          pos = Utils.getRandomLong(TestUtils.RANDOM, 1000000);
        } while (positionsGenerated.contains(pos));
        positionsGenerated.add(pos);
        long gen = Utils.getRandomLong(TestUtils.RANDOM, 1000);
        LogSegmentName name = LogSegmentName.fromPositionAndGeneration(pos, gen);
        File file = create(name.toFilename());
        new LogSegment(name, file, segmentCapacity, createStoreConfig(segmentCapacity, setFilePermissionEnabled),
            metrics, true).close(false);
        segmentNames.add(name);
      }
    }
    Collections.sort(segmentNames);
    return segmentNames;
  }
Creates {@code numToCreate} segment files on disk.
@param numToCreate the number of segment files to create.
@param numFinalSegments the total number of segment files in the log.
@return the names of the created files.
@throws IOException
ambry-store/src/test/java/com/github/ambry/store/LogTest.java