junrao commented on code in PR #15968:
URL: https://github.com/apache/kafka/pull/15968#discussion_r2058879093


##########
clients/src/test/java/org/apache/kafka/common/requests/ProduceRequestTest.java:
##########
@@ -54,7 +55,7 @@ public void 
shouldBeFlaggedAsTransactionalWhenTransactionalRecords() {
         final ProduceRequest request = ProduceRequest.builder(new 
ProduceRequestData()
             .setTopicData(new 
ProduceRequestData.TopicProduceDataCollection(Collections.singletonList(
                 new ProduceRequestData.TopicProduceData()
-                    .setName("topic")
+                    .setTopicId(Uuid.fromString("H3Emm3vW7AKKO4NTRPaCWt"))

Review Comment:
   Could we change the usage of `setName` in `ProducerRequestBenchmark` too?



##########
clients/src/test/java/org/apache/kafka/common/requests/ProduceRequestTest.java:
##########
@@ -102,13 +103,36 @@ public void testBuildWithCurrentMessageFormat() {
         ProduceRequest.Builder requestBuilder = ProduceRequest.builder(
             new ProduceRequestData()
                 .setTopicData(new 
ProduceRequestData.TopicProduceDataCollection(Collections.singletonList(
-                    new 
ProduceRequestData.TopicProduceData().setName("test").setPartitionData(Collections.singletonList(
-                        new 
ProduceRequestData.PartitionProduceData().setIndex(9).setRecords(builder.build()))))
+                    new ProduceRequestData.TopicProduceData()
+                            
.setTopicId(Uuid.fromString("H3Emm3vW7AKKO4NTRPaCWt"))
+                            .setPartitionData(Collections.singletonList(
+                                    new 
ProduceRequestData.PartitionProduceData().setIndex(9).setRecords(builder.build()))))
                     .iterator()))
                 .setAcks((short) 1)
                 .setTimeoutMs(5000),
             false);
-        assertEquals(3, requestBuilder.oldestAllowedVersion());
+        assertEquals(ApiKeys.PRODUCE.oldestVersion(), 
requestBuilder.oldestAllowedVersion());
+        assertEquals(ApiKeys.PRODUCE.latestVersion(), 
requestBuilder.latestAllowedVersion());
+    }
+
+    @Test
+    public void testBuildWithCurrentMessageFormatWithoutTopicId() {
+        ByteBuffer buffer = ByteBuffer.allocate(256);
+        MemoryRecordsBuilder builder = MemoryRecords.builder(buffer, 
RecordBatch.CURRENT_MAGIC_VALUE,
+                Compression.NONE, TimestampType.CREATE_TIME, 0L);
+        builder.append(10L, null, "a".getBytes());
+        ProduceRequest.Builder requestBuilder = ProduceRequest.builder(
+                new ProduceRequestData()
+                        .setTopicData(new 
ProduceRequestData.TopicProduceDataCollection(Collections.singletonList(
+                                        new 
ProduceRequestData.TopicProduceData()
+                                                
.setTopicId(Uuid.fromString("H3Emm3vW7AKKO4NTRPaCWt")) // TopicId will be set 
to Uuid.ZERO and client will get UNKNOWN_TOPIC_ID error if topicId not set.

Review Comment:
   Hmm, we should use `setName` in this test since we expect `topicId` to be 
zero, right?



-- 
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-unsubscr...@kafka.apache.org

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

Reply via email to