dongnuo123 commented on code in PR #14656:
URL: https://github.com/apache/kafka/pull/14656#discussion_r1374900874


##########
core/src/test/scala/unit/kafka/server/LeaveGroupRequestTest.scala:
##########
@@ -0,0 +1,137 @@
+/**
+ * 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 kafka.server
+
+import kafka.test.ClusterInstance
+import kafka.test.annotation.{ClusterConfigProperty, ClusterTest, 
ClusterTestDefaults, Type}
+import kafka.test.junit.ClusterTestExtensions
+import org.apache.kafka.common.protocol.{ApiKeys, Errors}
+import org.apache.kafka.common.requests.JoinGroupRequest
+import org.junit.jupiter.api.{Tag, Timeout}
+import org.junit.jupiter.api.extension.ExtendWith
+
+@Timeout(120)
+@ExtendWith(value = Array(classOf[ClusterTestExtensions]))
+@ClusterTestDefaults(clusterType = Type.KRAFT, brokers = 1)
+@Tag("integration")
+class LeaveGroupRequestTest(cluster: ClusterInstance) extends 
GroupCoordinatorBaseRequestTest(cluster) {
+  @ClusterTest(serverProperties = Array(
+    new ClusterConfigProperty(key = "unstable.api.versions.enable", value = 
"true"),
+    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 testLeaveGroupWithOldConsumerGroupProtocolAndNewGroupCoordinator(): Unit 
= {
+    testLeaveGroup()
+  }
+
+  @ClusterTest(clusterType = Type.ALL, serverProperties = Array(
+    new ClusterConfigProperty(key = "unstable.api.versions.enable", value = 
"false"),
+    new ClusterConfigProperty(key = "group.coordinator.new.enable", value = 
"false"),
+    new ClusterConfigProperty(key = "offsets.topic.num.partitions", value = 
"1"),
+    new ClusterConfigProperty(key = "offsets.topic.replication.factor", value 
= "1")
+  ))
+  def testLeaveGroupWithOldConsumerGroupProtocolAndOldGroupCoordinator(): Unit 
= {
+    testLeaveGroup()
+  }
+
+  private def testLeaveGroup(): Unit = {
+
+    // Creates the __consumer_offsets topics because it won't be created 
automatically
+    // in this test because it does not use FindCoordinator API.
+    createOffsetsTopic()
+
+    // Create the topic.
+    createTopic(
+      topic = "foo",
+      numPartitions = 3
+    )
+
+    for (version <- ApiKeys.LEAVE_GROUP.oldestVersion() to 
ApiKeys.LEAVE_GROUP.latestVersion(isUnstableApiEnabled)) {
+
+      // Join the consumer group. Note that we don't heartbeat here so we must 
use
+      // a session long enough for the duration of the test.
+      val (memberId1, _) = joinDynamicConsumerGroupWithOldProtocol("grp-1")
+      val (_, _) = joinStaticConsumerGroupWithOldProtocol("grp-2", 
"group-instance-id")

Review Comment:
   I still can't add static member and dynamic member to the same group. The 
reason shouldn't be the first member not rejoining the group, because the 
timeout already occurs when processing the second member's joining request.
   
   Joining two consecutive static members, or two consecutive dynamic members 
work. I wonder what's special about joining a static member then a dynamic 
member or joining a dynamic one and then a static one. @dajac 



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