You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Darrel Schneider (Jira)" <ji...@apache.org> on 2021/10/08 23:32:00 UTC

[jira] [Updated] (GEODE-9706) OutOfMemoryDUnitTest can be improved

     [ https://issues.apache.org/jira/browse/GEODE-9706?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Darrel Schneider updated GEODE-9706:
------------------------------------
    Priority: Trivial  (was: Major)

> OutOfMemoryDUnitTest can be improved
> ------------------------------------
>
>                 Key: GEODE-9706
>                 URL: https://issues.apache.org/jira/browse/GEODE-9706
>             Project: Geode
>          Issue Type: Test
>          Components: redis
>            Reporter: Darrel Schneider
>            Priority: Trivial
>
> Kirk Lund made the following suggestions for improving OutOfMemoryDUnitTest:
> You might want to consider using ExecutorServiceRule or DistributedExecutorServiceRule with a CompletableFuture instead of directly using a thread:
> {code:java}
> @Rule
> public ExecutorServiceRule executorServiceRule = new ExecutorServiceRule();
>     CompletableFuture<Void> memoryPressure = executorServiceRule.runAsync(() -> {
>       try {
>         while (true) {
>           Thread.sleep(1000);
>         }
>       } catch (InterruptedException e) {
>         // done
>       }
>     });
>     // do something
>     memoryPressure.cancel(true);
> {code}
> The cancel(true) will interrupt the thread. If the test throws before that, ExecutorServiceRule will clean up any threads during tear down by invoking shutdownNow which will also interrupt any running threads. If the thread resists interrupt and hangs, the rule should print a stack trace for it as a test failure which would then make it easy to debug.
> ExecutorServiceRule will work well within the controller JVM. If you need a version of the rule that works within any JVM in a dunit test, then use DistributedExecutorServiceRule.
> Also when the test does a "join()" add a timeout like so:
> {code:java}
>   join(GeodeAwaitility.getTimeout().getSeconds(), TimeUnit.SECONDS);
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)