geode-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Schuchardt <bschucha...@pivotal.io>
Subject Re: AsyncInvocation usage in dunit tests
Date Mon, 24 Apr 2017 20:38:05 GMT
I've started using it.  It's a much better way to deal with 
AsyncInvocations.  Don't forget that there is now a dunit blackboard 
that can be used to coordinate actions in AsyncInvocations.  I've been 
using it to fix flaky test failures that use asyncs.  I recently did 
that with DeadlockDetectorDUnitTest.

Le 4/24/2017 à 12:57 PM, Kirk Lund a écrit :
> I'm updating a test and noticed that this test is using an old pattern for
> AsyncInvocation which made me realize that I may not have mentioned this
> before...
>
> AsyncInvocation has been updated to make it easier to use.
>
> Example:
>
> AsyncInvocation asyInvk1 =
> vm1.invokeAsync(createIndexThrougXML("vm1testAsyncIndexWhileDoingGII",
> name, fileName));
>
> Instead of something like this:
>
> ThreadUtils.join(asyInvk1, 30 * 1000);
> if (asyInvk1.exceptionOccurred()) {
>    Assert.fail("asyInvk1 failed", asyInvk1.getException());
> }
>
> You can now simplify that to:
>
> asyInvk1.await();
>
> Await joins to the AsyncInvocation with a default timeout of 60 seconds (or
> you can specify your own timeout), throws TimeoutException if it times out
> or throws any Exception that the invocation threw (wrapped in
> AssertionError).
>
> AsyncInvocation also implements Future<V> now so it's easier to use if
> you're trying to get back some sort of value from it.
>


Mime
View raw message