@Test
  public void testUpdateStochasticCostsIfBalanceNotRan() {
    int[] cluster = new int[] { 10, 10 };
    Map<ServerName, List<RegionInfo>> servers = mockClusterServers(cluster);
    BalancerClusterState clusterState = mockCluster(cluster);
    conf.setFloat("hbase.master.balancer.stochastic.minCostNeedBalance", Float.MAX_VALUE);
    conf.setBoolean(HConstants.HBASE_MASTER_LOADBALANCE_BYTABLE, false);
    loadBalancer.onConfigurationChange(conf);
    dummyMetricsStochasticBalancer.clearDummyMetrics();
    List<RegionPlan> plans =
      loadBalancer.balanceCluster((Map) mockClusterServersWithTables(servers));

    assertTrue("Balance plan should be empty!", plans == null || plans.isEmpty());
    assertTrue("There should be metrics record in MetricsStochasticBalancer!",
      !dummyMetricsStochasticBalancer.getDummyCostsMap().isEmpty());

    double overallCostOfCluster = loadBalancer.computeCost(clusterState, Double.MAX_VALUE);
    double overallCostInMetrics = dummyMetricsStochasticBalancer.getDummyCostsMap().get(
      HConstants.ENSEMBLE_TABLE_NAME + "#" + StochasticLoadBalancer.OVERALL_COST_FUNCTION_NAME);
    assertEquals(overallCostOfCluster, overallCostInMetrics, 0.001);
  }
Data set for testLocalityCost: [test][0][0] = mapping of server to number of regions it hosts
[test][region + 1][0] = server that region is hosted on [test][region + 1][server + 1] =
locality for region on server
hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java