@Test
  public void testRpcRetryingCallerSleep() throws Exception {
    TableDescriptor htd = TableDescriptorBuilder.newBuilder(tableName)
      .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAM_NAM))
      .setCoprocessor(CoprocessorDescriptorBuilder.newBuilder(SleepAndFailFirstTime.class.getName())
        .setProperty(SleepAndFailFirstTime.SLEEP_TIME_CONF_KEY, String.valueOf(2000)).build())
      .build();
    TEST_UTIL.getAdmin().createTable(htd);

    Configuration c = new Configuration(TEST_UTIL.getConfiguration());
    c.setInt(HConstants.HBASE_CLIENT_PAUSE, 3000);
    c.setInt(HConstants.HBASE_RPC_TIMEOUT_KEY, 4000);

    try (Connection conn = ConnectionFactory.createConnection(c)) {
      SleepAndFailFirstTime.ct.set(0);
      try (Table table = conn.getTableBuilder(tableName, null).setOperationTimeout(8000).build()) {
        // Check that it works. Because 2s + 3s * RETRY_BACKOFF[0] + 2s < 8s
        table.get(new Get(FAM_NAM));
      }
      SleepAndFailFirstTime.ct.set(0);
      try (Table table = conn.getTableBuilder(tableName, null).setOperationTimeout(6000).build()) {
        // Will fail this time. After sleep, there are not enough time for second retry
        // Beacuse 2s + 3s + 2s > 6s
        table.get(new Get(FAM_NAM));
        fail("We expect an exception here");
      } catch (RetriesExhaustedException e) {
        LOG.info("We received an exception, as expected ", e);
      }
    }
  }
Test starting from 0 index when RpcRetryingCaller calculate the backoff time.
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCISleep.java