diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/eviction/EvictionDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/eviction/EvictionDUnitTest.java index eb929a1efcdc..0e13301ef28c 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/eviction/EvictionDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/eviction/EvictionDUnitTest.java @@ -24,6 +24,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadPoolExecutor; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -84,6 +85,7 @@ public void before() { if (offHeap) { properties.setProperty(OFF_HEAP_MEMORY_SIZE, "200m"); } + server0 = cluster.startServerVM(0, s -> s.withNoCacheServer() .withProperties(properties).withConnectionToLocator(locatorPort)); server1 = cluster.startServerVM(1, s -> s.withNoCacheServer() @@ -102,6 +104,14 @@ public void before() { }, server0, server1); } + @After + public void tearDown() throws Exception { + // this test is asserting on the expected number of evictions depending on the current memory + // usage, so we need to make sure each test start with clean memory usage to reduce flakiness + server0.getVM().bounce(); + server1.getVM().bounce(); + } + @Test public void testDummyInlineNCentralizedEviction() { VMProvider.invokeInEveryMember("create region", () -> {