Browse Source

MINOR: Fix flaky assertion in ControllerIntegrationTest (#5829)

`ControllerIntegrationTest#waitUntilControllerEpoch` sometimes fails with the following error:

```
java.util.NoSuchElementException: None.get
	at scala.None$.get(Option.scala:347)
	at scala.None$.get(Option.scala:345)
	at kafka.controller.ControllerIntegrationTest$$anonfun$waitUntilControllerEpoch$1.apply$mcZ$sp(ControllerIntegrationTest.scala:312)
	at kafka.utils.TestUtils$.waitUntilTrue(TestUtils.scala:779)
	at kafka.controller.ControllerIntegrationTest.waitUntilControllerEpoch(ControllerIntegrationTest.scala:312)
	at kafka.controller.ControllerIntegrationTest.testEmptyCluster(ControllerIntegrationTest.scala:51)
```

We should retry until the value is defined or it times out.

Reviewers: Ismael Juma <ismael@juma.me.uk>
pull/5781/head
Stanislav Kozlovski 6 years ago committed by Ismael Juma
parent
commit
d2c870b468
  1. 2
      core/src/test/scala/unit/kafka/controller/ControllerIntegrationTest.scala

2
core/src/test/scala/unit/kafka/controller/ControllerIntegrationTest.scala

@ -451,7 +451,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness { @@ -451,7 +451,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
}
private def waitUntilControllerEpoch(epoch: Int, message: String): Unit = {
TestUtils.waitUntilTrue(() => zkClient.getControllerEpoch.get._1 == epoch, message)
TestUtils.waitUntilTrue(() => zkClient.getControllerEpoch.map(_._1).contains(epoch) , message)
}
private def waitForPartitionState(tp: TopicPartition,

Loading…
Cancel
Save