@Test
  public void testWait() throws Exception {
    // disable the peers
    hbaseAdmin.disableReplicationPeer(PEER_ID2);
    hbaseAdmin.disableReplicationPeer(PEER_ID3);

    // put some data
    UTIL1.loadTable(htable1, famName);
    UTIL1.loadTable(table3, famName);

    EMPTY = true;
    UTIL1.getMiniHBaseCluster().stopRegionServer(0).join();
    UTIL1.getMiniHBaseCluster().startRegionServer();

    // since there is no active region server to get the replication queue, the procedure should be
    // in WAITING_TIMEOUT state for most time to retry
    HMaster master = UTIL1.getMiniHBaseCluster().getMaster();
    UTIL1.waitFor(30000,
      () -> master.getProcedures().stream()
        .filter(p -> p instanceof AssignReplicationQueuesProcedure)
        .anyMatch(p -> p.getState() == ProcedureState.WAITING_TIMEOUT));

    // call remove replication peer, and make sure it will be stuck in the POST_PEER_MODIFICATION
    // state.
    hbaseAdmin.removeReplicationPeerAsync(PEER_ID3);
    UTIL1.waitFor(30000,
      () -> master.getProcedures().stream().filter(p -> p instanceof RemovePeerProcedure)
        .anyMatch(p -> ((RemovePeerProcedure) p).getCurrentStateId()
            == PeerModificationState.POST_PEER_MODIFICATION_VALUE));
    Thread.sleep(5000);
    assertEquals(PeerModificationState.POST_PEER_MODIFICATION_VALUE,
      ((RemovePeerProcedure) master.getProcedures().stream()
        .filter(p -> p instanceof RemovePeerProcedure).findFirst().get()).getCurrentStateId());
    EMPTY = false;
    // wait until the SCP finished, AssignReplicationQueuesProcedure is a sub procedure of SCP
    UTIL1.waitFor(30000, () -> master.getProcedures().stream()
      .filter(p -> p instanceof ServerCrashProcedure).allMatch(Procedure::isSuccess));
    // the RemovePeerProcedure should have also finished
    UTIL1.waitFor(30000, () -> master.getProcedures().stream()
      .filter(p -> p instanceof RemovePeerProcedure).allMatch(Procedure::isSuccess));
    // make sure there is no remaining replication queues for PEER_ID3
    assertThat(master.getReplicationPeerManager().getQueueStorage().listAllQueueIds(PEER_ID3),
      empty());
  }
Make sure we will wait until all the SCPs finished in RemovePeerProcedure.
<p/>
See HBASE-27109 for more details.
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestRemovePeerProcedureWaitForSCP.java