kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maniku...@apache.org
Subject [kafka] branch 2.4 updated: MINOR: fix flaky ConsumerBounceTest.testClose
Date Thu, 14 Nov 2019 08:18:11 GMT
This is an automated email from the ASF dual-hosted git repository.

manikumar pushed a commit to branch 2.4
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/2.4 by this push:
     new 446f787  MINOR: fix flaky ConsumerBounceTest.testClose
446f787 is described below

commit 446f787dfc2073d1490df3d76c19db719e3db7fc
Author: Lucas Bradstreet <lucas@confluent.io>
AuthorDate: Thu Nov 14 13:47:10 2019 +0530

    MINOR: fix flaky ConsumerBounceTest.testClose
    
    Fixes `java.util.concurrent.ExecutionException: java.lang.AssertionError: Close finished
too quickly 5999`.
    
    The close test sets a close duration in milliseconds, but measures the time taken in nanoseconds.
This leads to small error due to the resolution in each, where the close is deemed to have
taken too little time.
    
    When I measured the start and end with nanoTime, I found the time taken to close was `5999641566
ns (5999.6ms)` which seems close enough to be a resolution error. I've run the test 50 times
and have not hit the "Close finished too quickly" issue again, whereas previously I hit a
failure pretty quickly.
    
    Author: Lucas Bradstreet <lucas@confluent.io>
    
    Reviewers: Ismael Juma <ismael@juma.me.uk>
    
    Closes #7683 from lbradstreet/flaky-consumer-bounce-test
    
    (cherry picked from commit 2bd6b6ff0f86d588fc09f96973a469989b9693df)
    Signed-off-by: Manikumar Reddy <manikumar@confluent.io>
---
 core/src/test/scala/integration/kafka/api/ConsumerBounceTest.scala | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/src/test/scala/integration/kafka/api/ConsumerBounceTest.scala b/core/src/test/scala/integration/kafka/api/ConsumerBounceTest.scala
index e355400..6c3201b 100644
--- a/core/src/test/scala/integration/kafka/api/ConsumerBounceTest.scala
+++ b/core/src/test/scala/integration/kafka/api/ConsumerBounceTest.scala
@@ -457,10 +457,10 @@ class ConsumerBounceTest extends AbstractConsumerTest with Logging {
       closeTimeoutMs: Long, minCloseTimeMs: Option[Long], maxCloseTimeMs: Option[Long]):
Future[Any] = {
     executor.submit(CoreUtils.runnable {
       val closeGraceTimeMs = 2000
-      val startNanos = System.nanoTime
+      val startMs = System.currentTimeMillis()
       info("Closing consumer with timeout " + closeTimeoutMs + " ms.")
       consumer.close(time.Duration.ofMillis(closeTimeoutMs))
-      val timeTakenMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime - startNanos)
+      val timeTakenMs = System.currentTimeMillis() - startMs
       maxCloseTimeMs.foreach { ms =>
         assertTrue("Close took too long " + timeTakenMs, timeTakenMs < ms + closeGraceTimeMs)
       }


Mime
View raw message