Browse Source

MINOR: Fix LogDirFailureTest flake

Ensure that `TestUtils.waitUntilTrue(..)` is blocked on both send completed and a new leader being assigned

Author: Gardner Vickers <gardner@vickers.me>

Reviewers: Dhruvil Shah <dhruvil@confluent.io>, Dong Lin <lindong28@gmail.com>

Closes #5695 from gardnervickers/log-dir-failure-test-fix
pull/5695/merge
Gardner Vickers 6 years ago committed by Dong Lin
parent
commit
6165b43744
  1. 4
      core/src/test/scala/unit/kafka/server/LogDirFailureTest.scala

4
core/src/test/scala/unit/kafka/server/LogDirFailureTest.scala

@ -178,13 +178,15 @@ class LogDirFailureTest extends IntegrationTestHarness { @@ -178,13 +178,15 @@ class LogDirFailureTest extends IntegrationTestHarness {
}
}
// Wait for producer to update metadata for the partition
TestUtils.waitUntilTrue(() => {
// ProduceResponse may contain KafkaStorageException and trigger metadata update
producer.send(record)
producer.partitionsFor(topic).asScala.find(_.partition() == 0).get.leader().id() != leaderServerId
}, "Expected new leader for the partition", 6000L)
// Block on send to ensure that new leader accepts a message.
producer.send(record).get(6000L, TimeUnit.MILLISECONDS)
// Consumer should receive some messages
TestUtils.waitUntilTrue(() => {
consumer.poll(0).count() > 0

Loading…
Cancel
Save