geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [geode] branch develop updated: GEODE-4832: use TemporaryFolder in CacheWriterGetOldValueIntegrationTest (#1652)
Date Tue, 20 Mar 2018 19:27:50 GMT
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


The following commit(s) were added to refs/heads/develop by this push:
     new 2480ed8  GEODE-4832: use TemporaryFolder in CacheWriterGetOldValueIntegrationTest
(#1652)
2480ed8 is described below

commit 2480ed853326bcded13ab1d51a89cbbcbbe47a73
Author: Kirk Lund <klund@apache.org>
AuthorDate: Tue Mar 20 12:27:47 2018 -0700

    GEODE-4832: use TemporaryFolder in CacheWriterGetOldValueIntegrationTest (#1652)
    
    * Use TemporaryFolder for DiskStore.
    * Use TestName to create uniquely named Region.
---
 .../CacheWriterGetOldValueIntegrationTest.java     | 52 +++++++++++++---------
 1 file changed, 31 insertions(+), 21 deletions(-)

diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/CacheWriterGetOldValueIntegrationTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/CacheWriterGetOldValueIntegrationTest.java
index 448c4f1..cae0147 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/CacheWriterGetOldValueIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/CacheWriterGetOldValueIntegrationTest.java
@@ -14,9 +14,14 @@
  */
 package org.apache.geode.internal.cache;
 
+import static org.apache.geode.cache.EvictionAction.OVERFLOW_TO_DISK;
+import static org.apache.geode.cache.EvictionAttributes.createLRUEntryAttributes;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.fail;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -25,35 +30,52 @@ import java.util.Map;
 
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
 
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.CacheWriterException;
 import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.DiskStore;
+import org.apache.geode.cache.DiskStoreFactory;
 import org.apache.geode.cache.EntryEvent;
-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.util.CacheWriterAdapter;
-import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 
-/**
- * FlakyTest: GEODE-4832: Caused by prior IntegrationTest(s) leaving behind a disk store
file in
- * current working directory.
- */
-@Category({IntegrationTest.class, FlakyTest.class})
+@Category(IntegrationTest.class)
 public class CacheWriterGetOldValueIntegrationTest {
 
   private final Map<String, String> expectedValues = new HashMap<>();
 
   private InternalCache cache;
+  private Region<String, String> region;
+
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  @Rule
+  public TestName testName = new TestName();
 
   @Before
   public void setUp() throws Exception {
-    cache = (InternalCache) new CacheFactory().set("locators", "").set("mcast-port", "0").create();
+    cache = (InternalCache) new CacheFactory().set(LOCATORS, "").set(MCAST_PORT, "0").create();
+
+    DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
+    diskStoreFactory.setDiskDirs(new File[] {temporaryFolder.getRoot()});
+
+    DiskStore diskStore = diskStoreFactory.create(testName.getMethodName());
+
+    RegionFactory<String, String> regionFactory = cache.createRegionFactory();
+    regionFactory.setEvictionAttributes(createLRUEntryAttributes(1, OVERFLOW_TO_DISK));
+    regionFactory.setDataPolicy(DataPolicy.NORMAL);
+    regionFactory.setDiskStoreName(diskStore.getName());
+
+    region = regionFactory.create(testName.getMethodName());
   }
 
   @After
@@ -64,7 +86,6 @@ public class CacheWriterGetOldValueIntegrationTest {
 
   @Test
   public void doPutAll() {
-    Region<String, String> region = createOverflowRegion();
     put(region, "k1", "v1");
     put(region, "k2", "v2");
 
@@ -81,7 +102,6 @@ public class CacheWriterGetOldValueIntegrationTest {
 
   @Test
   public void doRemoveAll() {
-    Region<String, String> region = createOverflowRegion();
     put(region, "k1", "v1");
     put(region, "k2", "v2");
 
@@ -104,7 +124,6 @@ public class CacheWriterGetOldValueIntegrationTest {
   }
 
   private void doOldValueTest(boolean useTx) {
-    Region<String, String> region = createOverflowRegion();
     put(region, "k1", "v1");
     put(region, "k2", "v2");
 
@@ -274,13 +293,4 @@ public class CacheWriterGetOldValueIntegrationTest {
       seenEntries.put(event.getKey(), event.getOldValue());
     }
   }
-
-  private <K, V> Region<K, V> createOverflowRegion() {
-    RegionFactory<K, V> regionFactory = cache.createRegionFactory();
-    regionFactory.setEvictionAttributes(
-        EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK));
-    regionFactory.setDataPolicy(DataPolicy.NORMAL);
-    return regionFactory.create("region");
-  }
-
 }

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

Mime
View raw message