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


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/HeartbeatRequestManagerTest.java:
##########
@@ -201,8 +202,42 @@ public void testSuccessfulHeartbeatTiming() {
     @ParameterizedTest
     @ApiKeyVersionsSource(apiKey = ApiKeys.CONSUMER_GROUP_HEARTBEAT)
     public void 
testFirstHeartbeatIncludesRequiredInfoToJoinGroupAndGetAssignments(short 
version) {
-        resetWithZeroHeartbeatInterval(Optional.of(DEFAULT_GROUP_INSTANCE_ID));
+        membershipManager = new MembershipManagerImpl(
+                DEFAULT_GROUP_ID,
+                Optional.of(DEFAULT_GROUP_INSTANCE_ID),
+                0,
+                Optional.of(""),
+                subscriptions,
+                mock(CommitRequestManager.class),
+                (ConsumerMetadata) metadata,
+                logContext,
+                Optional.of(mock(ClientTelemetryReporter.class)),
+                backgroundEventHandler,
+                time,
+                new Metrics()
+        );
+        membershipManager.transitionToJoining();

Review Comment:
   actually I wonder if we really need an instance of the `membershipMgr` here 
(and all the explicit calls on it). Since we're testing how the HBMgr generates 
the data, we maybe only need to mock the `membershipMgr` funcs the HBMgr relies 
on, maybe something like this, and removing the membershipMgr instance and all 
the calls on it, that were only trying to get to the state where these values 
would be returned:
   ```
       private void mockJoiningMemberData() {
           when(membershipManager.memberId()).thenReturn("");
           when(membershipManager.memberEpoch()).thenReturn(0);
           when(membershipManager.groupId()).thenReturn(DEFAULT_GROUP_ID);
           
when(membershipManager.groupInstanceId()).thenReturn(Optional.of(DEFAULT_GROUP_INSTANCE_ID));
           
when(membershipManager.currentAssignment()).thenReturn(LocalAssignment.NONE);
       }
   ```



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