kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jun...@apache.org
Subject git commit: kafka-1090; testPipelinedRequestOrdering has transient failures; patched by Jun Rao; reviewed by Joel Koshy, Guozhang Wang, and Neha Narkhede
Date Thu, 17 Oct 2013 17:26:49 GMT
Updated Branches:
  refs/heads/trunk c66e4d586 -> d0e948ca8


kafka-1090; testPipelinedRequestOrdering has transient failures; patched by Jun Rao; reviewed
by Joel Koshy, Guozhang Wang, and Neha Narkhede


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

Branch: refs/heads/trunk
Commit: d0e948ca86730a900adbe3300fe4af01cf15922a
Parents: c66e4d5
Author: Jun Rao <junrao@gmail.com>
Authored: Thu Oct 17 10:26:53 2013 -0700
Committer: Jun Rao <junrao@gmail.com>
Committed: Thu Oct 17 10:26:53 2013 -0700

----------------------------------------------------------------------
 .../unit/kafka/network/SocketServerTest.scala     | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/d0e948ca/core/src/test/scala/unit/kafka/network/SocketServerTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/network/SocketServerTest.scala b/core/src/test/scala/unit/kafka/network/SocketServerTest.scala
index 94b5a2a..4ff6f55 100644
--- a/core/src/test/scala/unit/kafka/network/SocketServerTest.scala
+++ b/core/src/test/scala/unit/kafka/network/SocketServerTest.scala
@@ -29,6 +29,7 @@ import java.nio.ByteBuffer
 import kafka.common.TopicAndPartition
 import kafka.message.ByteBufferMessageSet
 import java.nio.channels.SelectionKey
+import kafka.utils.TestUtils
 
 
 class SocketServerTest extends JUnitSuite {
@@ -107,7 +108,7 @@ class SocketServerTest extends JUnitSuite {
   }
 
   @Test
-  def testPipelinedRequestOrdering() {
+  def testSocketSelectionKeyState() {
     val socket = connect()
     val correlationId = -1
     val clientId = SyncProducerConfig.DefaultClientId
@@ -123,19 +124,18 @@ class SocketServerTest extends JUnitSuite {
     byteBuffer.get(serializedBytes)
 
     sendRequest(socket, 0, serializedBytes)
-    sendRequest(socket, 0, serializedBytes)
 
-    // here the socket server should've read only the first request completely and since
the response is not sent yet
-    // the selection key should not be readable
     val request = server.requestChannel.receiveRequest
+    // Since the response is not sent yet, the selection key should not be readable.
     Assert.assertFalse((request.requestKey.asInstanceOf[SelectionKey].interestOps & SelectionKey.OP_READ)
== SelectionKey.OP_READ)
 
     server.requestChannel.sendResponse(new RequestChannel.Response(0, request, null))
 
-    // if everything is working correctly, until you send a response for the first request,
-    // the 2nd request will not be read by the socket server
-    val request2 = server.requestChannel.receiveRequest
-    server.requestChannel.sendResponse(new RequestChannel.Response(0, request2, null))
-    Assert.assertFalse((request.requestKey.asInstanceOf[SelectionKey].interestOps & SelectionKey.OP_READ)
== SelectionKey.OP_READ)
+    // After the response is sent to the client (which is async and may take a bit of time),
the socket key should be available for reads.
+    Assert.assertTrue(
+      TestUtils.waitUntilTrue(
+        () => { (request.requestKey.asInstanceOf[SelectionKey].interestOps & SelectionKey.OP_READ)
== SelectionKey.OP_READ },
+        5000)
+    )
   }
 }


Mime
View raw message