+1, Good idea!

> On 29 Oct 2025, at 15:58, Ivan Zlenko <[email protected]> wrote:
> 
> Hi Ignite community!
> I have a small proposition in regards to our testing.
> We have an utility method called waitForCondition which we are using, as it
> implies from the name of the method, to wait until some condition will be
> met in the test. As soon as the condition is met this method returns true,
> or false if the specified condition is not met for specified timeout.
> After that our common pattern is to use assertTrue to verify whether
> waitForCondition is completed successfully.
> However we have a library awaitility in our test classpath in many modules
> which are made for similar purposes. The main difference here is that this
> library provides a clear message on what condition failed to meet in what
> time frame.
> Let's take a look at following example:
> 
> assertTrue(waitForCondition(() -> 60 == 61, 5_000));
> 
> In that case result of the assertion will be the following:
> 
> org.opentest4j.AssertionFailedError:
> Expected :true
> Actual   :false
> 
> As we can see it is hard to understand what went wrong.
> 
> The same scenario using awaitility:
> 
> await().timeout(Duration.ofSeconds(5)).until(() -> 60, equalTo(61));
> 
> Will result in the following error:
> 
> org.awaitility.core.ConditionTimeoutException: Lambda expression in
> org.apache.ignite.internal.ItApplyPartitionRaftLogOnAnotherNodesCompatibilityTest
> expected <61> but was <60> within 5 seconds.
> 
> Not only is it easier to understand what we want to achieve in the
> testing scenario, but the error message is much clearer compared to
> waitForCondition.
> 
> Also, we have a very huge bug in waitForCondition where it will not
> work at all if the supplier is frozen or executing more than specified
> timeout. For example:
> 
> assertTrue(waitForCondition(() -> {
>    try {
>        Thread.sleep(10_000);
>    } catch (InterruptedException e) {
>        throw new RuntimeException(e);
>    }
> 
>    return true;
> }, 5_000));
> 
> I would've expected that this code snippet would fail after 5 seconds,
> but it completes successfully after 10 seconds.
> 
> So my proposition to the community is to deprecate waitForCondition
> completely and eventually switch to awaitility through the whole
> Ignite code base.
> 
> Sincerely yours,
> 
> Ivan Zlenko.

Reply via email to