kirktrue commented on code in PR #16694:
URL: https://github.com/apache/kafka/pull/16694#discussion_r1735413135


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/ConsumerHeartbeatRequestManagerTest.java:
##########
@@ -746,6 +746,51 @@ public void 
testSendingLeaveGroupHeartbeatWhenPreviousOneInFlight(final short ve
         NetworkClientDelegate.PollResult pollAgain = 
heartbeatRequestManager.poll(time.milliseconds());
         assertEquals(0, pollAgain.unsentRequests.size());
     }
+    
+    @ParameterizedTest
+    @ApiKeyVersionsSource(apiKey = ApiKeys.CONSUMER_GROUP_HEARTBEAT)
+    public void testConsumerAcksReconciledAssignmentAfterAckLost(final short 
version) {
+        String topic = "topic1";
+        Set<String> topics = Collections.singleton(topic);
+        Uuid topicId = Uuid.randomUuid();
+        int partition = 0;
+        Map<Uuid, SortedSet<Integer>> testAssignment = 
Collections.singletonMap(
+                topicId, mkSortedSet(partition)
+        );
+        
+        // complete reconciliation
+        createHeartbeatStateAndRequestManager();
+        when(subscriptions.subscription()).thenReturn(topics);
+        subscriptions.subscribe(topics, Optional.empty());
+        mockReconcilingMemberData(testAssignment);
+        
+        // send heartbeat1 to ack assignment tp0
+        time.sleep(DEFAULT_HEARTBEAT_INTERVAL_MS);
+        NetworkClientDelegate.PollResult result = 
heartbeatRequestManager.poll(time.milliseconds());
+        
+        // HB1 times out
+        result.unsentRequests.get(0)

Review Comment:
   It would be ideal to assert that the number of requests is >= 1 before 
getting the first element, only because if we ever have a regression somewhere 
and it returns an empty request list, the `IndexOutOfBoundsException` (or 
whatever) won't be very helpful in tracking down the problem.



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