You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2018/05/09 16:51:22 UTC

[geode] 02/02: GEODE-5177: Clean up DiskRegionDistributedTest

This is an automated email from the ASF dual-hosted git repository.

klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 5e8e8f661942d6506c0ab57356962591b173c1c0
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Tue May 8 16:53:55 2018 -0700

    GEODE-5177: Clean up DiskRegionDistributedTest
    
    Overhaul test to use JUnit rules and Awaitility.
---
 .../geode/cache30/DiskRegionDistributedTest.java   | 520 ++++++++-------------
 1 file changed, 206 insertions(+), 314 deletions(-)

diff --git a/geode-core/src/test/java/org/apache/geode/cache30/DiskRegionDistributedTest.java b/geode-core/src/test/java/org/apache/geode/cache30/DiskRegionDistributedTest.java
index 74f6a03..75e76dd 100644
--- a/geode-core/src/test/java/org/apache/geode/cache30/DiskRegionDistributedTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache30/DiskRegionDistributedTest.java
@@ -14,55 +14,80 @@
  */
 package org.apache.geode.cache30;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.apache.geode.cache.EvictionAction.OVERFLOW_TO_DISK;
+import static org.apache.geode.cache.EvictionAttributes.createLRUEntryAttributes;
+import static org.apache.geode.cache.EvictionAttributes.createLRUMemoryAttributes;
+import static org.apache.geode.cache.RegionShortcut.REPLICATE_PERSISTENT;
+import static org.apache.geode.cache.RegionShortcut.REPLICATE_PROXY;
+import static org.apache.geode.test.dunit.VM.getVM;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+
+import java.io.Serializable;
+
+import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.cache.AttributesFactory;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheException;
 import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.DiskStore;
-import org.apache.geode.cache.DiskStoreFactory;
-import org.apache.geode.cache.EvictionAction;
-import org.apache.geode.cache.EvictionAttributes;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionFactory;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.Scope;
-import org.apache.geode.internal.OSProcess;
-import org.apache.geode.internal.cache.LocalRegion;
+import org.apache.geode.internal.cache.InternalRegion;
 import org.apache.geode.internal.cache.eviction.EvictionCounters;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.LogWriterUtils;
-import org.apache.geode.test.dunit.SerializableCallable;
-import org.apache.geode.test.dunit.SerializableRunnable;
 import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.Wait;
-import org.apache.geode.test.dunit.WaitCriterion;
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
+import org.apache.geode.test.dunit.rules.CacheRule;
+import org.apache.geode.test.dunit.rules.DistributedDiskDirRule;
+import org.apache.geode.test.dunit.rules.DistributedTestRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
 
 /**
  * Tests the functionality of cache regions whose contents may be written to disk.
  *
- *
  * @since GemFire 3.2
  */
 @Category(DistributedTest.class)
