kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsiva...@apache.org
Subject kafka git commit: KAFKA-6010; Relax record conversion time test to avoid build failure
Date Wed, 04 Oct 2017 21:37:46 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 06738b41b -> 51c652c40


KAFKA-6010; Relax record conversion time test to avoid build failure

For record conversion tests, check time >=0 since conversion times may be too small to
be measured accurately. Since default value is -1, the test is still useful. Also increase
message size in SslTransportLayerTest#testNetworkThreadTimeRecorded to avoid failures when
processing time is too small.

Author: Rajini Sivaram <rajinisivaram@googlemail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #4018 from rajinisivaram/KAFKA-6010-MemoryRecordsBuilderTest


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

Branch: refs/heads/trunk
Commit: 51c652c40cb8a775b40374e968ed35bec5378906
Parents: 06738b4
Author: Rajini Sivaram <rajinisivaram@googlemail.com>
Authored: Wed Oct 4 17:37:26 2017 -0400
Committer: Rajini Sivaram <rajinisivaram@googlemail.com>
Committed: Wed Oct 4 17:37:26 2017 -0400

----------------------------------------------------------------------
 .../apache/kafka/common/network/SslTransportLayerTest.java   | 8 +++++---
 .../apache/kafka/common/record/MemoryRecordsBuilderTest.java | 4 +++-
 core/src/test/scala/unit/kafka/log/LogValidatorTest.scala    | 2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/51c652c4/clients/src/test/java/org/apache/kafka/common/network/SslTransportLayerTest.java
----------------------------------------------------------------------
diff --git a/clients/src/test/java/org/apache/kafka/common/network/SslTransportLayerTest.java
b/clients/src/test/java/org/apache/kafka/common/network/SslTransportLayerTest.java
index 6229eb6..a782627 100644
--- a/clients/src/test/java/org/apache/kafka/common/network/SslTransportLayerTest.java
+++ b/clients/src/test/java/org/apache/kafka/common/network/SslTransportLayerTest.java
@@ -595,7 +595,7 @@ public class SslTransportLayerTest {
         InetSocketAddress addr = new InetSocketAddress("localhost", server.port());
         selector.connect(node, addr, BUFFER_SIZE, BUFFER_SIZE);
 
-        String message = TestUtils.randomString(10 * 1024);
+        String message = TestUtils.randomString(1024 * 1024);
         NetworkTestUtils.waitForChannelReady(selector, node);
         KafkaChannel channel = selector.channel(node);
         assertTrue("SSL handshake time not recorded", channel.getAndResetNetworkThreadTimeNanos()
> 0);
@@ -606,7 +606,8 @@ public class SslTransportLayerTest {
         while (selector.completedSends().isEmpty()) {
             selector.poll(100L);
         }
-        assertTrue("Send time not recorded", channel.getAndResetNetworkThreadTimeNanos()
> 0);
+        long sendTimeNanos = channel.getAndResetNetworkThreadTimeNanos();
+        assertTrue("Send time not recorded: " + sendTimeNanos, sendTimeNanos > 0);
         assertEquals("Time not reset", 0, channel.getAndResetNetworkThreadTimeNanos());
         assertFalse("Unexpected bytes buffered", channel.hasBytesBuffered());
         assertEquals(0, selector.completedReceives().size());
@@ -616,7 +617,8 @@ public class SslTransportLayerTest {
             selector.poll(100L);
             assertEquals(0, selector.numStagedReceives(channel));
         }
-        assertTrue("Receive time not recorded", channel.getAndResetNetworkThreadTimeNanos()
> 0);
+        long receiveTimeNanos = channel.getAndResetNetworkThreadTimeNanos();
+        assertTrue("Receive time not recorded: " + receiveTimeNanos, receiveTimeNanos >
0);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/kafka/blob/51c652c4/clients/src/test/java/org/apache/kafka/common/record/MemoryRecordsBuilderTest.java
----------------------------------------------------------------------
diff --git a/clients/src/test/java/org/apache/kafka/common/record/MemoryRecordsBuilderTest.java
b/clients/src/test/java/org/apache/kafka/common/record/MemoryRecordsBuilderTest.java
index 15cc508..c713d17 100644
--- a/clients/src/test/java/org/apache/kafka/common/record/MemoryRecordsBuilderTest.java
+++ b/clients/src/test/java/org/apache/kafka/common/record/MemoryRecordsBuilderTest.java
@@ -648,7 +648,9 @@ public class MemoryRecordsBuilderTest {
             int numRecordsConverted, long finalBytes, long preConvertedBytes) {
         assertNotNull("Records processing info is null", processingStats);
         assertEquals(numRecordsConverted, processingStats.numRecordsConverted());
-        assertTrue("Processing time not recorded", processingStats.conversionTimeNanos()
> 0);
+        // Since nanoTime accuracy on build machines may not be sufficient to measure small
conversion times,
+        // only check if the value >= 0. Default is -1, so this checks if time has been
recorded.
+        assertTrue("Processing time not recorded: " + processingStats, processingStats.conversionTimeNanos()
>= 0);
         long tempBytes = processingStats.temporaryMemoryBytes();
         if (compressionType == CompressionType.NONE) {
             if (numRecordsConverted == 0)

http://git-wip-us.apache.org/repos/asf/kafka/blob/51c652c4/core/src/test/scala/unit/kafka/log/LogValidatorTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/log/LogValidatorTest.scala b/core/src/test/scala/unit/kafka/log/LogValidatorTest.scala
index 4d8365b..131152a 100644
--- a/core/src/test/scala/unit/kafka/log/LogValidatorTest.scala
+++ b/core/src/test/scala/unit/kafka/log/LogValidatorTest.scala
@@ -1078,7 +1078,7 @@ class LogValidatorTest {
     assertNotNull("Records processing info is null", stats)
     assertEquals(numConvertedRecords, stats.numRecordsConverted)
     if (numConvertedRecords > 0)
-      assertTrue(s"Conversion time not recorded $stats", stats.conversionTimeNanos > 0)
+      assertTrue(s"Conversion time not recorded $stats", stats.conversionTimeNanos >=
0)
     val originalSize = records.sizeInBytes
     val tempBytes = stats.temporaryMemoryBytes
     if (numConvertedRecords > 0 && compressed)


Mime
View raw message