geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [1/5] incubator-geode git commit: GEODE-175: change test to use a wait criteria instead of pause and use millis instead of seconds
Date Tue, 04 Aug 2015 21:39:22 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-181 f37a2c42d -> a5db10d92


GEODE-175: change test to use a wait criteria instead of pause and use millis instead of seconds


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

Branch: refs/heads/feature/GEODE-181
Commit: a5db10d927541461629678171b576dbf2518cf54
Parents: be62253
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Tue Aug 4 10:42:50 2015 -0700
Committer: Kirk Lund <klund@pivotal.io>
Committed: Tue Aug 4 14:38:24 2015 -0700

----------------------------------------------------------------------
 .../cache/RemoteTransactionDUnitTest.java       | 42 +++++++++++++-------
 1 file changed, 27 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a5db10d9/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/RemoteTransactionDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/RemoteTransactionDUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/RemoteTransactionDUnitTest.java
index 7c6d133..0daaafb 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/RemoteTransactionDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/RemoteTransactionDUnitTest.java
@@ -4006,10 +4006,15 @@ protected static class ClientListener extends CacheListenerAdapter
{
     vm1.invoke(new SerializableCallable() {
       @Override
       public Object call() throws Exception {
+        System.setProperty(LocalRegion.EXPIRY_MS_PROPERTY, "true");
+        try {
         RegionFactory<String, String> rf = getCache().createRegionFactory();
         rf.setEntryTimeToLive(new ExpirationAttributes(1, ExpirationAction.LOCAL_DESTROY));
         rf.setScope(Scope.DISTRIBUTED_ACK);
         rf.create(regionName);
+        } finally {
+          System.getProperties().remove(LocalRegion.EXPIRY_MS_PROPERTY);
+        }
         return null;
       }
     });
@@ -4027,20 +4032,6 @@ protected static class ClientListener extends CacheListenerAdapter
{
       @Override
       public Object call() throws Exception {
         final Region<String, String> r = getCache().getRegion(regionName);
-        r.put("key", "value");
-        r.put("nonTXkey", "nonTXvalue");
-        getCache().getCacheTransactionManager().begin();
-        r.put("key", "newvalue");
-        // wait for entry to expire
-        DistributedTestCase.pause(5000);
-        TransactionId tx = getCache().getCacheTransactionManager().suspend();
-        // A remote tx will allow expiration to happen on the side that
-        // is not hosting the tx. But it will not allow an expiration
-        // initiated on the hosting jvm.
-        assertFalse(r.containsKey("key"));
-        assertFalse(r.containsKey("nonTXkey"));
-        getCache().getCacheTransactionManager().resume(tx);
-        getCache().getCacheTransactionManager().commit();
         WaitCriterion wc2 = new WaitCriterion() {
           @Override
           public boolean done() {
@@ -4049,9 +4040,30 @@ protected static class ClientListener extends CacheListenerAdapter
{
           
           @Override
           public String description() {
-            return "did not expire";
+            return "did not expire containsKey(key)=" + r.containsKey("key") + " r.containsKey(nonTXKey)="
+ r.containsKey("nonTXKey");
           }
         };
+        ExpiryTask.suspendExpiration();
+        Region.Entry entry = null;
+        long tilt;
+        try {
+          r.put("key", "value");
+          r.put("nonTXkey", "nonTXvalue");
+          getCache().getCacheTransactionManager().begin();
+          r.put("key", "newvalue");
+        } 
+        finally {
+          ExpiryTask.permitExpiration();
+        }
+        TransactionId tx = getCache().getCacheTransactionManager().suspend();
+        // A remote tx will allow expiration to happen on the side that
+        // is not hosting the tx. But it will not allow an expiration
+        // initiated on the hosting jvm.
+        // tx is hosted in vm2 so expiration can happen in vm1.
+        DistributedTestCase.waitForCriterion(wc2, 30000, 5, true);
+        getCache().getCacheTransactionManager().resume(tx);
+        assertTrue(r.containsKey("key"));
+        getCache().getCacheTransactionManager().commit();
         DistributedTestCase.waitForCriterion(wc2, 30000, 5, true);
         return null;
       }


Mime
View raw message