-public class DiskRegionDistributedTest extends JUnit4CacheTestCase {
+public class DiskRegionDistributedTest implements Serializable {
 
-  /**
-   * Returns the <code>EvictionStatistics</code> for the given region
-   */
-  private EvictionCounters getLRUStats(Region region) {
-    final LocalRegion l = (LocalRegion) region;
-    return l.getEvictionController().getCounters();
+  private String uniqueName;
+  private String regionName;
+
+  private VM vm0;
+  private VM vm1;
+  private VM vm2;
+  private VM vm3;
+
+  @Rule
+  public DistributedTestRule distributedTestRule = new DistributedTestRule();
+
+  @Rule
+  public CacheRule cacheRule = new CacheRule();
+
+  /** DistributedDiskDirRule invokes before and after for SerializableTestName */
+  private SerializableTestName testName = new SerializableTestName();
+
+  @Rule
+  public DistributedDiskDirRule diskDirsRule = new DistributedDiskDirRule(testName);
+
+  @Before
+  public void setUp() {
+    vm0 = getVM(0);
+    vm1 = getVM(1);
+    vm2 = getVM(2);
+    vm3 = getVM(3);
+
+    uniqueName = getClass().getSimpleName() + "_" + testName.getMethodName();
+    regionName = uniqueName + "_region";
+
+    vm0.invoke(() -> cacheRule.createCache());
+    vm1.invoke(() -> cacheRule.createCache());
+    vm2.invoke(() -> cacheRule.createCache());
+    vm3.invoke(() -> cacheRule.createCache());
   }
 
   /**
@@ -70,166 +95,88 @@ public class DiskRegionDistributedTest extends JUnit4CacheTestCase {
    */
   @Test
   public void testRemoteUpdates() {
-    final String name = this.getUniqueName();
-
-    SerializableRunnable create = new CacheSerializableRunnable("Create region") {
-      public void run2() throws CacheException {
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.DISTRIBUTED_NO_ACK);
-        factory.setEvictionAttributes(
-            EvictionAttributes.createLRUMemoryAttributes(2, null, EvictionAction.OVERFLOW_TO_DISK));
-        File d = new File("DiskRegions" + OSProcess.getId());
-        d.mkdirs();
-        DiskStoreFactory dsf = getCache().createDiskStoreFactory();
-        dsf.setDiskDirs(new File[] {d});
-        DiskStore ds = dsf.create(name);
-        factory.setDiskStoreName(ds.getName());
-        createRegion(name, factory.create());
-      }
-    };
-
-    Host host = Host.getHost(0);
-    VM vm0 = host.getVM(0);
-    VM vm1 = host.getVM(1);
-
-    vm0.invoke(create);
-    vm1.invoke(create);
-
-    vm0.invoke(new CacheSerializableRunnable("Fill Region") {
-      public void run2() throws CacheException {
-        LocalRegion region = (LocalRegion) getRootRegion().getSubregion(name);
-        // DiskRegion dr = region.getDiskRegion();
-        EvictionCounters lruStats = getLRUStats(region);
-        int i;
-        for (i = 0; lruStats.getEvictions() <= 0; i++) {
-          region.put(new Integer(i), new short[250]);
-        }
-        assertTrue(i > 5);
+    vm0.invoke(() -> createRegionWithEvictionOverflow());
+    vm1.invoke(() -> createRegionWithEvictionOverflow());
+
+    vm0.invoke(() -> {
+      Region region = cacheRule.getCache().getRegion(uniqueName);
+      EvictionCounters evictionCounters = getEvictionCounters(region);
+      int i;
+      for (i = 0; evictionCounters.getEvictions() <= 0; i++) {
+        region.put(i, new short[250]);
       }
+
+      assertThat(i).isGreaterThan(5);
     });
 
-    vm1.invoke(new CacheSerializableRunnable("Update Region") {
-      public void run2() throws CacheException {
-        LocalRegion region = (LocalRegion) getRootRegion().getSubregion(name);
-        // DiskRegion dr = region.getDiskRegion();
-        // EvictionStatistics lruStats = getLRUStats(region);
-        for (int i = 0; i < 10; i++) {
-          region.put(new Integer(i), new int[250]);
-        }
+    vm1.invoke(() -> {
+      Region region = cacheRule.getCache().getRegion(uniqueName);
+      for (int i = 0; i < 10; i++) {
+        region.put(i, new int[250]);
       }
     });
 
-    vm0.invoke(new CacheSerializableRunnable("Verify overflow") {
-      public void run2() throws CacheException {
-        LocalRegion region = (LocalRegion) getRootRegion().getSubregion(name);
-        // DiskRegion dr = region.getDiskRegion();
-        final EvictionCounters lruStats = getLRUStats(region);
-        WaitCriterion ev = new WaitCriterion() {
-          public boolean done() {
-            return lruStats.getEvictions() > 6;
-          }
-
-          public String description() {
-            return "waiting for evictions to exceed 6";
-          }
-        };
-        Wait.waitForCriterion(ev, 5 * 1000, 200, true);
-        // DiskRegionStats diskStats = dr.getStats();
-        // assertTrue(diskStats.getWrites() > 6);
-      }
+    vm0.invoke(() -> {
+      Region region = cacheRule.getCache().getRegion(uniqueName);
+      EvictionCounters evictionCounters = getEvictionCounters(region);
+
+      await("waiting for evictions to exceed 6").atMost(1, MINUTES)
+          .until(() -> evictionCounters.getEvictions() > 6);
     });
 
-    vm0.invoke(new CacheSerializableRunnable("Populate with byte[]") {
-      public void run2() throws CacheException {
-        LocalRegion region = (LocalRegion) getRootRegion().getSubregion(name);
-        // DiskRegion dr = region.getDiskRegion();
-        // EvictionStatistics lruStats = getLRUStats(region);
-        for (int i = 0; i < 10000; i++) {
-          region.put(String.valueOf(i), String.valueOf(i).getBytes());
-        }
+    vm0.invoke(() -> {
+      Region region = cacheRule.getCache().getRegion(uniqueName);
+      for (int i = 0; i < 10000; i++) {
+        region.put(String.valueOf(i), String.valueOf(i).getBytes());
       }
     });
 
-    vm1.invoke(new CacheSerializableRunnable("Get with byte[]") {
-      public void run2() throws CacheException {
-        LocalRegion region = (LocalRegion) getRootRegion().getSubregion(name);
-        // DiskRegion dr = region.getDiskRegion();
-        // EvictionStatistics lruStats = getLRUStats(region);
-        for (int i = 0; i < 10000; i++) {
-          byte[] bytes = (byte[]) region.get(String.valueOf(i));
-          assertEquals(String.valueOf(i), new String(bytes));
-        }
+    vm1.invoke(() -> {
+      Region region = cacheRule.getCache().getRegion(uniqueName);
+      for (int i = 0; i < 10000; i++) {
+        byte[] bytes = (byte[]) region.get(String.valueOf(i));
+
+        assertThat(new String(bytes)).isEqualTo(String.valueOf(i));
       }
     });
   }
 
   /**
-   * Tests overflow with mirrored regions. Note that we have to use <code>byte</code> array values
+   * Tests overflow with mirrored regions. Note that we have to use {@code byte} array values
    * in this test. Otherwise, the size of the data in the "puter" VM would be different from the
    * size of the data in the receiver VM, thus cause the two VMs to have different LRU eviction
    * behavior.
    */
   @Test
-  public void testOverflowMirror() throws Exception {
-    final String name = this.getUniqueName();
-
-    SerializableRunnable create = new CacheSerializableRunnable("Create region") {
-      public void run2() throws CacheException {
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.DISTRIBUTED_ACK);
-        factory.setEarlyAck(false);
-        factory.setEvictionAttributes(
-            EvictionAttributes.createLRUEntryAttributes(100, EvictionAction.OVERFLOW_TO_DISK));
-        factory.setDataPolicy(DataPolicy.REPLICATE);
-        File d = new File("DiskRegions" + OSProcess.getId());
-        d.mkdirs();
-        DiskStoreFactory dsf = getCache().createDiskStoreFactory();
-        dsf.setDiskDirs(new File[] {d});
-        factory.setDiskSynchronous(true);
-        DiskStore ds = dsf.create(name);
-        factory.setDiskStoreName(ds.getName());
-        createRegion(name, factory.create());
-      }
-    };
-
-    Host host = Host.getHost(0);
-    VM vm0 = host.getVM(0);
-    VM vm1 = host.getVM(1);
-
-    vm0.invoke(create);
-    vm1.invoke(create);
-
-    vm0.invoke(new CacheSerializableRunnable("Fill Region") {
-      public void run2() throws CacheException {
-        LocalRegion region = (LocalRegion) getRootRegion().getSubregion(name);
-        // DiskRegion dr = region.getDiskRegion();
-        EvictionCounters lruStats = getLRUStats(region);
-        for (int i = 0; lruStats.getEvictions() < 10; i++) {
-          LogWriterUtils.getLogWriter().info("Put " + i);
-          region.put(new Integer(i), new byte[1]);
-        }
-
-        assertEquals(10, lruStats.getEvictions());
+  public void testOverflowMirror() {
+    vm0.invoke(() -> createReplicateRegionWithEvictionOverflow());
+    vm1.invoke(() -> createReplicateRegionWithEvictionOverflow());
+
+    vm0.invoke(() -> {
+      Region region = cacheRule.getCache().getRegion(uniqueName);
+      EvictionCounters evictionCounters = getEvictionCounters(region);
+      for (int i = 0; evictionCounters.getEvictions() < 10; i++) {
+        region.put(i, new byte[1]);
       }
+
+      assertThat(evictionCounters.getEvictions()).isEqualTo(10);
     });
 
-    vm1.invoke(new CacheSerializableRunnable("Verify overflow") {
-      public void run2() throws CacheException {
-        LocalRegion region = (LocalRegion) getRootRegion().getSubregion(name);
-        // DiskRegion dr = region.getDiskRegion();
-        EvictionCounters lruStats = getLRUStats(region);
-        assertEquals(10, lruStats.getEvictions());
-
-        // Because we are DISTRIBUTED_ACK, we can rely on the order
-        // in which messages arrive and hence the order of the LRU
-        // entries.
-        for (int i = 0; i < 10; i++) {
-          region.get(new Integer(i));
-          assertEquals("No eviction for " + i, 10 + 1 + i, lruStats.getEvictions());
-        }
+    vm1.invoke(() -> {
+      Region region = cacheRule.getCache().getRegion(uniqueName);
+      EvictionCounters evictionCounters = getEvictionCounters(region);
+
+      assertThat(evictionCounters.getEvictions()).isEqualTo(10);
+
+      // Because we are DISTRIBUTED_ACK, we can rely on the order in which messages arrive and
+      // hence the order of the LRU entries.
+      for (int i = 0; i < 10; i++) {
+        region.get(i);
+
+        assertThat(evictionCounters.getEvictions()).as("No eviction for " + i)
+            .isEqualTo(10 + 1 + i);
       }
     });
-
   }
 
   /**
@@ -237,179 +184,124 @@ public class DiskRegionDistributedTest extends JUnit4CacheTestCase {
    * overflow regions.
    */
   @Test
-  public void testDistributedInvalidate() throws Exception {
-    final String name = this.getUniqueName();
-
-    SerializableRunnable create = new CacheSerializableRunnable("Create region") {
-      public void run2() throws CacheException {
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.DISTRIBUTED_ACK);
-        factory.setEarlyAck(false);
-        factory.setEvictionAttributes(
-            EvictionAttributes.createLRUEntryAttributes(100, EvictionAction.OVERFLOW_TO_DISK));
-        File d = new File("DiskRegions" + OSProcess.getId());
-        d.mkdirs();
-        DiskStoreFactory dsf = getCache().createDiskStoreFactory();
-        dsf.setDiskDirs(new File[] {d});
-        DiskStore ds = dsf.create(name);
-        factory.setDiskStoreName(ds.getName());
-        createRegion(name, factory.create());
-      }
-    };
-
-    Host host = Host.getHost(0);
-    VM vm0 = host.getVM(0);
-    VM vm1 = host.getVM(1);
-
-    vm0.invoke(create);
-    vm1.invoke(create);
-
-    vm0.invoke(new CacheSerializableRunnable("Fill Region") {
-      public void run2() throws CacheException {
-        LocalRegion region = (LocalRegion) getRootRegion().getSubregion(name);
-        // DiskRegion dr = region.getDiskRegion();
-        EvictionCounters lruStats = getLRUStats(region);
-        for (int i = 0; lruStats.getEvictions() < 10; i++) {
-          LogWriterUtils.getLogWriter().info("Put " + i);
-          region.put(new Integer(i), new byte[1]);
-        }
-
-        assertEquals(10, lruStats.getEvictions());
+  public void testDistributedInvalidate() {
+    vm0.invoke(() -> createRegionWithEvictionCountOverflow());
+    vm1.invoke(() -> createRegionWithEvictionCountOverflow());
+
+    vm0.invoke(() -> {
+      Region region = cacheRule.getCache().getRegion(uniqueName);
+      EvictionCounters evictionCounters = getEvictionCounters(region);
+      for (int i = 0; evictionCounters.getEvictions() < 10; i++) {
+        region.put(i, new byte[1]);
       }
+
+      assertThat(evictionCounters.getEvictions()).isEqualTo(10);
     });
 
-    final Object key = new Integer(20);
+    Object key = 20;
 
-    vm1.invoke(new CacheSerializableRunnable("Invalidate entry") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        assertNotNull(region.get(key));
-        region.invalidate(key);
-      }
+    vm1.invoke(() -> {
+      Region region = cacheRule.getCache().getRegion(uniqueName);
+
+      assertThat(region.get(key)).isNotNull();
+
+      region.invalidate(key);
     });
 
-    vm0.invoke(new CacheSerializableRunnable("Verify invalidate") {
-      public void run2() throws CacheException {
-        final Region region = getRootRegion().getSubregion(name);
-        WaitCriterion ev = new WaitCriterion() {
-          public boolean done() {
-            return region.get(key) == null;
-          }
-
-          public String description() {
-            return "value for key remains: " + key;
-          }
-        };
-        Wait.waitForCriterion(ev, 500, 200, true);
-      }
+    vm0.invoke(() -> {
+      Region region = cacheRule.getCache().getRegion(uniqueName);
+
+      await("value for key remains: " + key).atMost(30, SECONDS)
+          .until(() -> region.get(key) == null);
     });
 
-    final String newValue = "NEW VALUE";
+    String newValue = "NEW VALUE";
 
-    vm1.invoke(new CacheSerializableRunnable("Update entry") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        region.put(key, newValue);
-      }
+    vm1.invoke(() -> {
+      Region region = cacheRule.getCache().getRegion(uniqueName);
+      region.put(key, newValue);
     });
 
-    vm0.invoke(new CacheSerializableRunnable("Verify update") {
-      public void run2() throws CacheException {
-        final Region region = getRootRegion().getSubregion(name);
-        WaitCriterion ev = new WaitCriterion() {
-          public boolean done() {
-            return newValue.equals(region.get(key));
-          }
-
-          public String description() {
-            return "verify update";
-          }
-        };
-        Wait.waitForCriterion(ev, 500, 200, true);
-      }
+    vm0.invoke(() -> {
+      Region region = cacheRule.getCache().getRegion(uniqueName);
+
+      await("verify update").atMost(30, SECONDS).until(() -> newValue.equals(region.get(key)));
     });
   }
 
   @Test
   public void testPersistentReplicateB4NonPersistent() {
-    Host host = Host.getHost(0);
-    VM vm1 = host.getVM(0);
-    VM vm2 = host.getVM(1);
-    VM vm3 = host.getVM(2);
-    final String regionName = getName();
-
-    vm1.invoke(new SerializableCallable() {
-      @Override
-      public Object call() throws Exception {
-        RegionFactory rf = getCache().createRegionFactory(RegionShortcut.REPLICATE_PERSISTENT);
-        Region r = rf.create(regionName);
-        assertTrue(r.getAttributes().getConcurrencyChecksEnabled());
-        return null;
-      }
+    vm1.invoke(() -> {
+      RegionFactory regionFactory = cacheRule.getCache().createRegionFactory(REPLICATE_PERSISTENT);
+      Region region = regionFactory.create(regionName);
+
+      assertThat(region.getAttributes().getConcurrencyChecksEnabled()).isTrue();
     });
-    vm2.invoke(new SerializableCallable() {
-      @Override
-      public Object call() throws Exception {
-        RegionFactory rf = getCache().createRegionFactory(RegionShortcut.REPLICATE);
-        Region region = rf.create(regionName);
-        assertTrue(region.getAttributes().getConcurrencyChecksEnabled());
-        return null;
-      }
+
+    vm2.invoke(() -> {
+      RegionFactory regionFactory =
+          cacheRule.getCache().createRegionFactory(RegionShortcut.REPLICATE);
+      Region region = regionFactory.create(regionName);
+
+      assertThat(region.getAttributes().getConcurrencyChecksEnabled()).isTrue();
     });
-    vm3.invoke(new SerializableCallable() {
-      @Override
-      public Object call() throws Exception {
-        Cache cache = getCache();
-        AttributesFactory af = new AttributesFactory();
-        af.setScope(Scope.DISTRIBUTED_ACK);
-        RegionFactory rf = cache.createRegionFactory(af.create());
-        Region r = rf.create(regionName);
-        assertNotNull(r);
-        assertTrue(r.getAttributes().getConcurrencyChecksEnabled());
-        return null;
-      }
+
+    vm3.invoke(() -> {
+      RegionFactory regionFactory = cacheRule.getCache().createRegionFactory();
+      regionFactory.setScope(Scope.DISTRIBUTED_ACK);
+
+      Region region = regionFactory.create(regionName);
+      assertThat(region.getAttributes().getConcurrencyChecksEnabled()).isTrue();
     });
   }
 
   @Test
   public void testRRProxyWithPersistentReplicates() {
-    Host host = Host.getHost(0);
-    VM vm1 = host.getVM(0);
-    VM vm2 = host.getVM(1);
-    VM vm3 = host.getVM(2);
-    final String regionName = getName();
-    SerializableCallable createRRProxy = new SerializableCallable() {
-      @Override
-      public Object call() throws Exception {
-        Region r =
-            getCache().createRegionFactory(RegionShortcut.REPLICATE_PROXY).create(regionName);
-        assertNotNull(r);
-        return null;
-      }
-    };
-    SerializableCallable createPersistentRR = new SerializableCallable() {
-      @Override
-      public Object call() throws Exception {
-        Region r =
-            getCache().createRegionFactory(RegionShortcut.REPLICATE_PERSISTENT).create(regionName);
-        assertNotNull(r);
-        return null;
-      }
-    };
-    vm1.invoke(createRRProxy);
-    vm2.invoke(createPersistentRR);
-    vm3.invoke(createRRProxy);
-
-    SerializableCallable assertConcurrency = new SerializableCallable() {
-      @Override
-      public Object call() throws Exception {
-        Region r = getCache().getRegion(regionName);
-        assertTrue(r.getAttributes().getConcurrencyChecksEnabled());
-        return null;
-      }
-    };
+    vm1.invoke(() -> {
+      cacheRule.getCache().createRegionFactory(REPLICATE_PROXY).create(regionName);
+    });
+    vm2.invoke(() -> {
+      cacheRule.getCache().createRegionFactory(REPLICATE_PERSISTENT).create(regionName);
+    });
 
-    vm1.invoke(assertConcurrency);
-    vm3.invoke(assertConcurrency);
+    assertThat(vm1.invoke(() -> cacheRule.getCache().getRegion(regionName).getAttributes()
+        .getConcurrencyChecksEnabled())).isTrue();
+    assertThat(vm2.invoke(() -> cacheRule.getCache().getRegion(regionName).getAttributes()
+        .getConcurrencyChecksEnabled())).isTrue();
+  }
+
+  private void createRegionWithEvictionOverflow() {
+    RegionFactory regionFactory = cacheRule.getCache().createRegionFactory();
+    regionFactory.setEvictionAttributes(createLRUMemoryAttributes(2, null, OVERFLOW_TO_DISK));
+    regionFactory.setScope(Scope.DISTRIBUTED_NO_ACK);
+
+    regionFactory.create(uniqueName);
+  }
+
+  private void createReplicateRegionWithEvictionOverflow() {
+    RegionFactory regionFactory = cacheRule.getCache().createRegionFactory();
+
+    regionFactory.setDataPolicy(DataPolicy.REPLICATE);
+    regionFactory.setDiskSynchronous(true);
+    regionFactory.setEvictionAttributes(createLRUEntryAttributes(100, OVERFLOW_TO_DISK));
+    regionFactory.setScope(Scope.DISTRIBUTED_ACK);
+
+    regionFactory.create(uniqueName);
+  }
+
+  private void createRegionWithEvictionCountOverflow() {
+    RegionFactory regionFactory = cacheRule.getCache().createRegionFactory();
+
+    regionFactory.setEvictionAttributes(createLRUEntryAttributes(100, OVERFLOW_TO_DISK));
+    regionFactory.setScope(Scope.DISTRIBUTED_ACK);
+
+    regionFactory.create(uniqueName);
+  }
+
+  /**
+   * Returns the {@code EvictionStatistics} for the given region
+   */
+  private EvictionCounters getEvictionCounters(Region region) {
+    return ((InternalRegion) region).getEvictionController().getCounters();
   }
 }

-- 
To stop receiving notification emails like this one, please contact
klund@apache.org.