You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2023/01/10 22:31:24 UTC

[GitHub] [kafka] hachikuji commented on a diff in pull request #13104: KAFKA-14612: Make sure to write ConfigRecords to metadata log iff topic is created

hachikuji commented on code in PR #13104:
URL: https://github.com/apache/kafka/pull/13104#discussion_r1066408319


##########
metadata/src/test/java/org/apache/kafka/controller/ReplicationControlManagerTest.java:
##########
@@ -605,6 +617,16 @@ public void testCreateTopicsWithConfigs() throws Exception {
             "Null value not supported for topic configs: foo",
             result2.response().topics().find("bar").errorMessage()
         );
+
+        CreateTopicsRequestData request3 = new CreateTopicsRequestData();
+        request3.topics().add(new CreatableTopic().setName("baz")
+            .setNumPartitions(-1).setReplicationFactor((short) -2)
+            .setConfigs(validConfigs));
+
+        ControllerResult<CreateTopicsResponseData> result3 =
+            replicationControl.createTopics(request3, Collections.singleton("baz"));
+        assertEquals(INVALID_REPLICATION_FACTOR.code(), result3.response().topics().find("baz").errorCode());
+        assertEquals(0, result3.records().size());

Review Comment:
   nit: a better assertion is this:
   ```java
   assertEquals(Collections.emptyList(), result3.records());
   ```
   It gives more information in case of a failure.



##########
metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:
##########
@@ -725,6 +725,8 @@ private ApiError createTopic(CreatableTopic topic,
         records.add(new ApiMessageAndVersion(new TopicRecord().
             setName(topic.name()).
             setTopicId(topicId), (short) 0));
+        // ConfigRecords go after TopicRecord but before PartitionRecord(s).
+        records.addAll(configResult.records());

Review Comment:
   This looks a little suspicious. Don't we need to pull the configs for the topic that is being created? We should have a test case with multiple topics.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org