jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1580776 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CacheInvalidationIT.java
Date Mon, 24 Mar 2014 07:21:07 GMT
Author: chetanm
Date: Mon Mar 24 07:21:07 2014
New Revision: 1580776

URL: http://svn.apache.org/r1580776
Log:
OAK-1586 - Implement checkpoint support in DocumentNodeStore

Updating the testcase to account for changes in initial cache state.

Testcase logic was bit fragile wrt initial cache state. Making it more robus

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CacheInvalidationIT.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CacheInvalidationIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CacheInvalidationIT.java?rev=1580776&r1=1580775&r2=1580776&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CacheInvalidationIT.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/CacheInvalidationIT.java
Mon Mar 24 07:21:07 2014
@@ -48,11 +48,15 @@ public class CacheInvalidationIT extends
 
     private DocumentNodeStore c1;
     private DocumentNodeStore c2;
+    private int initialCacheSizeC1;
+    private int initialCacheSizeC2;
 
     @Before
     public void prepareStores() throws Exception {
         c1 = createNS(1);
         c2 = createNS(2);
+        initialCacheSizeC1 = getCurrentCacheSize(c1);
+        initialCacheSizeC2 = getCurrentCacheSize(c2);
     }
 
     private int createScenario() throws CommitFailedException {
@@ -78,10 +82,10 @@ public class CacheInvalidationIT extends
         createTree(root, paths);
         c1.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY);
 
-        assertEquals(totalPaths, Iterables.size(ds(c1).getCacheEntries()));
+        assertEquals(initialCacheSizeC1 + paths.length, getCurrentCacheSize(c1));
 
         runBgOps(c1, c2);
-        return totalPaths;
+        return paths.length;
     }
 
     @Test
@@ -101,7 +105,7 @@ public class CacheInvalidationIT extends
         //Only 2 entries /a and /a/d would be invalidated
         // '/' would have been added to cache in start of backgroundRead
         //itself
-        assertEquals(totalPaths - 2, Iterables.size(ds(c1).getCacheEntries()));
+        assertEquals(initialCacheSizeC1+ totalPaths - 2, Iterables.size(ds(c1).getCacheEntries()));
     }
 
     @Test
@@ -127,7 +131,7 @@ public class CacheInvalidationIT extends
         assertEquals(2, result.invalidationCount);
 
         //All excluding /a and /a/d would be updated. Also we exclude / from processing
-        assertEquals(totalPaths - 3, result.upToDateCount);
+        assertEquals(initialCacheSizeC1 + totalPaths - 3, result.upToDateCount);
 
         //3 queries would be fired for [/] [/a] [/a/b, /a/c, /a/d]
         assertEquals(2, result.queryCount);
@@ -195,16 +199,20 @@ public class CacheInvalidationIT extends
         assertEquals(2, result.invalidationCount);
 
         //All excluding /a and /a/d would be updated
-        assertEquals(totalPaths - 2, result.upToDateCount);
+        assertEquals(initialCacheSizeC1 + totalPaths - 2, result.upToDateCount);
 
         //Only one query would be fired
         assertEquals(1, result.queryCount);
 
         //Query would be done for all the cache entries
-        assertEquals(totalPaths, result.cacheEntriesProcessedCount);
+        assertEquals(initialCacheSizeC1 + totalPaths, result.cacheEntriesProcessedCount);
 
     }
 
+    private int getCurrentCacheSize(DocumentNodeStore ds){
+        return Iterables.size(ds(ds).getCacheEntries());
+    }
+
     private static void refreshHead(DocumentNodeStore store) {
         ds(store).find(Collection.NODES, Utils.getIdFromPath("/"), 0);
     }



Mime
View raw message