lianetm commented on code in PR #16449:
URL: https://github.com/apache/kafka/pull/16449#discussion_r1676058719


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/MembershipManagerImplTest.java:
##########
@@ -2302,6 +2317,49 @@ 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());
+
+        membershipManager.leaveGroup();
+        verify(subscriptionState).unsubscribe();
+    }
+
+    @Test
+    public void testLeaveGroupWhenStateIsUnsubscribe() {
+        MembershipManagerImpl membershipManager = new MembershipManagerImpl(
+                GROUP_ID, Optional.empty(), REBALANCE_TIMEOUT, 
Optional.empty(),
+                subscriptionState, commitRequestManager, metadata, 
LOG_CONTEXT, Optional.empty(),
+                backgroundEventHandler, time, rebalanceMetricsManager);
+        assertEquals(MemberState.UNSUBSCRIBED, membershipManager.state());
+
+        membershipManager.leaveGroup();
+        verify(subscriptionState).unsubscribe();
+    }
+
+    @Test
+    public void testLeaveGroupWhenStateIsFenced() {
+        MembershipManagerImpl membershipManager = createMemberInStableState();
+        ConsumerRebalanceListenerInvoker invoker = 
consumerRebalanceListenerInvoker();
+        mockFencedMemberStuckOnUserCallback(membershipManager, invoker);
+        assertEquals(MemberState.FENCED, membershipManager.state());
+
+        membershipManager.leaveGroup();
+        verify(subscriptionState).unsubscribe();
+    }
+
+    @Test
+    public void testLeaveGroupWhenStateIsStale() {

Review Comment:
   sorry a bit late, but I noticed now that this test is a duplicate, we 
already have a `testLeaveGroupWhenMemberIsStale`, that you updated to verify 
the unsubscribe, so I would say we just remove this one (and 
`testLeaveGroupWhenStateIsFenced`, that seems a dup of 
`testLeaveGroupWhenMemberFenced`)



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