@Test
  public void closeLogSegmentAndSkipFlushTest() throws Exception {
    Pair<LogSegment, FileChannel> segmentAndFileChannel =
        getSegmentAndFileChannel(LogSegmentName.SINGLE_SEGMENT_LOG_FILE_NAME);
    LogSegment segment = segmentAndFileChannel.getFirst();
    FileChannel mockFileChannel = segmentAndFileChannel.getSecond();
    verify(mockFileChannel).force(true);

    // test that log segment is being closed due to disk I/O error and flush operation should be skipped
    segment.close(true);
    verify(mockFileChannel).force(true);
    assertFalse("File channel is not closed", segment.getView().getSecond().isOpen());
    assertTrue("File couldn't be deleted.", (new File(tempDir, LogSegmentName.SINGLE_SEGMENT_LOG_FILE_NAME).delete()));
  }
Test that closing log segment and skip any disk flush operation. Verify that flush method is never invoked.
@throws Exception
ambry-store/src/test/java/com/github/ambry/store/LogSegmentTest.java