@Test
  public void disableTest() {
    TRegionReplicaSet regionReplicaSet =
        new TRegionReplicaSet(
            new TConsensusGroupId(TConsensusGroupType.DataRegion, 0),
            Arrays.asList(
                new TDataNodeLocation().setDataNodeId(0),
                new TDataNodeLocation().setDataNodeId(1),
                new TDataNodeLocation().setDataNodeId(2)));

    // Prepare input parameters
    Map<String, List<TConsensusGroupId>> databaseRegionGroupMap = new TreeMap<>();
    databaseRegionGroupMap.put(DATABASE, Collections.singletonList(regionReplicaSet.getRegionId()));
    Map<TConsensusGroupId, Set<Integer>> regionReplicaSetMap = new TreeMap<>();
    regionReplicaSetMap.put(
        regionReplicaSet.getRegionId(),
        regionReplicaSet.getDataNodeLocations().stream()
            .map(TDataNodeLocation::getDataNodeId)
            .collect(Collectors.toSet()));
    Map<TConsensusGroupId, Integer> regionLeaderMap = new TreeMap<>();
    regionLeaderMap.put(regionReplicaSet.getRegionId(), 1);
    Map<Integer, NodeStatistics> nodeStatisticsMap = new TreeMap<>();
    nodeStatisticsMap.put(0, new NodeStatistics(NodeStatus.Unknown));
    nodeStatisticsMap.put(1, new NodeStatistics(NodeStatus.ReadOnly));
    nodeStatisticsMap.put(2, new NodeStatistics(NodeStatus.Removing));
    Map<TConsensusGroupId, Map<Integer, RegionStatistics>> regionStatisticsMap = new TreeMap<>();
    Map<Integer, RegionStatistics> regionStatistics = new TreeMap<>();
    regionStatistics.put(0, new RegionStatistics(RegionStatus.Running));
    regionStatistics.put(1, new RegionStatistics(RegionStatus.Running));
    regionStatistics.put(2, new RegionStatistics(RegionStatus.Running));
    regionStatisticsMap.put(regionReplicaSet.getRegionId(), regionStatistics);

    // Do balancing
    Map<TConsensusGroupId, Integer> leaderDistribution =
        BALANCER.generateOptimalLeaderDistribution(
            databaseRegionGroupMap,
            regionReplicaSetMap,
            regionLeaderMap,
            nodeStatisticsMap,
            regionStatisticsMap);
    Assert.assertEquals(1, leaderDistribution.size());
    Assert.assertEquals(1, new HashSet<>(leaderDistribution.values()).size());
    // Leader remains the same
    Assert.assertEquals(
        regionLeaderMap.get(regionReplicaSet.getRegionId()),
        leaderDistribution.get(regionReplicaSet.getRegionId()));
    // MaxFlow is 0
    Assert.assertEquals(0, BALANCER.getMaximumFlow());
    // MinimumCost is 0
    Assert.assertEquals(0, BALANCER.getMinimumCost());
  }
The leader will remain the same if all DataNodes are disabled
iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/load/balancer/router/leader/CFDLeaderBalancerTest.java