FrankYang0529 commented on code in PR #18198:
URL: https://github.com/apache/kafka/pull/18198#discussion_r4172572410


##########
tools/src/test/java/org/apache/kafka/tools/consumer/ConsoleConsumerTest.java:
##########
@@ -411,6 +418,34 @@ public void 
testGroupMetadataMessageFormatter(ClusterInstance cluster) throws Ex
         }
     }
 
+    @ClusterTest(serverProperties = {
+        @ClusterConfigProperty(key = OFFSETS_TOPIC_PARTITIONS_CONFIG, value = 
"1"),
+        @ClusterConfigProperty(key = OFFSETS_TOPIC_REPLICATION_FACTOR_CONFIG, 
value = "1")
+    })
+    public void 
testGroupMetadataMessageFormatterWithConsumerGroupProtocol(ClusterInstance 
cluster) throws Exception {
+        cluster.createTopic(topic, 1, (short) 1);
+        produceMessages(cluster);
+
+        String[] groupMetadataMessageFormatter = 
createConsoleConsumerArgs(cluster,
+            Topic.GROUP_METADATA_TOPIC_NAME,
+            "org.apache.kafka.tools.consumer.GroupMetadataMessageFormatter");
+
+        ConsoleConsumerOptions options = new 
ConsoleConsumerOptions(groupMetadataMessageFormatter);
+        ConsoleConsumer.ConsumerWrapper consumerWrapper =
+            new ConsoleConsumer.ConsumerWrapper(options, 
createGroupMetadataConsumer(cluster, GroupProtocol.CONSUMER));
+
+        try (ByteArrayOutputStream out = new ByteArrayOutputStream();
+             PrintStream output = new PrintStream(out)) {
+            ConsoleConsumer.process(1, options.formatter(), consumerWrapper, 
output, true);
+
+            JsonNode jsonNode = 
objectMapper.reader().readTree(out.toByteArray());
+            // Consumer group protocol does not write GROUP_METADATA records, 
so the result is empty

Review Comment:
   Create a PR for it. Thanks for the review. 
https://github.com/apache/kafka/pull/23683



-- 
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