@Override
    public AdminProtos.ExecuteProceduresResponse sendRequest(final ServerName serverName,
      final AdminProtos.ExecuteProceduresRequest request) throws IOException {
      int j = I.addAndGet(1);
      LOG.info("sendRequest() req: {} , j: {}", request, j);
      if (j == 12 || j == 22) {
        // Execute the remote close and open region requests in the last (5th) retry before
        // throwing ConnectionClosedException. This is to ensure even if the region open/close
        // is successfully completed by regionserver, master still schedules SCP because
        // sendRequest() throws error which has retry-limit exhausted.
        FutureUtils.get(getRsAdmin().executeProcedures(request));
      }
      // For one of the close region requests and one of the open region requests,
      // throw ConnectionClosedException until retry limit is exhausted and master
      // schedules recoveries for the server.
      // We will have ABNORMALLY_CLOSED regions, and they are expected to recover on their own.
      if (j >= 8 && j <= 13 || j >= 18 && j <= 23) {
        throw ERRORS.get(ERROR_IDX.getAndIncrement() % ERRORS.size());
      }
      return FutureUtils.get(getRsAdmin().executeProcedures(request));
    }
Test implementation of RSProcedureDispatcher that throws desired errors for testing purpose.
hbase-server/src/test/java/org/apache/hadoop/hbase/util/RSProcDispatcher.java