@Test
  public void test() throws Exception {
    String peerId = "legacy";
    ReplicationPeerConfig peerConfig = ReplicationPeerConfig.newBuilder()
      .setClusterKey("127.0.0.1:2181:/hbase")
      .setReplicationEndpointImpl(ReplicationUtils.LEGACY_REGION_REPLICATION_ENDPOINT_NAME).build();
    SingleProcessHBaseCluster cluster = UTIL.getMiniHBaseCluster();
    HMaster master = cluster.getMaster();
    // can not use Admin.addPeer as it will fail with ClassNotFound
    master.getReplicationPeerManager().addPeer(peerId, peerConfig, true);
    // add a wal file to the queue
    ServerName rsName = cluster.getRegionServer(0).getServerName();
    master.getReplicationPeerManager().getQueueStorage().setOffset(
      new ReplicationQueueId(rsName, ServerRegionReplicaUtil.REGION_REPLICA_REPLICATION_PEER), "",
      new ReplicationGroupOffset("test-wal-file", 0), Collections.emptyMap());
    cluster.stopRegionServer(0);
    RegionServerThread rst = cluster.startRegionServer();
    // we should still have this peer
    assertNotNull(UTIL.getAdmin().getReplicationPeerConfig(peerId));
    // but at RS side, we should not have this peer loaded as replication source
    assertTrue(
      rst.getRegionServer().getReplicationSourceService().getReplicationManager().getSources()
        .stream().map(ReplicationSourceInterface::getPeerId).noneMatch(p -> p.equals(peerId)));

    UTIL.shutdownMiniHBaseCluster();
    UTIL.restartHBaseCluster(1);
    // now we should have removed the peer
    assertThrows(ReplicationPeerNotFoundException.class,
      () -> UTIL.getAdmin().getReplicationPeerConfig("legacy"));

    // make sure that we can finish the SCP
    UTIL.waitFor(15000,
      () -> UTIL.getMiniHBaseCluster().getMaster().getProcedures().stream()
        .filter(p -> p instanceof ServerCrashProcedure).map(p -> (ServerCrashProcedure) p)
        .allMatch(Procedure::isSuccess));
    // we will delete the legacy peer while migrating, so here we do not assert the replication data
  }
Make sure we could start the cluster with RegionReplicaReplicationEndpoint configured.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestStartupWithLegacyRegionReplicationEndpoint.java