private void setupCluster() throws Exception, IOException, InterruptedException {
    // Set Zookeeper based connection registry since we will stop master and start a new master
    // without populating the underlying config for the connection.
    UTIL.getConfiguration().set(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
      HConstants.ZK_CONNECTION_REGISTRY_CLASS);
    // Enable retain assignment during ServerCrashProcedure
    UTIL.getConfiguration().setBoolean(MASTER_SCP_RETAIN_ASSIGNMENT, true);
    UTIL.startMiniCluster(StartTestingClusterOption.builder().masterClass(HMasterForTest.class)
      .numRegionServers(NUM_OF_RS).build());

    // Turn off balancer
    UTIL.getMiniHBaseCluster().getMaster().getMasterRpcServices().synchronousBalanceSwitch(false);

    LOG.info("\n\nCreating tables");
    for (TableName TABLE : TABLES) {
      UTIL.createTable(TABLE, FAMILY);
    }
    for (TableName TABLE : TABLES) {
      UTIL.waitTableEnabled(TABLE);
    }

    UTIL.getMiniHBaseCluster().getMaster();
    UTIL.waitUntilNoRegionsInTransition(60000);
  }
This tests the force retaining assignments upon an RS restart, even when master triggers an SCP
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRetainAssignmentOnRestart.java