dajac commented on code in PR #15727:
URL: https://github.com/apache/kafka/pull/15727#discussion_r1596452023


##########
core/src/test/scala/unit/kafka/server/ConsumerGroupDescribeRequestsTest.scala:
##########
@@ -0,0 +1,175 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package unit.kafka.server
+
+import kafka.server.GroupCoordinatorBaseRequestTest
+import kafka.test.ClusterInstance
+import kafka.test.annotation.{ClusterConfigProperty, ClusterTest, 
ClusterTestDefaults, Type}
+import kafka.test.junit.ClusterTestExtensions
+import kafka.utils.TestUtils
+import org.apache.kafka.common.ConsumerGroupState
+import org.apache.kafka.common.message.ConsumerGroupDescribeResponseData
+import 
org.apache.kafka.common.message.ConsumerGroupDescribeResponseData.{Assignment, 
DescribedGroup, TopicPartitions}
+import org.apache.kafka.common.protocol.ApiKeys
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.extension.ExtendWith
+import org.junit.jupiter.api.{Tag, Timeout}
+
+import scala.jdk.CollectionConverters._
+
+@Timeout(120)
+@ExtendWith(value = Array(classOf[ClusterTestExtensions]))
+@ClusterTestDefaults(clusterType = Type.KRAFT, brokers = 1)
+@Tag("integration")
+class ConsumerGroupDescribeRequestsTest(cluster: ClusterInstance) extends 
GroupCoordinatorBaseRequestTest(cluster) {
+
+  @ClusterTest(clusterType = Type.KRAFT, serverProperties = Array(
+    new ClusterConfigProperty(key = "group.coordinator.rebalance.protocols", 
value = "classic,consumer"),
+    new ClusterConfigProperty(key = "group.coordinator.new.enable", value = 
"true"),
+    new ClusterConfigProperty(key = "offsets.topic.num.partitions", value = 
"1"),
+    new ClusterConfigProperty(key = "offsets.topic.replication.factor", value 
= "1")
+  ))
+  def testConsumerGroupDescribeWithNewGroupCoordinator(): Unit = {
+    testConsumerGroupDescribe()
+  }
+
+  private def testConsumerGroupDescribe(): Unit = {
+    // Creates the __consumer_offsets topics because it won't be created 
automatically
+    // in this test because it does not use FindCoordinator API.
+    createOffsetsTopic()
+
+    val admin = cluster.createAdminClient()
+    val topicId = TestUtils.createTopicWithAdminRaw(
+      admin = admin,
+      topic = "foo",
+      numPartitions = 3
+    )
+
+    val timeoutMs = 5 * 60 * 1000
+    val clientId = "client-id"
+    val clientHost = "/127.0.0.1"
+
+    // Add first group
+    val consumerGroupHeartbeatResponseData1 = consumerGroupHeartbeat(
+      groupId = "grp-1",
+      rebalanceTimeoutMs = timeoutMs,
+      subscribedTopicNames = List(""),
+      topicPartitions = List.empty
+    )
+
+    // Add second group
+    consumerGroupHeartbeat(
+      memberId = "member-1",
+      groupId = "grp-2",
+      rebalanceTimeoutMs = timeoutMs,
+      subscribedTopicNames = List("foo"),
+      topicPartitions = List.empty
+    )
+
+    // Add second member to second group
+    consumerGroupHeartbeat(
+      memberId = "member-2",
+      groupId = "grp-2",
+      rebalanceTimeoutMs = timeoutMs,
+      subscribedTopicNames = List("foo"),
+      topicPartitions = List.empty
+    )
+
+    val assignmentMember1 = new Assignment()
+      .setTopicPartitions(List(
+        new TopicPartitions()
+          .setTopicId(topicId)
+          .setTopicName("foo")
+          .setPartitions(List[Integer](0, 1, 2).asJava)
+      ).asJava)
+
+    val targetAssignmentMember1 = new Assignment()
+      .setTopicPartitions(List(
+        new TopicPartitions()
+          .setTopicId(topicId)
+          .setTopicName("foo")
+          .setPartitions(List[Integer](0, 1).asJava)
+      ).asJava)
+
+    val assignmentMember2 = new Assignment()
+      .setTopicPartitions(List().asJava)
+
+    val targetAssignmentMember2 = new Assignment()
+      .setTopicPartitions(List(
+        new TopicPartitions()
+          .setTopicId(topicId)
+          .setTopicName("foo")
+          .setPartitions(List[Integer](2).asJava)
+      ).asJava)
+
+    for (version <- ApiKeys.CONSUMER_GROUP_DESCRIBE.oldestVersion() to 
ApiKeys.CONSUMER_GROUP_DESCRIBE.latestVersion(isUnstableApiEnabled)) {
+
+      val expected = List(
+        new DescribedGroup()
+          .setGroupId("grp-1")
+          .setGroupState(ConsumerGroupState.STABLE.toString)
+          .setGroupEpoch(1)
+          .setAssignmentEpoch(1)
+          .setAssignorName("uniform")
+          .setMembers(List(
+            new ConsumerGroupDescribeResponseData.Member()
+              .setMemberId(consumerGroupHeartbeatResponseData1.memberId)
+              .setMemberEpoch(1)
+              .setClientId(clientId)
+              .setClientHost(clientHost)
+              .setSubscribedTopicRegex("")
+              .setSubscribedTopicNames(List("").asJava)
+          ).asJava),
+
+        new DescribedGroup()
+          .setGroupId("grp-2")
+          .setGroupState(ConsumerGroupState.RECONCILING.toString)
+          .setGroupEpoch(2)
+          .setAssignmentEpoch(2)
+          .setAssignorName("uniform")

Review Comment:
   @riedelmax I think that we could just do it here as we only need to change 
the assignor. What do you think?



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