squah-confluent commented on code in PR #23538:
URL: https://github.com/apache/kafka/pull/23538#discussion_r4064368791
##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/classic/ClassicGroupTest.java:
##########
@@ -1050,9 +1052,25 @@ public void testValidateOffsetCommit(short version) {
// Replace static member.
group.replaceStaticMember("instance-id", "member-id", "new-member-id");
- // The old instance id should be fenced.
- assertThrows(FencedInstanceIdException.class,
- () -> group.validateOffsetCommit("member-id", "instance-id", 1,
false, version));
+ // The old instance id should be fenced. The log should name the
correct operation.
+ try (LogCaptureAppender appender =
LogCaptureAppender.createAndRegister(ClassicGroup.class)) {
+ assertThrows(FencedInstanceIdException.class,
+ () -> group.validateOffsetCommit("member-id", "instance-id",
1, false, version));
+
+ assertEquals(1, appender.getMessages(Level.INFO).stream()
+ .filter(msg -> msg.contains("during operation offset-commit"))
+ .count());
+ }
Review Comment:
We don't usually test for log messages but we could argue that these
particular log messages are important for diagnosing fencing issues. In that
case we'd want to test that the logs contain the rest of the information we
need too, like the member id and instance id. The group id is missing but that
looks like a systemic issue across the entire class so we can leave that for a
separate PR if we decide to add it.
and the same for txn-offset-commit.
```suggestion
// The old instance id should be fenced and the operation logged.
try (LogCaptureAppender appender =
LogCaptureAppender.createAndRegister(ClassicGroup.class)) {
assertThrows(FencedInstanceIdException.class,
() -> group.validateOffsetCommit("member-id", "instance-id",
1, false, version));
assertEquals(1, appender.getMessages(Level.INFO).stream()
.filter(msg -> msg.contains("Request memberId=member-id for
static member with groupInstanceId=instance-id is fenced by existing
memberId=new-member-id during operation offset-commit"))
.count());
}
```
--
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]