@Test
  public void testBarrieredErrorPropagation() throws Exception {
    List<String> members = new ArrayList<>();
    members.add("member");
    LatchedProcedure proc = new LatchedProcedure(coord, new ForeignExceptionDispatcher(), 100,
      Integer.MAX_VALUE, "op", null, members);
    final LatchedProcedure procspy = spy(proc);

    // start the barrier procedure
    Thread t = new Thread() {
      @Override
      public void run() {
        procspy.call();
      }
    };
    t.start();

    // now test that we can put an error in before the commit phase runs
    procspy.startedAcquireBarrier.await();
    ForeignException cause = new ForeignException("SRC", "External Exception");
    procspy.receive(cause);
    procspy.barrierAcquiredByMember(members.get(0));
    t.join();

    // verify state of all the object
    verify(procspy).sendGlobalBarrierStart();
    verify(procspy).sendGlobalBarrierComplete();
    verify(procspy, never()).sendGlobalBarrierReached();
  }
With a single member, verify ordered execution. The Coordinator side is run in a separate
thread so we can only trigger from members and wait for particular state latches.
hbase-server/src/test/java/org/apache/hadoop/hbase/procedure/TestProcedure.java