private void testTakeZkCoordinatedSnapshot(int i) throws Exception {
    SnapshotDescription snapshotOnSameTable =
      new SnapshotDescription(SNAPSHOT_NAME + i, TABLE_NAME, SnapshotType.SKIPFLUSH);
    SnapshotProtos.SnapshotDescription snapshotOnSameTableProto =
      ProtobufUtil.createHBaseProtosSnapshotDesc(snapshotOnSameTable);
    Thread second = new Thread("zk-snapshot") {
      @Override
      public void run() {
        try {
          master.getSnapshotManager().takeSnapshot(snapshotOnSameTableProto);
        } catch (IOException e) {
          LOG.error("zk snapshot failed", e);
          fail("zk snapshot failed");
        }
      }
    };
    second.start();

    Thread.sleep(5000);
    boolean snapshotCreated = false;
    try {
      SnapshotTestingUtils.confirmSnapshotValid(TEST_UTIL, snapshotOnSameTableProto, TABLE_NAME,
        CF);
      snapshotCreated = true;
    } catch (AssertionError e) {
      LOG.error("Assertion error..", e);
      if (
        e.getMessage() != null && e.getMessage().contains("target snapshot directory")
          && e.getMessage().contains("doesn't exist.")
      ) {
        LOG.debug("Expected behaviour - snapshot could not be created");
      } else {
        throw new IOException(e);
      }
    }

    if (snapshotCreated) {
      throw new IOException("Snapshot created successfully");
    }

    // ensure all scheduled procedures are successfully completed
    TEST_UTIL.waitFor(4000, 400,
      () -> master.getMasterProcedureExecutor().getProcedures().stream()
        .filter(masterProcedureEnvProcedure -> masterProcedureEnvProcedure.getState()
            == ProcedureProtos.ProcedureState.SUCCESS)
        .count() == master.getMasterProcedureExecutor().getProcedures().size());
  }
Snapshot creation with master lock timeout test.
hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestSnapshotProcedureWithLockTimeout.java