@Test
public void testIncorrectCommitMarker() throws Exception {

  Path newLog = new Path(TMP_FOLDER.newFolder().getAbsolutePath(), LOG_FILE);
  // Write an incorrect marker
  try (SequenceFile.Writer writer = SequenceFile.createWriter(fs, conf, newLog, LongWritable.class,
                                                              LongWritable.class,
                                                              SequenceFile.CompressionType.NONE)) {
    String invalidKey = "IncorrectKey";
    SequenceFile.ValueBytes valueBytes = new CommitMarkerCodec.CommitEntriesCount(100);
    writer.appendRaw(invalidKey.getBytes(), 0, invalidKey.length(), valueBytes);
    writer.hflush();
    writer.hsync();
  }
  // Read the commit markers back to verify the marker
  try (SequenceFile.Reader reader = new SequenceFile.Reader(fs, newLog, conf);
       CommitMarkerCodec markerCodec = new CommitMarkerCodec()) {
    try {
      markerCodec.readMarker(reader);
      Assert.fail("Expected an IOException to be thrown");
    } catch (IOException e) {
      // expected
    }
  }
}