@Test
    public void testAvoidFencedReplicaIfPossibleOnSingleRack() {
        MockRandom random = new MockRandom();
        RackList rackList = new RackList(random, Arrays.asList(
            new UsableBroker(3, Optional.empty(), false),
            new UsableBroker(1, Optional.empty(), true),
            new UsableBroker(0, Optional.empty(), false),
            new UsableBroker(4, Optional.empty(), false),
            new UsableBroker(2, Optional.empty(), false)).iterator());
        assertEquals(5, rackList.numTotalBrokers());
        assertEquals(4, rackList.numUnfencedBrokers());
        assertEquals(Collections.singletonList(Optional.empty()), rackList.rackNames());
        assertThrows(InvalidReplicationFactorException.class, () -> rackList.place(0));
        assertThrows(InvalidReplicationFactorException.class, () -> rackList.place(-1));
        assertEquals(Arrays.asList(3, 4, 0, 2), rackList.place(4));
        assertEquals(Arrays.asList(4, 0, 2, 3), rackList.place(4));
        assertEquals(Arrays.asList(0, 2, 3, 4), rackList.place(4));
        assertEquals(Arrays.asList(2, 3, 4, 0), rackList.place(4));
        assertEquals(Arrays.asList(0, 4, 3, 2), rackList.place(4));
    }
Test that we perform striped replica placement as expected, and don't use the
fenced replica if we don't have to.
metadata/src/test/java/org/apache/kafka/metadata/placement/StripedReplicaPlacerTest.java