@Test
  public void testNettyWritableFatalThreshold() throws Exception {
    Configuration conf = HBaseConfiguration.create();
    conf.setInt(NettyRpcServer.CHANNEL_WRITABLE_FATAL_WATERMARK_KEY, 1);

    // flushAfter is 3 here, with requestCount 5 below. If we never flush, the WriteTasks will sit
    // in the eventloop. So we flush a few at once, which will ensure that we hit fatal threshold
    NettyRpcServer rpcServer = createRpcServer(conf, 3);
    try {
      CompletionException exception =
        assertThrows(CompletionException.class, () -> sendAndReceive(conf, rpcServer, 5));
      assertTrue(exception.getCause().getCause() instanceof ServiceException);
      METRICS_ASSERT.assertCounterGt("maxOutboundBytesExceeded", 0,
        rpcServer.metrics.getMetricsSource());
    } finally {
      rpcServer.stop();
    }
  }
Test that our fatal watermark is honored, which requires artificially causing some queueing so
that pendingOutboundBytes increases.
hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyChannelWritability.java