lucasbru commented on code in PR #24148:
URL: https://github.com/apache/kafka/pull/24148#discussion_r4522874723


##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/streams/topics/InternalTopicManagerTest.java:
##########
@@ -108,6 +109,99 @@ void testConfigureTopics() {
         assertEquals(expectedConfiguredTopology, 
configuredTopology.subtopologies());
     }
 
+    @Test
+    void 
testConfigureTopicsIgnoresUnrelatedFixedRepartitionTopicsForCopartitionGroup() {
+        MetadataImage metadataImage = new MetadataImageBuilder()
+            .addTopic(Uuid.randomUuid(), "left", 2)
+            .addTopic(Uuid.randomUuid(), "right", 4)
+            .addTopic(Uuid.randomUuid(), "other-a", 1)
+            .addTopic(Uuid.randomUuid(), "other-b", 1)
+            .build();
+
+        final ConfiguredTopology configuredTopology = 
InternalTopicManager.configureTopics(
+            LOG, "test-group", "test-member", 0, 
makeTopologyWithUnrelatedFixedRepartitionTopics(),
+            new KRaftCoordinatorMetadataImage(metadataImage), TIME);
+
+        assertEquals(
+            Optional.of(Status.MISSING_INTERNAL_TOPICS),
+            
configuredTopology.topicConfigurationException().map(TopicConfigurationException::status));
+        final Map<String, CreatableTopic> toCreate = 
configuredTopology.internalTopicsToBeCreated();
+        assertEquals(4, toCreate.get("left-repartition").numPartitions());
+        assertEquals(4, toCreate.get("right-repartition").numPartitions());
+        assertEquals(3, toCreate.get("fixed-3-repartition").numPartitions());
+        assertEquals(5, toCreate.get("fixed-5-repartition").numPartitions());
+
+        final ConfiguredSubtopology joinSubtopology = 
configuredTopology.subtopologies().orElseThrow().get("join-sub");
+        assertEquals(4, joinSubtopology.numberOfTasks());
+        assertEquals(4, 
joinSubtopology.repartitionSourceTopics().get("left-repartition").numberOfPartitions());
+        assertEquals(4, 
joinSubtopology.repartitionSourceTopics().get("right-repartition").numberOfPartitions());
+    }
+
+    @Test
+    void 
testConfigureTopicsCreatesMissingCopartitionedRepartitionTopicWithPartitionCountOfExistingSibling()
 {
+        // "left-repartition" already exists with more partitions than its 
sources suggest, "right-repartition" is missing.
+        MetadataImage metadataImage = new MetadataImageBuilder()
+            .addTopic(Uuid.randomUuid(), "left", 2)
+            .addTopic(Uuid.randomUuid(), "right", 4)
+            .addTopic(Uuid.randomUuid(), "other-a", 1)
+            .addTopic(Uuid.randomUuid(), "other-b", 1)
+            .addTopic(Uuid.randomUuid(), "left-repartition", 6)
+            .build();
+
+        final ConfiguredTopology configuredTopology = 
InternalTopicManager.configureTopics(
+            LOG, "test-group", "test-member", 0, 
makeTopologyWithUnrelatedFixedRepartitionTopics(),
+            new KRaftCoordinatorMetadataImage(metadataImage), TIME);
+
+        final Map<String, CreatableTopic> toCreate = 
configuredTopology.internalTopicsToBeCreated();
+        assertEquals(6, toCreate.get("right-repartition").numPartitions());

Review Comment:
   Good catch, you're right: a wrong count there would leave 
`internalTopicsToBeCreated()` empty and fail with an NPE instead of the status. 
Added the status assertion first, same as the test above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to