kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject kafka git commit: KAFKA-4058; improved test condition evaluation
Date Fri, 30 Sep 2016 19:34:22 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 5a989d174 -> 451d263bb


KAFKA-4058; improved test condition evaluation

Author: Matthias J. Sax <matthias@confluent.io>

Reviewers: Guozhang Wang <wangguoz@gmail.com>, Eno Thereska <eno.thereska@gmail.com>,
Ismael Juma <ismael@juma.me.uk>

Closes #1938 from mjsax/kafka-4058-resetIntegartionTest


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/451d263b
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/451d263b
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/451d263b

Branch: refs/heads/trunk
Commit: 451d263bb4df844bc4a359c320e7265ea25f3c8e
Parents: 5a989d1
Author: Matthias J. Sax <matthias@confluent.io>
Authored: Fri Sep 30 20:06:18 2016 +0100
Committer: Ismael Juma <ismael@juma.me.uk>
Committed: Fri Sep 30 20:33:24 2016 +0100

----------------------------------------------------------------------
 .../src/test/java/org/apache/kafka/test/TestUtils.java | 13 ++++++++-----
 .../streams/integration/ResetIntegrationTest.java      |  3 ++-
 2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/451d263b/clients/src/test/java/org/apache/kafka/test/TestUtils.java
----------------------------------------------------------------------
diff --git a/clients/src/test/java/org/apache/kafka/test/TestUtils.java b/clients/src/test/java/org/apache/kafka/test/TestUtils.java
index adc79ac..d3280e5 100644
--- a/clients/src/test/java/org/apache/kafka/test/TestUtils.java
+++ b/clients/src/test/java/org/apache/kafka/test/TestUtils.java
@@ -27,6 +27,7 @@ import org.apache.kafka.common.record.Record;
 import org.apache.kafka.common.record.Records;
 import org.apache.kafka.common.utils.Utils;
 
+import javax.xml.bind.DatatypeConverter;
 import java.io.File;
 import java.io.IOException;
 import java.nio.ByteBuffer;
@@ -43,8 +44,6 @@ import java.util.UUID;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import javax.xml.bind.DatatypeConverter;
-
 import static java.util.Arrays.asList;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -267,11 +266,15 @@ public class TestUtils {
     public static void waitForCondition(final TestCondition testCondition, final long maxWaitMs,
String conditionDetails) throws InterruptedException {
         final long startTime = System.currentTimeMillis();
 
-        while (!testCondition.conditionMet() && ((System.currentTimeMillis() - startTime)
< maxWaitMs)) {
+        boolean testConditionMet;
+        while (!(testConditionMet = testCondition.conditionMet()) && ((System.currentTimeMillis()
- startTime) < maxWaitMs)) {
             Thread.sleep(Math.min(maxWaitMs, 100L));
         }
 
-        if (!testCondition.conditionMet()) {
+        // don't re-evaluate testCondition.conditionMet() because this might slow down some
tests significantly (this
+        // could be avoided by making the implementations more robust, but we have a large
number of such implementations
+        // and it's easier to simply avoid the issue altogether)
+        if (!testConditionMet) {
             conditionDetails = conditionDetails != null ? conditionDetails : "";
             throw new AssertionError("Condition not met within timeout " + maxWaitMs + ".
" + conditionDetails);
         }
@@ -306,4 +309,4 @@ public class TestUtils {
             fail(clusterId + " cannot be converted back to UUID.");
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/kafka/blob/451d263b/streams/src/test/java/org/apache/kafka/streams/integration/ResetIntegrationTest.java
----------------------------------------------------------------------
diff --git a/streams/src/test/java/org/apache/kafka/streams/integration/ResetIntegrationTest.java
b/streams/src/test/java/org/apache/kafka/streams/integration/ResetIntegrationTest.java
index 0f1717c..ccafa30 100644
--- a/streams/src/test/java/org/apache/kafka/streams/integration/ResetIntegrationTest.java
+++ b/streams/src/test/java/org/apache/kafka/streams/integration/ResetIntegrationTest.java
@@ -120,7 +120,8 @@ public class ResetIntegrationTest {
         final List<KeyValue<Long, Long>> result = IntegrationTestUtils.waitUntilMinKeyValueRecordsReceived(
             resultTopicConsumerConfig,
             OUTPUT_TOPIC,
-            10);
+            10,
+            60000);
         // receive only first values to make sure intermediate user topic is not consumed
completely
         // => required to test "seekToEnd" for intermediate topics
         final KeyValue<Object, Object> result2 = IntegrationTestUtils.waitUntilMinKeyValueRecordsReceived(


Mime
View raw message