@Test
  public void testMergingRegionWhileTakingSnapshot() throws Exception {
    final TableName tableName = TableName.valueOf("testMergingRegionWhileTakingSnapshot");
    final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();

    List<RegionInfo> tableRegions = createTable(tableName);

    ProcedureTestingUtility.waitNoProcedureRunning(procExec);

    SnapshotDescription snapshot =
      new SnapshotDescription("SnapshotProcedureTest", tableName, SnapshotType.FLUSH);
    SnapshotProtos.SnapshotDescription snapshotProto =
      ProtobufUtil.createHBaseProtosSnapshotDesc(snapshot);
    snapshotProto = SnapshotDescriptionUtils.validate(snapshotProto,
      UTIL.getHBaseCluster().getMaster().getConfiguration());
    long snapshotProcId = procExec.submitProcedure(
      new TestSnapshotProcedure.DelaySnapshotProcedure(procExec.getEnvironment(), snapshotProto));
    UTIL.getHBaseCluster().getMaster().getSnapshotManager().registerSnapshotProcedure(snapshotProto,
      snapshotProcId);

    RegionInfo[] regionsToMerge = new RegionInfo[2];
    regionsToMerge[0] = tableRegions.get(0);
    regionsToMerge[1] = tableRegions.get(1);

    long mergeProcId = procExec.submitProcedure(
      new MergeTableRegionsProcedure(procExec.getEnvironment(), regionsToMerge, true));

    ProcedureTestingUtility
      .waitProcedure(UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor(), mergeProcId);
    ProcedureTestingUtility.waitProcedure(
      UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor(), snapshotProcId);

    assertProcFailed(procExec, mergeProcId);
    assertEquals(initialRegionCount, UTIL.getAdmin().getRegions(tableName).size());
  }
This tests two concurrent region merges
hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestMergeTableRegionsProcedure.java