private void testDuplicatePutsHelper() throws Exception {
    // Construct a blob store, where there is a duplicate PUT indexValue in different log segment.
    refreshState(false, false, false);
    writeDataToMeetRequiredSegmentCount(1, Collections.singletonList(Utils.Infinite_Time));
    // we know all the IndexEntries are PUT entries.
    TreeMap<MockId, TreeSet<IndexValue>> lastEntry = state.referenceIndex.lastEntry().getValue();
    MockId id = lastEntry.firstKey();
    IndexValue value = lastEntry.get(id).first();
    byte[] bytes = state.logOrder.get(value.getOffset()).getSecond().buffer;

    // Delete some PUT entries, so we know the first log segment will be compacted
    for (MockId toDelete : state.referenceIndex.firstEntry().getValue().keySet()) {
      state.addDeleteEntry(toDelete);
    }
    state.forceAddPutEntry(id, value, bytes);
    writeDataToMeetRequiredSegmentCount(3, Collections.singletonList(Utils.Infinite_Time));

    // Now compact the blobstore, it will fail because of duplicate puts
    state.reloadIndex(true, false);
    long deleteReferenceTimeMs = state.time.milliseconds();
    List<LogSegmentName> segmentsUnderCompaction = getLogSegments(0, state.index.getLogSegmentCount() - 1);
    CompactionDetails details = new CompactionDetails(deleteReferenceTimeMs, segmentsUnderCompaction, null);
    compactor = getCompactor(state.log, DISK_IO_SCHEDULER, null, false);
    compactor.initialize(state.index);

    long duplicateCount = compactor.getTgtMetrics().compactionTargetIndexDuplicateOnNonRecoveryCount.getCount();
    try {
      compactor.compact(details, bundleReadBuffer);
      fail("Should fail with duplicate put");
    } catch (StoreException e) {
      assertEquals(StoreErrorCodes.UnknownError, e.getErrorCode());
      assertTrue(e.getMessage().contains("duplicate PUT"));
    }
    compactor.close(0);
  }
Generate local replica and two peer replicas.
@return a list of replicas (first one is local replica, others are remote peer replicas)
ambry-store/src/test/java/com/github/ambry/store/BlobStoreCompactorTest.java