@Before
  public void setUp() throws Exception {
    Admin admin = TEST_UTIL.getAdmin();

    // Add a new rsgroup and assign two servers to it.
    admin.addRSGroup(TEST_RSGROUP);
    Collection<ServerName> allServers = admin.getRegionServers();
    // Remove rs contains hbase:meta, otherwise test looks unstable and buggy in test env.
    ServerName rsContainMeta = TEST_UTIL.getMiniHBaseCluster().getRegionServerThreads().stream()
      .map(t -> t.getRegionServer())
      .filter(rs -> rs.getRegions(TableName.META_TABLE_NAME).size() > 0).findFirst().get()
      .getServerName();
    LOG.info("{} contains hbase:meta", rsContainMeta);
    List<ServerName> modifiable = new ArrayList<>(allServers);
    modifiable.remove(rsContainMeta);
    int i = 0;
    for (ServerName server : modifiable) {
      if (i == 2) break;
      rsservers.add(Address.fromParts(server.getHostname(), server.getPort()));
      i++;
    }
    admin.moveServersToRSGroup(new HashSet<>(rsservers), TEST_RSGROUP);
    LOG.info("Servers in {} are {}", TEST_RSGROUP, rsservers);
    assertEquals(3, admin.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getServers().size());
    assertEquals(2, admin.getRSGroup(TEST_RSGROUP).getServers().size());

    // Create a pre-split table in test rsgroup
    TableName tableName = TableName.valueOf("testRegionMoverWithRSGroupEnable");
    if (admin.tableExists(tableName)) {
      TEST_UTIL.deleteTable(tableName);
    }
    TableDescriptor tableDesc = TableDescriptorBuilder.newBuilder(tableName)
      .setColumnFamily(ColumnFamilyDescriptorBuilder.of("f")).setRegionServerGroup(TEST_RSGROUP)
      .build();
    String startKey = "a";
    String endKey = "z";
    admin.createTable(tableDesc, Bytes.toBytes(startKey), Bytes.toBytes(endKey), 9);
  }
Test for rsgroup enable, unloaded regions from decommissoned host of a rsgroup should be assigned
to those regionservers belonging to the same rsgroup.
hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionMoverWithRSGroupEnable.java