DBZ-7813: waitForAvailableRecords using Awaitility
This commit is contained in:
parent
67779326ef
commit
a7bfa8d11f
@ -6,7 +6,6 @@
|
|||||||
package io.debezium.embedded;
|
package io.debezium.embedded;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.awaitility.pollinterval.FibonacciPollInterval.fibonacci;
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -953,10 +952,13 @@ protected int consumeAvailableRecords(Consumer<SourceRecord> recordConsumer) {
|
|||||||
*/
|
*/
|
||||||
protected boolean waitForAvailableRecords(long timeout, TimeUnit unit) {
|
protected boolean waitForAvailableRecords(long timeout, TimeUnit unit) {
|
||||||
assertThat(timeout).isNotNegative();
|
assertThat(timeout).isNotNegative();
|
||||||
|
assertThat(unit).isNotNull();
|
||||||
try {
|
try {
|
||||||
Awaitility.await()
|
Awaitility.await()
|
||||||
.alias("Records were not available on time")
|
.alias("Records were not available on time")
|
||||||
.pollInterval(fibonacci(unit))
|
.pollInterval(timeout < 10
|
||||||
|
? unit.toChronoUnit().getDuration().dividedBy(10)
|
||||||
|
: unit.toChronoUnit().getDuration())
|
||||||
.atMost(timeout, unit)
|
.atMost(timeout, unit)
|
||||||
.until(() -> !consumedLines.isEmpty());
|
.until(() -> !consumedLines.isEmpty());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user