geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [2/4] incubator-geode git commit: fixed testVerifyStats unit tests handling of invalid
Date Thu, 04 Aug 2016 21:58:26 GMT
fixed testVerifyStats unit tests handling of invalid


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

Branch: refs/heads/feature/GEODE-1714
Commit: b15a64feedb267043137da6fd7273f5ed7762cf2
Parents: 22c7805
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Thu Aug 4 10:42:44 2016 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Thu Aug 4 10:42:44 2016 -0700

----------------------------------------------------------------------
 .../cache/DiskRegRecoveryJUnitTest.java         | 33 ++++++++++----------
 1 file changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b15a64fe/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegRecoveryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegRecoveryJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegRecoveryJUnitTest.java
index 792f07e..da20763 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegRecoveryJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegRecoveryJUnitTest.java
@@ -26,7 +26,9 @@ import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
 
+import com.jayway.awaitility.Awaitility;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -1368,7 +1370,7 @@ public class DiskRegRecoveryJUnitTest extends DiskRegionTestingBase
{
 
       DiskRegion dr = ((LocalRegion)region).getDiskRegion();
       if (recovValues) {
-        assertEquals(1, dr.getNumEntriesInVM());
+        waitForInVMToBe(dr, 1);
         assertEquals(0, dr.getNumOverflowOnDisk());
       } else {
         assertEquals(0, dr.getNumEntriesInVM());
@@ -1384,13 +1386,10 @@ public class DiskRegRecoveryJUnitTest extends DiskRegionTestingBase
{
       region.close();
       region = DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps, Scope.LOCAL);
       dr = ((LocalRegion)region).getDiskRegion();
-      if (recovValues) {
-        assertEquals(1, dr.getNumEntriesInVM());
-        assertEquals(0, dr.getNumOverflowOnDisk());
-      } else {
-        assertEquals(1, dr.getNumEntriesInVM());
-        assertEquals(0, dr.getNumOverflowOnDisk());
-      }
+      assertEquals(1, region.size());
+      // invalid entries are not inVM since they have no value
+      assertEquals(0, dr.getNumEntriesInVM());
+      assertEquals(0, dr.getNumOverflowOnDisk());
 
       region.clear();
       assertEquals(0, dr.getNumEntriesInVM());
@@ -1402,7 +1401,7 @@ public class DiskRegRecoveryJUnitTest extends DiskRegionTestingBase
{
       region = DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps, Scope.LOCAL);
       dr = ((LocalRegion)region).getDiskRegion();
       if (recovValues) {
-        assertEquals(1, dr.getNumEntriesInVM());
+        waitForInVMToBe(dr, 1);
         assertEquals(0, dr.getNumOverflowOnDisk());
       } else {
         assertEquals(0, dr.getNumEntriesInVM());
@@ -1418,13 +1417,9 @@ public class DiskRegRecoveryJUnitTest extends DiskRegionTestingBase
{
       region.close();
       region = DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps, Scope.LOCAL);
       dr = ((LocalRegion)region).getDiskRegion();
-      if (recovValues) {
-        assertEquals(1, dr.getNumEntriesInVM());
-        assertEquals(0, dr.getNumOverflowOnDisk());
-      } else {
-        assertEquals(1, dr.getNumEntriesInVM());
-        assertEquals(0, dr.getNumOverflowOnDisk());
-      }
+      // invalid entries have not value so the are not inVM or onDisk
+      assertEquals(0, dr.getNumEntriesInVM());
+      assertEquals(0, dr.getNumOverflowOnDisk());
 
     } finally {
       if (oldValue != null) {
@@ -1435,6 +1430,12 @@ public class DiskRegRecoveryJUnitTest extends DiskRegionTestingBase
{
     }
   }
 
+  private void waitForInVMToBe(final DiskRegion dr, final int expected) {
+    // values are recovered async from disk
+    Awaitility.await().pollInterval(10, TimeUnit.MILLISECONDS).pollDelay(10, TimeUnit.MILLISECONDS)
+    .atMost(30, TimeUnit.SECONDS).until(() -> assertEquals(expected, dr.getNumEntriesInVM()));

+  }
+
   @Test
   public void testVerifyStatsWithValues() {
     basicVerifyStats(true);


Mime
View raw message