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


##########
clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:
##########
@@ -2686,12 +2686,11 @@ public void testCurrentLag(GroupProtocol groupProtocol) 
throws InterruptedExcept
         // poll once again, which should send the list-offset request
         consumer.seek(tp0, 50L);
         consumer.poll(Duration.ofMillis(0));
-        // requests: list-offset, fetch
-        TestUtils.waitForCondition(() -> {
-            boolean hasListOffsetRequest = requestGenerated(client, 
ApiKeys.LIST_OFFSETS);
-            boolean hasFetchRequest = requestGenerated(client, ApiKeys.FETCH);
-            return hasListOffsetRequest && hasFetchRequest;
-        }, "No list-offset & fetch request sent");

Review Comment:
   In addition, the `KafkaConsumerTest.testCurrentLag()` test only issues one 
call to `poll()` before checking that both RPCs were sent. In 
`ClassicKafkaConsumer`, the 'update fetch positions' stage will time out and it 
will continue to the 'fetch' stage within the same call to `poll()`. In the 
version of `AsyncKafkaConsumer` in this PR, we are no longer guaranteed to 
complete both stages within a single call to `poll()`.
   
   The test passes if I move the call to `poll()` to inside the loop like this:
   
   ```java
   // requests: list-offset, fetch
   TestUtils.waitForCondition(() -> {
       consumer.poll(Duration.ofMillis(0));
       boolean hasListOffsetRequest = requestGenerated(client, 
ApiKeys.LIST_OFFSETS);
       boolean hasFetchRequest = requestGenerated(client, ApiKeys.FETCH);
       return hasListOffsetRequest && hasFetchRequest;
   }, () -> "No list-offset & fetch request sent");
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to