You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by qi...@apache.org on 2015/08/06 19:11:21 UTC

[10/19] incubator-geode git commit: GEODE-175: change test to use a wait criteria instead of pause and use millis instead of seconds

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/a9da1422
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/a9da1422
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/a9da1422

Branch: refs/heads/feature/GEODE-137
Commit: a9da1422d11d8944a210bae1294c9facd2265a80
Parents: 32186b9
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Tue Aug 4 10:42:50 2015 -0700
Committer: Qihong Chen <qc...@pivotal.io>
Committed: Thu Aug 6 10:07:47 2015 -0700

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


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a9da1422/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;
       }