You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by rs...@apache.org on 2018/04/03 14:40:19 UTC

[kafka] branch trunk updated: MINOR: Add Timed wait to SslTransportLayerTest.testNetworkThreadTimeRecorded (#4811)

This is an automated email from the ASF dual-hosted git repository.

rsivaram 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 e4c8e3e  MINOR: Add Timed wait to SslTransportLayerTest.testNetworkThreadTimeRecorded (#4811)
e4c8e3e is described below

commit e4c8e3e758cbc0b5826885644da69bb7fc3c35ef
Author: Manikumar Reddy O <ma...@gmail.com>
AuthorDate: Tue Apr 3 20:10:12 2018 +0530

    MINOR: Add Timed wait to SslTransportLayerTest.testNetworkThreadTimeRecorded (#4811)
    
    Avoid test hanging when there is a failure by limiting wait time.
---
 .../kafka/common/network/SslTransportLayerTest.java  | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

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 5cc66e5..f54f490 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
@@ -645,7 +645,7 @@ public class SslTransportLayerTest {
 
         String message = TestUtils.randomString(1024 * 1024);
         NetworkTestUtils.waitForChannelReady(selector, node);
-        KafkaChannel channel = selector.channel(node);
+        final KafkaChannel channel = selector.channel(node);
         assertTrue("SSL handshake time not recorded", channel.getAndResetNetworkThreadTimeNanos() > 0);
         assertEquals("Time not reset", 0, channel.getAndResetNetworkThreadTimeNanos());
 
@@ -661,10 +661,20 @@ public class SslTransportLayerTest {
         assertEquals(0, selector.completedReceives().size());
 
         selector.unmute(node);
-        while (selector.completedReceives().isEmpty()) {
-            selector.poll(100L);
-            assertEquals(0, selector.numStagedReceives(channel));
-        }
+        // Wait for echo server to send the message back
+        TestUtils.waitForCondition(new TestCondition() {
+            @Override
+            public boolean conditionMet() {
+                try {
+                    selector.poll(100L);
+                    assertEquals(0, selector.numStagedReceives(channel));
+                } catch (IOException e) {
+                    return false;
+                }
+                return !selector.completedReceives().isEmpty();
+            }
+        }, "Timed out waiting for a message to receive from echo server");
+
         long receiveTimeNanos = channel.getAndResetNetworkThreadTimeNanos();
         assertTrue("Receive time not recorded: " + receiveTimeNanos, receiveTimeNanos > 0);
     }

-- 
To stop receiving notification emails like this one, please contact
rsivaram@apache.org.