From fc1eea127a6aec66284f917cc8fd776b196adf6c Mon Sep 17 00:00:00 2001 From: Stanislav Kozlovski Date: Wed, 31 Oct 2018 15:47:19 +0200 Subject: [PATCH] MINOR: Improve ReplicationQuotasTest#shouldThrottleOldSegments resiliency (#5849) I've seen this test fail with ``` java.lang.AssertionError: Throttled replication of 6352ms should be < 6000ms ``` A contributing factor is that it starts counting the time it took for replication before the replication itself has started. `createServer()` initializes ZK and other systems before it starts up the replication thread. I ran the test 25 times locally both ways. Average `throttledTook` before the change: 5341.75 Mean `throttledTook` after the change: 5256.92 Note that those are the results from `./gradlew core:test --tests kafka.server.ReplicationQuotasTest.shouldThrottleOldSegments`. I've noticed that if I run the whole test class `ReplicationQuotasTest`, the `throttledTook` is close ~4100. Reviewers: Ismael Juma --- .../test/scala/unit/kafka/server/ReplicationQuotasTest.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/test/scala/unit/kafka/server/ReplicationQuotasTest.scala b/core/src/test/scala/unit/kafka/server/ReplicationQuotasTest.scala index 78300c9a521..45c21d2096b 100644 --- a/core/src/test/scala/unit/kafka/server/ReplicationQuotasTest.scala +++ b/core/src/test/scala/unit/kafka/server/ReplicationQuotasTest.scala @@ -194,11 +194,11 @@ class ReplicationQuotasTest extends ZooKeeperTestHarness { //Add data addData(msgCount, msg) - val start = System.currentTimeMillis() - //Start the new broker (and hence start replicating) debug("Starting new broker") brokers = brokers :+ createServer(fromProps(createBrokerConfig(101, zkConnect))) + val start = System.currentTimeMillis() + waitForOffsetsToMatch(msgCount, 0, 101) val throttledTook = System.currentTimeMillis() - start