From eeb8f67810e2b02ee73eeb3a784e365b7b780f47 Mon Sep 17 00:00:00 2001 From: Ismael Juma Date: Wed, 31 May 2017 23:47:11 +0100 Subject: [PATCH] MINOR: Use `waitUntil` to fix transient failures of ControllerFailoverTest Without it, it's possible that the assertion is checked before the exception is thrown in the callback. Author: Ismael Juma Reviewers: Rajini Sivaram Closes #3182 from ijuma/fix-controller-failover-flakiness --- .../scala/unit/kafka/controller/ControllerFailoverTest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/test/scala/unit/kafka/controller/ControllerFailoverTest.scala b/core/src/test/scala/unit/kafka/controller/ControllerFailoverTest.scala index c17ec6a21f6..13b728594f3 100644 --- a/core/src/test/scala/unit/kafka/controller/ControllerFailoverTest.scala +++ b/core/src/test/scala/unit/kafka/controller/ControllerFailoverTest.scala @@ -81,7 +81,7 @@ class ControllerFailoverTest extends KafkaServerTestHarness with Logging { TestUtils.waitUntilTrue(() => !initialController.kafkaScheduler.isStarted, "Scheduler was not shutdown") TestUtils.waitUntilTrue(() => !initialController.isActive, "Controller did not become inactive") latch.countDown() - assertTrue("handleIllegalState did not throw an exception", exceptionThrown.isDefined) + TestUtils.waitUntilTrue(() => exceptionThrown.isDefined, "handleIllegalState did not throw an exception") assertTrue(s"handleIllegalState should throw an IllegalStateException, but $exceptionThrown was thrown", exceptionThrown.get.isInstanceOf[IllegalStateException])