etolbakov commented on code in PR #12388:
URL: https://github.com/apache/kafka/pull/12388#discussion_r916680576
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinatorTest.java:
##########
@@ -1164,6 +1168,34 @@ public void testHandleNormalLeaveGroupResponse() {
assertTrue(leaveGroupFuture.succeeded());
}
+ @Test
+ public void testHandleNormalLeaveGroupResponseAndTruncatedLeaveReason() {
+ MemberResponse memberResponse = new MemberResponse()
+ .setMemberId(memberId)
+ .setErrorCode(Errors.NONE.code());
+ LeaveGroupResponse leaveGroupResponse =
+ leaveGroupResponse(Collections.singletonList(memberResponse));
+ String leaveReason = "Very
looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
leaveReason that is 271 characters long to make sure that length limit logic
handles the scenario nicely";
+ setupCoordinator(RETRY_BACKOFF_MS, Integer.MAX_VALUE,
Optional.empty());
+
+ mockClient.prepareResponse(groupCoordinatorResponse(node,
Errors.NONE));
Review Comment:
thanks, understood about `KafkaAdminClient.java`.
yeah, in my initial attempt I had `setupLeaveGroup(LeaveGroupResponse
leaveGroupResponse, String leaveReason) {`
but I didn't like the assertion bit (as it hides the truncation)
```
LeaveGroupRequestData leaveGroupRequest = ((LeaveGroupRequest) body).data();
return leaveGroupRequest.members().get(0).memberId().equals(memberId) &&
leaveGroupRequest.members().get(0).reason().equals(leaveReason.substring(0,
255));
}, leaveGroupResponse);
```
however, maybe it's not that bad.
alternatively, we can pass `actualLeaveReason` and `expectedLeaveReason` but
it looks even scarier.
I can try the former approach and show you the result.
--
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]