dajac commented on a change in pull request #11571:
URL: https://github.com/apache/kafka/pull/11571#discussion_r782071080



##########
File path: 
clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
##########
@@ -3907,6 +3909,44 @@ public void testRemoveMembersFromGroup() throws 
Exception {
         }
     }
 
+    @Test
+    public void testRemoveMembersFromGroupReason() throws Exception {
+        final Cluster cluster = mockCluster(3, 0);
+        final Time time = new MockTime();
+
+        try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(time, 
cluster)) {
+
+            env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
+
+            
env.kafkaClient().prepareResponse(prepareFindCoordinatorResponse(Errors.NONE, 
env.cluster().controller()));
+            env.kafkaClient().prepareResponse(body -> {
+                if (!(body instanceof LeaveGroupRequest)) {
+                    return false;
+                }
+                LeaveGroupRequestData leaveGroupRequest = ((LeaveGroupRequest) 
body).data();
+
+                return leaveGroupRequest.members().stream().allMatch(
+                    member -> member.reason().equals("member was removed by an 
admin: testing remove members reason")
+                );
+            }, new LeaveGroupResponse(new 
LeaveGroupResponseData().setErrorCode(Errors.NONE.code()).setMembers(
+                    Arrays.asList(
+                        new MemberResponse().setGroupInstanceId("instance-1"),
+                        new MemberResponse().setGroupInstanceId("instance-2")
+                    ))
+            ));
+
+            Collection<MemberToRemove> membersToRemove = Arrays.asList(new 
MemberToRemove("instance-1"), new MemberToRemove("instance-2"));
+
+            RemoveMembersFromConsumerGroupOptions options = new 
RemoveMembersFromConsumerGroupOptions(membersToRemove);
+            options.reason("testing remove members reason");

Review comment:
       Should we also add a test that does not specify the reason to test the 
default case?




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