@Test
  public void testCoordinatorAbort() throws Exception {
    buildCohortMemberPair();

    // mock that another node timed out or failed to prepare
    final TimeoutException oate = new TimeoutException("bogus timeout", 1, 2, 0);
    doAnswer(new Answer<Void>() {
      @Override
      public Void answer(InvocationOnMock invocation) throws Throwable {
        // inject a remote error (this would have come from an external thread)
        spySub.cancel("bogus message", oate);
        // sleep the wake frequency since that is what we promised
        Thread.sleep(WAKE_FREQUENCY);
        return null;
      }
    }).when(spySub).waitForReachedGlobalBarrier();

    // run the operation
    // build a new operation
    Subprocedure subproc = member.createSubprocedure(op, data);
    member.submitSubprocedure(subproc);
    // if the operation doesn't die properly, then this will timeout
    member.closeAndWait(TIMEOUT);

    // make sure everything ran in order
    InOrder order = inOrder(mockMemberComms, spySub);
    order.verify(spySub).acquireBarrier();
    order.verify(mockMemberComms).sendMemberAcquired(eq(spySub));
    // Later phases not run
    order.verify(spySub, never()).insideBarrier();
    order.verify(mockMemberComms, never()).sendMemberCompleted(eq(spySub), eq(data));
    // error recovery path exercised
    order.verify(spySub).cancel(anyString(), any());
    order.verify(spySub).cleanup(any());
  }
Fail correctly if coordinator aborts the procedure. The subprocedure will not interrupt a
running {@link Subprocedure#acquireBarrier()} -- prepare needs to finish first, and the the
abort is checked. Thus, the {@link Subprocedure#acquireBarrier()} should succeed but later get
rolled back via {@link Subprocedure#cleanup}.
hbase-server/src/test/java/org/apache/hadoop/hbase/procedure/TestProcedureMember.java