dengziming commented on a change in pull request #10243:
URL: https://github.com/apache/kafka/pull/10243#discussion_r587236489



##########
File path: core/src/test/scala/integration/kafka/api/ConsumerBounceTest.scala
##########
@@ -483,7 +483,8 @@ class ConsumerBounceTest extends AbstractConsumerTest with 
Logging {
       def onPartitionsRevoked(partitions: Collection[TopicPartition]): Unit = {
       }})
     consumer.poll(time.Duration.ofSeconds(3L))
-    assertTrue(assignSemaphore.tryAcquire(1, TimeUnit.SECONDS), "Assignment 
did not complete on time")
+    TestUtils.waitUntilTrue(() => assignSemaphore.tryAcquire(100, 
TimeUnit.MILLISECONDS),
+      "Assignment did not complete on time")

Review comment:
       That make sense, I tried to print the time cost by `consumer.poll`, 
   ```
       println("start:" + System.currentTimeMillis() )
       consumer.poll(time.Duration.ofSeconds(3L))
       println("end:" + System.currentTimeMillis() )
   ```
   
   and I found that `poll` will cost 3 seconds since no data is consumed before 
timeout.
   ```
   start:1614844034207
   end:1614844037213
   ```
   
   We can save almost 3 seconds after moving `poll` to `waitUntilTrue` .
   




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

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


Reply via email to