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


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/HeartbeatRequestManagerTest.java:
##########
@@ -898,6 +854,42 @@ private HeartbeatRequestManager 
createHeartbeatRequestManager(
                 heartbeatState,
                 heartbeatRequestState,
                 backgroundEventHandler,
-                metrics);
+                new Metrics());
+    }
+
+    private void mockJoiningMemberData(boolean instanceId) {
+        when(membershipManager.memberId()).thenReturn("");
+        when(membershipManager.memberEpoch()).thenReturn(0);
+        when(membershipManager.groupId()).thenReturn(DEFAULT_GROUP_ID);
+        if (instanceId)
+            
when(membershipManager.groupInstanceId()).thenReturn(Optional.of(DEFAULT_GROUP_INSTANCE_ID));
+        else
+            
when(membershipManager.groupInstanceId()).thenReturn(Optional.empty());
+        
when(membershipManager.currentAssignment()).thenReturn(LocalAssignment.NONE);
+        
when(membershipManager.serverAssignor()).thenReturn(Optional.of("uniform"));
+        when(membershipManager.state()).thenReturn(MemberState.UNSUBSCRIBED);

Review Comment:
   this is a bit confusing because it's not what happens in practice. A member 
that is about to join (send first HB) is in JOINING state, not unsubscribed. I 
guess you needed this because of the existing `testHeartbeatState` that uses 
this func and expects the state to be UNSUBSCRIBED. I would say that's what is 
actually wrong. I would suggest we remove the 
`assertEquals(MemberState.UNSUBSCRIBED, membershipManager.state());` on ln 560, 
and this expectation here too. (we're only asserting on something we set 
ourselves)



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