lianetm commented on code in PR #16449: URL: https://github.com/apache/kafka/pull/16449#discussion_r1665069309
########## clients/src/test/java/org/apache/kafka/clients/consumer/internals/MembershipManagerImplTest.java: ########## @@ -2302,6 +2303,61 @@ public void testRebalanceMetricsOnFailedRebalance() { assertEquals(-1d, getMetricValue(metrics, rebalanceMetricsManager.lastRebalanceSecondsAgo)); } + @Test + public void testLeaveGroupWhenStateIsFatal() { + MembershipManagerImpl membershipManager = createMemberInStableState(null); + when(subscriptionState.hasAutoAssignedPartitions()).thenReturn(true); + membershipManager.transitionToFatal(); + assertEquals(MemberState.FATAL, membershipManager.state()); + + subscriptionState.assignFromUser(Collections.singleton(new TopicPartition("topic", 0))); + assertEquals(1, subscriptionState.numAssignedPartitions()); Review Comment: Cool. Related although not introduced by this PR, this makes me notice that we don't have this full story covered in the tests (not testing the call to `subscriptionState.unsubscribed` when `isNotInGroup` is false). Would you mind adding the same verification you added for `notInGroup` true, to the func that covers this for `notInGroup` false? Should be the same `verify(subscriptionState).unsubscribe();` but added to `assertStaleMemberLeavesGroupAndClearsAssignment` I would say. -- 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