private void testReadEntry(Path file, int entryCount) throws IOException {
    try (
      WALStreamReader reader = WALFactory.createStreamReader(FS, file, UTIL.getConfiguration())) {
      for (int i = 0; i < entryCount; i++) {
        assertEntryEquals(reader.next(), i);
      }
      assertThrows(EOFException.class, () -> reader.next());
    }
    try (WALTailingReader reader =
      WALFactory.createTailingReader(FS, file, UTIL.getConfiguration(), -1)) {
      for (int i = 0; i < entryCount; i++) {
        WALTailingReader.Result result = reader.next(-1);
        assertEquals(WALTailingReader.State.NORMAL, result.getState());
        assertEntryEquals(result.getEntry(), i);
      }
      WALTailingReader.Result result = reader.next(-1);
      assertEquals(WALTailingReader.State.EOF_AND_RESET, result.getState());
    }
  }
In this test, we write a small WAL file first, and then generate partial WAL file which length is
in range [0, fileLength)(we test all the possible length in the range), to see if we can
successfully get the completed entries, and also get an EOF at the end.
<p/>
It is very important to make sure 3 things:
<ul>
<li>We do not get incorrect entries. Otherwise there will be data corruption.</li>
<li>We can get all the completed entries, i.e, we do not miss some data. Otherwise there will be
data loss.</li>
<li>We will get an EOF finally, instead of a general IOException. Otherwise the split or
replication will be stuck.</li>
</ul>
hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestParsePartialWALFile.java