@Test
  public void testTakeZkCoordinatedSnapshot() {
    for (int i = 0; i < 10; i++) {
      try {
        // Verify that snapshot creation is not possible because lock could not be
        // acquired on time. This can be flaky behavior because even though we provide 1ms
        // as lock timeout, it could still be fast enough and eventually lead to successful
        // snapshot creation. If that happens, retry again.
        testTakeZkCoordinatedSnapshot(i);
        break;
      } catch (Exception e) {
        LOG.error("Error because of faster lock acquisition. retrying....", e);
      }
      assertNotEquals("Retries exhausted", 9, i);
    }
  }
Snapshot creation with master lock timeout test.
hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestSnapshotProcedureWithLockTimeout.java