This is an automated email from the ASF dual-hosted git repository. rsivaram pushed a commit to branch 2.2 in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/2.2 by this push: new 10c2169 KAFKA-7980 - Fix timing issue in SocketServerTest.testConnectionRateLimit (#6391) 10c2169 is described below commit 10c2169fd127b3bd4f27885c429ef7f3bdbbb3cb Author: Rajini Sivaram <rajinisiva...@googlemail.com> AuthorDate: Fri Mar 8 14:37:23 2019 +0000 KAFKA-7980 - Fix timing issue in SocketServerTest.testConnectionRateLimit (#6391) Test currently checks that there were at least 5 polls when 5 connections are established with connectionQueueSize=1. But we could be doing the check just after the 5th connection before the 5th poll, so updated the check to verify that there were at least 4 polls. Reviewers: Ismael Juma <ism...@juma.me.uk> --- core/src/test/scala/unit/kafka/network/SocketServerTest.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/test/scala/unit/kafka/network/SocketServerTest.scala b/core/src/test/scala/unit/kafka/network/SocketServerTest.scala index 463bbd8..81a96a3 100644 --- a/core/src/test/scala/unit/kafka/network/SocketServerTest.scala +++ b/core/src/test/scala/unit/kafka/network/SocketServerTest.scala @@ -1118,8 +1118,13 @@ class SocketServerTest extends JUnitSuite { "Connections not registered", waitTimeMs = 15000) assertEquals(Set.empty, errors) testableSelector.waitForOperations(SelectorOperation.Register, numConnections) + + // In each iteration, SocketServer processes at most connectionQueueSize (1 in this test) + // new connections and then does poll() to process data from existing connections. So for + // 5 connections, we expect 5 iterations. Since we stop when the 5th connection is processed, + // we can safely check that there were atleast 4 polls prior to the 5th connection. val pollCount = testableSelector.operationCounts(SelectorOperation.Poll) - assertTrue(s"Connections created too quickly: $pollCount", pollCount >= numConnections) + assertTrue(s"Connections created too quickly: $pollCount", pollCount >= numConnections - 1) verifyAcceptorBlockedPercent("PLAINTEXT", expectBlocked = true) assertProcessorHealthy(testableServer, sockets)