@Test
  public void testUniformDistribution() {
    ServerName server1 = ServerName.valueOf("server1.example.org", 1234, 1L);
    ServerName server2 = ServerName.valueOf("server2.example.org", 1234, 1L);
    ServerName server3 = ServerName.valueOf("server3.example.org", 1234, 1L);
    ServerName server4 = ServerName.valueOf("server4.example.org", 1234, 1L);

    Map<ServerName, List<RegionInfo>> serverToRegions = new HashMap<>();
    serverToRegions.put(server1, Arrays.asList(createMockRegionInfo(10), createMockRegionInfo(10)));
    serverToRegions.put(server2, Arrays.asList(createMockRegionInfo(10), createMockRegionInfo(10)));
    serverToRegions.put(server3, Arrays.asList(createMockRegionInfo(10), createMockRegionInfo(10)));
    serverToRegions.put(server4, Arrays.asList(createMockRegionInfo(10), createMockRegionInfo(10)));

    BalancerClusterState clusterState = createMockBalancerClusterState(serverToRegions);
    DummyBalancerClusterState state = new DummyBalancerClusterState(clusterState);

    StoreFileTableSkewCostFunction costFunction =
      new StoreFileTableSkewCostFunction(new Configuration());
    costFunction.prepare(state);
    double cost = costFunction.cost();

    // Expect zero cost since all regions (from the same table) are balanced.
    assertEquals("Uniform distribution should yield zero cost", 0.0, cost, 1e-6);
  }
Tests that a uniform store file distribution (single table) across servers results in zero
cost.
hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStoreFileTableSkewCostFunction.java