kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject [kafka] branch trunk updated: MINOR: Catch NoRecordsException in testCommaSeparatedRegex() test (#5944)
Date Sat, 08 Dec 2018 17:43:53 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/trunk by this push:
     new edfa681  MINOR: Catch NoRecordsException in testCommaSeparatedRegex() test (#5944)
edfa681 is described below

commit edfa68173615cddaa421ef02ccf7b82ce4181c79
Author: Stanislav Kozlovski <stanislav_kozlovski@outlook.com>
AuthorDate: Sat Dec 8 17:43:43 2018 +0000

    MINOR: Catch NoRecordsException in testCommaSeparatedRegex() test (#5944)
    
    This test sometimes fails with
    
    ```
    kafka.tools.MirrorMaker$NoRecordsException
    	at kafka.tools.MirrorMaker$ConsumerWrapper.receive(MirrorMaker.scala:483)
    	at kafka.tools.MirrorMakerIntegrationTest$$anonfun$testCommaSeparatedRegex$1.apply$mcZ$sp(MirrorMakerIntegrationTest.scala:92)
    	at kafka.utils.TestUtils$.waitUntilTrue(TestUtils.scala:738)
    ```
    
    The test should catch `NoRecordsException` instead of `TimeoutException`.
    
    Reviewers: Ismael Juma <ismael@juma.me.uk>
---
 core/src/main/scala/kafka/tools/MirrorMaker.scala                   | 3 ++-
 .../scala/integration/kafka/tools/MirrorMakerIntegrationTest.scala  | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/core/src/main/scala/kafka/tools/MirrorMaker.scala b/core/src/main/scala/kafka/tools/MirrorMaker.scala
index c685d8c..823f0fd 100755
--- a/core/src/main/scala/kafka/tools/MirrorMaker.scala
+++ b/core/src/main/scala/kafka/tools/MirrorMaker.scala
@@ -424,7 +424,8 @@ object MirrorMaker extends Logging with KafkaMetricsGroup {
     }
   }
 
-  private class NoRecordsException extends RuntimeException
+  // package-private for tests
+  private[tools] class NoRecordsException extends RuntimeException
 
   class MirrorMakerOptions(args: Array[String]) extends CommandDefaultOptions(args) {
 
diff --git a/core/src/test/scala/integration/kafka/tools/MirrorMakerIntegrationTest.scala
b/core/src/test/scala/integration/kafka/tools/MirrorMakerIntegrationTest.scala
index 7212b3b..0329f52 100644
--- a/core/src/test/scala/integration/kafka/tools/MirrorMakerIntegrationTest.scala
+++ b/core/src/test/scala/integration/kafka/tools/MirrorMakerIntegrationTest.scala
@@ -20,7 +20,7 @@ import java.util.Properties
 
 import kafka.integration.KafkaServerTestHarness
 import kafka.server.KafkaConfig
-import kafka.tools.MirrorMaker.{ConsumerWrapper, MirrorMakerProducer}
+import kafka.tools.MirrorMaker.{ConsumerWrapper, MirrorMakerProducer, NoRecordsException}
 import kafka.utils.TestUtils
 import org.apache.kafka.clients.consumer.{ConsumerConfig, KafkaConsumer}
 import org.apache.kafka.clients.producer.{ProducerConfig, ProducerRecord}
@@ -92,8 +92,8 @@ class MirrorMakerIntegrationTest extends KafkaServerTestHarness {
           val data = mirrorMakerConsumer.receive()
           data.topic == topic && new String(data.value) == msg
         } catch {
-          // this exception is thrown if no record is returned within a short timeout, so
safe to ignore
-          case _: TimeoutException => false
+          // these exceptions are thrown if no records are returned within the timeout, so
safe to ignore
+          case _: NoRecordsException => false
         }
       }, "MirrorMaker consumer should read the expected message from the expected topic within
the timeout")
     } finally consumer.close()


Mime
View raw message