Class Awaits
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidawait(String what, Duration timeout, BooleanSupplier condition) Polls until the condition holds or the timeout passes, then fails naming what was awaited.static voidPolls asawait(String, Duration, BooleanSupplier)does, and on timeout appends whatdiagnosisreports to the failure message.
-
Method Details
-
await
public static void await(String what, Duration timeout, BooleanSupplier condition) throws InterruptedException Polls until the condition holds or the timeout passes, then fails naming what was awaited.For conditions observed outside a running job's output — a subscription appearing, a static observer filling up. Waiting on the job's own records goes through
Drains.drainDistinct(org.apache.flink.util.CloseableIterator<T>, int, java.time.Duration, java.util.function.Function<? super T, ?>)instead, which also watches for the job ending.- Parameters:
what- what is being awaited, phrased to follow "Timed out waiting for"timeout- how long to waitcondition- the condition, polled every 100 ms- Throws:
InterruptedException
-
await
public static void await(String what, Duration timeout, BooleanSupplier condition, Supplier<String> diagnosis) throws InterruptedException Polls asawait(String, Duration, BooleanSupplier)does, and on timeout appends whatdiagnosisreports to the failure message.A boolean condition says only that something did not happen, which in CI is the whole of what a reader gets: a timed-out
awaitin a run nobody can reproduce is a dead end unless the message itself carries the state it timed out in.Drains.drainDistinct(org.apache.flink.util.CloseableIterator<T>, int, java.time.Duration, java.util.function.Function<? super T, ?>)already has this property — it returns the shortfall, so the assertion that asked for the elements reports the ones that arrived — and this is the same affordance for a condition that has no elements to return. Composing one greppable line is the intended shape.The diagnosis is evaluated once, only on timeout, and a throwing supplier is reported in place of its text rather than propagated: a path that runs only when a test has already failed must not be the thing that destroys the evidence it exists to capture.
- Parameters:
what- what is being awaited, phrased to follow "Timed out waiting for"timeout- how long to waitcondition- the condition, polled every 100 msdiagnosis- the state to append to the failure message, appended after a space- Throws:
InterruptedException
-