While I was testing Kafka I end up with some issues around Awaitility. The goal was to test that Kafka topic doesn't contain the new records for a specified time. This is the simplified scratch of my test but it shows the problem. I expect that ConditionTimeoutException doesn't throw in this case. But it does.
public static void main(String[] args) {
List<String> list = new ArrayList<>();
await("wait").during(5_000, TimeUnit.MILLISECONDS).atMost(5_000, TimeUnit.MILLISECONDS)
.pollInterval(100, TimeUnit.MILLISECONDS)
.until(() -> list, List::isEmpty);
}
I increased the atMost
timeout to 5000 + pollInterval -> 5100 but still end up with exception. On my local machine throwing exception was stoped closed the value of atMost
timeout of 5170-5180.
Should I keep something in mind? Or may the test isn't correct?