@ParameterizedTest(name = TEST_NAME_WITH_RACK_CONFIG)
    @EnumSource(RackConfig.class)
    public void testReassignmentWithRandomSubscriptionsAndChanges(RackConfig rackConfig) {
        initializeRacks(rackConfig);
        final int minNumConsumers = 20;
        final int maxNumConsumers = 40;
        final int minNumTopics = 10;
        final int maxNumTopics = 20;

        for (int round = 1; round <= 100; ++round) {
            int numTopics = minNumTopics + new Random().nextInt(maxNumTopics - minNumTopics);

            ArrayList<String> topics = new ArrayList<>();

            Map<String, List<PartitionInfo>> partitionsPerTopic = new HashMap<>();
            for (int i = 0; i < numTopics; ++i) {
                String topicName = getTopicName(i, maxNumTopics);
                topics.add(topicName);
                partitionsPerTopic.put(topicName, partitionInfos(topicName, i + 1));
            }

            int numConsumers = minNumConsumers + new Random().nextInt(maxNumConsumers - minNumConsumers);

            for (int i = 0; i < numConsumers; ++i) {
                List<String> sub = Utils.sorted(getRandomSublist(topics));
                subscriptions.put(getConsumerName(i, maxNumConsumers), subscription(sub, i));
            }

            assignor = createAssignor();

            Map<String, List<TopicPartition>> assignment = assignor.assignPartitions(partitionsPerTopic, subscriptions);
            verifyValidityAndBalance(subscriptions, assignment, partitionsPerTopic);

            subscriptions.clear();
            for (int i = 0; i < numConsumers; ++i) {
                List<String> sub = Utils.sorted(getRandomSublist(topics));
                String consumer = getConsumerName(i, maxNumConsumers);
                subscriptions.put(consumer, buildSubscriptionV2Above(sub, assignment.get(consumer), generationId, i));
            }

            assignment = assignor.assignPartitions(partitionsPerTopic, subscriptions);
            verifyValidityAndBalance(subscriptions, assignment, partitionsPerTopic);
            assertTrue(assignor.isSticky());
        }
    }
This unit test performs sticky assignment for a scenario that round robin assignor handles poorly.
Topics (partitions per topic): topic1 (2), topic2 (1), topic3 (2), topic4 (1), topic5 (2)
Subscriptions:
 - consumer1: topic1, topic2, topic3, topic4, topic5
 - consumer2: topic1, topic3, topic5
 - consumer3: topic1, topic3, topic5
 - consumer4: topic1, topic2, topic3, topic4, topic5
Round Robin Assignment Result:
 - consumer1: topic1-0, topic3-0, topic5-0
 - consumer2: topic1-1, topic3-1, topic5-1
 - consumer3:
 - consumer4: topic2-0, topic4-0
Sticky Assignment Result:
 - consumer1: topic2-0, topic3-0
 - consumer2: topic1-0, topic3-1
 - consumer3: topic1-1, topic5-0
 - consumer4: topic4-0, topic5-1
clients/src/test/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignorTest.java