@Test
  public void testOnlineSlowLogWithHighRecords() throws Exception {

    Configuration conf = applySlowLogRecorderConf(14);
    Constructor<NamedQueueRecorder> constructor =
      NamedQueueRecorder.class.getDeclaredConstructor(Configuration.class);
    constructor.setAccessible(true);
    namedQueueRecorder = constructor.newInstance(conf);
    AdminProtos.SlowLogResponseRequest request =
      AdminProtos.SlowLogResponseRequest.newBuilder().setLimit(14 * 11).build();

    Assert.assertEquals(getSlowLogPayloads(request).size(), 0);
    LOG.debug("Initially ringbuffer of Slow Log records is empty");

    for (int i = 0; i < 14 * 11; i++) {
      RpcLogDetails rpcLogDetails =
        getRpcLogDetails("userName_" + (i + 1), "client_" + (i + 1), "class_" + (i + 1));
      namedQueueRecorder.addRecord(rpcLogDetails);
    }
    LOG.debug("Added 14 * 11 records, ringbuffer should only provide latest 14 records");

    Assert.assertNotEquals(-1,
      HBASE_TESTING_UTILITY.waitFor(3000, () -> getSlowLogPayloads(request).size() == 14));

    Assert.assertNotEquals(-1, HBASE_TESTING_UTILITY.waitFor(3000, () -> {
      List<SlowLogPayload> slowLogPayloads = getSlowLogPayloads(request);

      // confirm strict order of slow log payloads
      return slowLogPayloads.size() == 14 && confirmPayloadParams(0, 154, slowLogPayloads)
        && confirmPayloadParams(1, 153, slowLogPayloads)
        && confirmPayloadParams(2, 152, slowLogPayloads)
        && confirmPayloadParams(3, 151, slowLogPayloads)
        && confirmPayloadParams(4, 150, slowLogPayloads)
        && confirmPayloadParams(5, 149, slowLogPayloads)
        && confirmPayloadParams(6, 148, slowLogPayloads)
        && confirmPayloadParams(7, 147, slowLogPayloads)
        && confirmPayloadParams(8, 146, slowLogPayloads)
        && confirmPayloadParams(9, 145, slowLogPayloads)
        && confirmPayloadParams(10, 144, slowLogPayloads)
        && confirmPayloadParams(11, 143, slowLogPayloads)
        && confirmPayloadParams(12, 142, slowLogPayloads)
        && confirmPayloadParams(13, 141, slowLogPayloads);
    }));

    boolean isRingBufferCleaned =
      namedQueueRecorder.clearNamedQueue(NamedQueuePayload.NamedQueueEvent.SLOW_LOG);
    Assert.assertTrue(isRingBufferCleaned);
    LOG.debug("cleared the ringbuffer of Online Slow Log records");
    List<SlowLogPayload> slowLogPayloads = getSlowLogPayloads(request);

    // confirm ringbuffer is empty
    Assert.assertEquals(slowLogPayloads.size(), 0);
  }
confirm that for a ringbuffer of slow logs, payload on given index of buffer has expected
elements
@param i               index of ringbuffer logs
@param j               data value that was put on index i
@param slowLogPayloads list of payload retrieved from {@link NamedQueueRecorder}
@return if actual values are as per expectations
hbase-server/src/test/java/org/apache/hadoop/hbase/namequeues/TestNamedQueueRecorder.java