@Test
public void testRoundRobinWithUnavailablePartitions() {

    // When there are some unavailable partitions, we want to make sure that (1) we always pick an available partition,
    // and (2) the available partitions are selected in a round robin way.
    int countForPart0 = 0;
    int countForPart2 = 0;
    for (int i = 1; i <= 100; i++) {
        int part = partitioner.partition("test", null, null, null, null, cluster);
        assertTrue("We should never choose a leader-less node in round robin", part == 0 || part == 2);
        if (part == 0)
            countForPart0++;
        else
            countForPart2++;
    }
    assertEquals("The distribution between two available partitions should be even", countForPart0, countForPart2);
}