@Test
  public void testSizeOfLogQueue() throws Exception {
    // There should be always 1 log which is current wal.
    assertEquals(1, logQueue.getMetrics().getSizeOfLogQueue());
    appendToLogAndSync();

    log.rollWriter();
    // wait until the previous WAL file is cleanly closed, so later we can aleays see
    // RETRY_IMMEDIATELY instead of RETRY. The wait here is necessary because the closing of a WAL
    // writer is asynchronouns
    TEST_UTIL.waitFor(30000, () -> fs.getClient().isFileClosed(logQueue.getQueue(fakeWalGroupId)
      .peek().makeQualified(fs.getUri(), fs.getWorkingDirectory()).toUri().getPath()));
    // After rolling there will be 2 wals in the queue
    assertEquals(2, logQueue.getMetrics().getSizeOfLogQueue());

    try (WALEntryStream entryStream =
      new WALEntryStream(logQueue, fs, CONF, 0, log, logQueue.getMetrics(), fakeWalGroupId)) {
      // There's one edit in the log, read it.
      assertNotNull(next(entryStream));
      // we've switched to the next WAL, and the previous WAL file is closed cleanly, so it is
      // RETRY_IMMEDIATELY
      assertEquals(HasNext.RETRY_IMMEDIATELY, entryStream.hasNext());
    }
    // After removing one wal, size of log queue will be 1 again.
    assertEquals(1, logQueue.getMetrics().getSizeOfLogQueue());
  }
Tests size of log queue is incremented and decremented properly.
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStream.java