@Test
  public void testOperationTimeout() throws IOException {
    TableBuilder builder =
      TEST_UTIL.getConnection().getTableBuilder(tableName, null).setRpcTimeout(Integer.MAX_VALUE)
        .setReadRpcTimeout(Integer.MAX_VALUE).setWriteRpcTimeout(Integer.MAX_VALUE);
    // Check that it works if the timeout is big enough
    SleepAndFailFirstTime.ct.set(0);
    try (Table table = builder.setOperationTimeout(120 * 1000).build()) {
      execute(table);
    }
    // Resetting and retrying. Will fail this time, not enough time for the second try
    SleepAndFailFirstTime.ct.set(0);
    try (Table table = builder.setOperationTimeout(30 * 1000).build()) {
      SleepAndFailFirstTime.ct.set(0);
      execute(table);
      fail("We expect an exception here");
    } catch (SocketTimeoutException | RetriesExhaustedException e) {
      // The client has a CallTimeout class, but it's not shared. We're not very clean today,
      // in the general case you can expect the call to stop, but the exception may vary.
      // In this test however, we're sure that it will be a socket timeout.
      LOG.info("We received an exception, as expected ", e);
    }
  }
Test that an operation can fail if we read the global operation timeout, even if the individual
timeout is fine. We do that with:
<ul>
<li>client side: an operation timeout of 30 seconds</li>
<li>server side: we sleep 20 second at each attempt. The first work fails, the second one
succeeds. But the client won't wait that much, because 20 + 20 > 30, so the client timed out
when the server answers.</li>
</ul>
hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestCIOperationTimeout.java