@Test
  public void testUpgradeAndIncreaseReplicaCount() throws Exception {
    HMaster oldMaster = TEST_UTIL.getMiniHBaseCluster().getMaster();
    TableDescriptors oldTds = oldMaster.getTableDescriptors();
    TableDescriptor oldMetaTd = oldTds.get(TableName.META_TABLE_NAME);
    assertEquals(3, oldMetaTd.getRegionReplication());
    // force update the replica count to 1 and then kill the master, to simulate that hen upgrading,
    // we have no region replication in meta table descriptor but we actually have meta region
    // replicas
    oldTds.update(TableDescriptorBuilder.newBuilder(oldMetaTd).setRegionReplication(1).build());
    oldMaster.stop("Restarting");
    TEST_UTIL.waitFor(30000, () -> oldMaster.isStopped());

    // increase replica count to 5 through Configuration
    TEST_UTIL.getMiniHBaseCluster().getConfiguration().setInt(HConstants.META_REPLICAS_NUM, 5);
    TEST_UTIL.getMiniHBaseCluster().startMaster();
    TEST_UTIL.waitFor(30000,
      () -> TEST_UTIL.getZooKeeperWatcher().getMetaReplicaNodes().size() == 5);
  }
Make sure we will honor the {@link HConstants#META_REPLICAS_NUM}.And also test upgrading.
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIncreaseMetaReplicaThroughConfig.java