You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by Kirk Lund <kl...@apache.org> on 2018/01/12 00:18:03 UTC
ExecutorServiceRule
GEODE-4239: Create JUnit Rule to facilitate reuse of ExecutorService
pattern for concurrent integration tests
I just merged GEODE-4239 to develop. This introduces a new JUnit rule
called ExecutorServiceRule. The commit also updates about 8 tests to use
this rule.
ExecutorServiceRule provides a reusable mechanism for executing tasks
asynchronously in tests. It creates an ExecutorService which is terminated
after the scope of the rule and can be used in tests for hangs, deadlocks,
and infinite loops.
You can use this in any type of test (Unit Test, Integration Test,
Distributed Test). If you're doing any sort of waiting in a test, then you
probably want to move that from Unit Test to Integration Test category.
RegionVersionVectorTest is an example of a Unit Test usage that's ok. You
can use it as a method @Rule or a @ClassRule.
The javadocs on ExecutorServiceRule explain how to use it. You can also
look at these tests for example usage:
* AbortableTaskServiceJUnitTest
* BlockingProcessStreamReaderWindowsTest
* DLockServiceLeakTest
* FileProcessControllerIntegrationTest
* GMSEncryptJUnitTest
* InterruptDiskJUnitTest
* MainLauncherJUnitTest
* RegionVersionVectorTest
ExecutorServiceRule is directly tested by these new tests:
* ExecutorServiceRuleTest
* ExecutorServiceRuleIntegrationTest