private void assertConnectionDistributionIsFair(Map<String, Integer> connectionsUsedPerHost) {
        double deviationDueToRandomSourceSelection = 0.15;
        final int size = 1000;
        int minHostCount = (int) (size/2 * (1 - deviationDueToRandomSourceSelection));
        int maxHostCount = (int) (size/2 * (1 + deviationDueToRandomSourceSelection));

        for (Map.Entry<String, Integer> entry : connectionsUsedPerHost.entrySet()) {
            Integer timesUsed = entry.getValue();
            assertTrue("Host 0 used " + timesUsed + " times, expected to be < " + maxHostCount, timesUsed < maxHostCount);
            assertTrue("Host 0 used " + timesUsed + " times, expected to be > " + minHostCount, timesUsed > minHostCount);
        }
    }
Tests that when there are two sources and several clients
the sources will be chosen with about the same probability.
config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java