[TEST] Check static test state after suite scoped cluster is shut down (#21256)

Checks on static test state are run by an @After method in ESTestCase. Suite-scoped tests in ESIntegTestCase only shut down in an @AfterClass method, which executes after the @After method in ESTestCase. The suite-scoped cluster can thus still execute actions that will violate the checks in @After without those being caught. A subsequent test executing within the same JVM will fail these checks however when @After gets called for that test.

This commit adds an explicit call to check the static test state after the suite-scoped cluster has been shut down.
This commit is contained in:
Yannick Welsch 2016-11-02 15:00:16 +01:00 committed by GitHub
parent 7276737a03
commit 6930a4846c
2 changed files with 6 additions and 0 deletions

View File

@ -1970,6 +1970,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
try {
INSTANCE.printTestMessage("cleaning up after");
INSTANCE.afterInternal(true);
checkStaticState();
} finally {
INSTANCE = null;
}

View File

@ -237,6 +237,11 @@ public abstract class ESTestCase extends LuceneTestCase {
@After
public final void ensureCleanedUp() throws Exception {
checkStaticState();
}
// separate method so that this can be checked again after suite scoped cluster is shut down
protected static void checkStaticState() throws Exception {
MockPageCacheRecycler.ensureAllPagesAreReleased();
MockBigArrays.ensureAllArraysAreReleased();
// field cache should NEVER get loaded.