@Test
  public void testRpcTimeout() throws IOException {
    Configuration c = new Configuration(TEST_UTIL.getConfiguration());
    try (Table table = TEST_UTIL.getConnection().getTableBuilder(tableName, null)
      .setRpcTimeout(SleepCoprocessor.SLEEP_TIME / 2)
      .setReadRpcTimeout(SleepCoprocessor.SLEEP_TIME / 2)
      .setWriteRpcTimeout(SleepCoprocessor.SLEEP_TIME / 2)
      .setOperationTimeout(SleepCoprocessor.SLEEP_TIME * 100).build()) {
      execute(table);
      fail("Get should not have succeeded");
    } catch (RetriesExhaustedException e) {
      LOG.info("We received an exception, as expected ", e);
    }

    // Again, with configuration based override
    c.setInt(HConstants.HBASE_RPC_TIMEOUT_KEY, SleepCoprocessor.SLEEP_TIME / 2);
    c.setInt(HConstants.HBASE_RPC_READ_TIMEOUT_KEY, SleepCoprocessor.SLEEP_TIME / 2);
    c.setInt(HConstants.HBASE_RPC_WRITE_TIMEOUT_KEY, SleepCoprocessor.SLEEP_TIME / 2);
    c.setInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, SleepCoprocessor.SLEEP_TIME * 100);
    try (Connection conn = ConnectionFactory.createConnection(c)) {
      try (Table table = conn.getTable(tableName)) {
        execute(table);
        fail("Get should not have succeeded");
      } catch (RetriesExhaustedException e) {
        LOG.info("We received an exception, as expected ", e);
      }
    }
  }
Based class for testing rpc timeout logic.
hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestCIRpcTimeout.java