jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1525889 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/DocumentSplitTest.java
Date Tue, 24 Sep 2013 13:56:54 GMT
Author: mreutegg
Date: Tue Sep 24 13:56:54 2013
New Revision: 1525889

URL: http://svn.apache.org/r1525889
Log:
OAK-926: MongoMK: split documents when they are too large
- Add a cluster test

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/DocumentSplitTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/DocumentSplitTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/DocumentSplitTest.java?rev=1525889&r1=1525888&r2=1525889&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/DocumentSplitTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/DocumentSplitTest.java
Tue Sep 24 13:56:54 2013
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.plugin
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.jackrabbit.mk.blobs.MemoryBlobStore;
 import org.apache.jackrabbit.oak.plugins.mongomk.util.Utils;
 import org.junit.Test;
 
@@ -154,4 +155,50 @@ public class DocumentSplitTest extends B
         valueMap = doc.getLocalMap("prop");
         assertEquals(1L, valueMap.size());
     }
+
+    @Test
+    public void cluster() {
+        MemoryDocumentStore ds = new MemoryDocumentStore();
+        MemoryBlobStore bs = new MemoryBlobStore();
+        MongoMK.Builder builder;
+
+        builder = new MongoMK.Builder();
+        builder.setDocumentStore(ds).setBlobStore(bs).setAsyncDelay(0);
+        MongoMK mk1 = builder.setClusterId(1).open();
+
+        mk1.commit("/", "+\"test\":{\"prop1\":0}", null, null);
+        // make sure the new node is visible to other MongoMK instances
+        mk1.backgroundWrite();
+
+        builder = new MongoMK.Builder();
+        builder.setDocumentStore(ds).setBlobStore(bs).setAsyncDelay(0);
+        MongoMK mk2 = builder.setClusterId(2).open();
+        builder = new MongoMK.Builder();
+        builder.setDocumentStore(ds).setBlobStore(bs).setAsyncDelay(0);
+        MongoMK mk3 = builder.setClusterId(3).open();
+
+        for (int i = 0; i < NodeDocument.REVISIONS_SPLIT_OFF_SIZE; i++) {
+            mk1.commit("/", "^\"test/prop1\":" + i, null, null);
+            mk2.commit("/", "^\"test/prop2\":" + i, null, null);
+            mk3.commit("/", "^\"test/prop3\":" + i, null, null);
+        }
+
+        mk1.runBackgroundOperations();
+        mk2.runBackgroundOperations();
+        mk3.runBackgroundOperations();
+
+        NodeDocument doc = ds.find(Collection.NODES, Utils.getIdFromPath("/test"));
+        assertNotNull(doc);
+        Map<Revision, String> revs = doc.getLocalRevisions();
+        assertEquals(3, revs.size());
+        revs = doc.getValueMap("_revisions");
+        assertEquals(3 * NodeDocument.REVISIONS_SPLIT_OFF_SIZE + 1, revs.size());
+        Revision previous = null;
+        for (Map.Entry<Revision, String> entry : revs.entrySet()) {
+            if (previous != null) {
+                assertTrue(previous.compareRevisionTime(entry.getKey()) > 0);
+            }
+            previous = entry.getKey();
+        }
+    }
 }



Mime
View raw message