geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [2/7] incubator-geode git commit: fixed tests to work with PRs and invalidates to work with concurrency check regions
Date Fri, 24 Jul 2015 18:48:26 GMT
fixed tests to work with PRs and invalidates to work with concurrency check regions


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/620aa08e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/620aa08e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/620aa08e

Branch: refs/heads/develop
Commit: 620aa08ece867aef947c4af5bc40480e36b00a63
Parents: 77daa48
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Tue Jul 21 11:03:12 2015 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Thu Jul 23 17:14:07 2015 -0700

----------------------------------------------------------------------
 .../internal/cache/PartitionedRegion.java       |  8 +++++
 .../gemfire/cache30/MultiVMRegionTestCase.java  | 33 ++++++++++++--------
 .../gemfire/cache30/RegionTestCase.java         | 10 ++++--
 3 files changed, 36 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/620aa08e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
index 003b691..b11d7f6 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java
@@ -11450,5 +11450,13 @@ public class PartitionedRegion extends LocalRegion implements
     return this.getLocalMaxMemory() != 0;
   }
   
+  @Override
+  public EntryExpiryTask getEntryExpiryTask(Object key) {
+    BucketRegion br = this.getDataStore().getLocalBucketByKey(key);
+    if (br == null) {
+      throw new EntryNotFoundException("Bucket for key " + key + " does not exist.");
+    }
+    return br.getEntryExpiryTask(key);
+  }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/620aa08e/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
index 8f0c522..d0acc4d 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
@@ -73,6 +73,7 @@ import com.gemstone.gemfire.cache.TimeoutException;
 import com.gemstone.gemfire.cache.TransactionEvent;
 import com.gemstone.gemfire.cache.TransactionId;
 import com.gemstone.gemfire.cache.TransactionListener;
+import com.gemstone.gemfire.cache.partition.PartitionRegionHelper;
 import com.gemstone.gemfire.cache.server.CacheServer;
 import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
 import com.gemstone.gemfire.distributed.internal.DMStats;
@@ -4086,7 +4087,7 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
       VM vm1 = host.getVM(1);
 
 
-      vm1.invoke(new CacheSerializableRunnable("Create Region " + name) {
+      vm0.invoke(new CacheSerializableRunnable("Create with Idle") {
         public void run2() throws CacheException {
           AttributesFactory factory = new AttributesFactory(getRegionAttributes());
           factory.setStatisticsEnabled(true);
@@ -4094,15 +4095,22 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase
{
               new ExpirationAttributes(timeout,
                   ExpirationAction.DESTROY);
           factory.setEntryIdleTimeout(expire);
-          if(getRegionAttributes().getPartitionAttributes() != null){
-            createRegion(name, factory.create());  
-          } else {
-            createRegion(name);
-          }          
+          LocalRegion region =
+              (LocalRegion) createRegion(name, factory.create());
+          if (region.getDataPolicy().withPartitioning()) {
+            // Force all buckets to be created locally so the
+            // test will know that the create happens in this vm
+            // and the update (in vm1) is remote.
+            PartitionRegionHelper.assignBucketsToPartitions(region);
+          }
+          region.create(key, null);
+          EntryExpiryTask eet = region.getEntryExpiryTask(key);
+          region.create("createExpiryTime", eet.getExpirationTime());
+          waitForExpiryClockToChange(region);
         }
       });
 
-      vm0.invoke(new CacheSerializableRunnable("Create with Idle") {
+      vm1.invoke(new CacheSerializableRunnable("Create Region " + name) {
         public void run2() throws CacheException {
           AttributesFactory factory = new AttributesFactory(getRegionAttributes());
           factory.setStatisticsEnabled(true);
@@ -4110,12 +4118,11 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase
{
               new ExpirationAttributes(timeout,
                   ExpirationAction.DESTROY);
           factory.setEntryIdleTimeout(expire);
-          LocalRegion region =
-              (LocalRegion) createRegion(name, factory.create());
-          region.create(key, null);
-          EntryExpiryTask eet = region.getEntryExpiryTask(key);
-          region.create("createExpiryTime", eet.getExpirationTime());
-          waitForExpiryClockToChange(region);
+          if(getRegionAttributes().getPartitionAttributes() != null){
+            createRegion(name, factory.create());  
+          } else {
+            createRegion(name);
+          }          
         }
       });
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/620aa08e/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/RegionTestCase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/RegionTestCase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/RegionTestCase.java
index 1c1b59c..8f20e12 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/RegionTestCase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/RegionTestCase.java
@@ -3778,8 +3778,14 @@ public abstract class RegionTestCase extends CacheTestCase {
     region.invalidate(key); // touch
     assertSame(eet, region.getEntryExpiryTask(key));
     long invalidateExpiryTime = eet.getExpirationTime();
-    if (invalidateExpiryTime != putExpiryTime) {
-      fail("invalidate did reset the expiration time. putExpiryTime=" + putExpiryTime + "
invalidateExpiryTime=" + invalidateExpiryTime);
+    if (region.getConcurrencyChecksEnabled()) {
+      if (putExpiryTime - getExpiryTime <= 0L) {
+        fail("invalidate did not reset the expiration time. putExpiryTime=" + putExpiryTime
+ " invalidateExpiryTime=" + invalidateExpiryTime);
+      }
+    } else {
+      if (invalidateExpiryTime != putExpiryTime) {
+        fail("invalidate did reset the expiration time. putExpiryTime=" + putExpiryTime +
" invalidateExpiryTime=" + invalidateExpiryTime);
+      }
     }
   }
   


Mime
View raw message