You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by mr...@apache.org on 2015/09/10 15:00:04 UTC
svn commit: r1702241 -
/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Author: mreutegg
Date: Thu Sep 10 13:00:04 2015
New Revision: 1702241
URL: http://svn.apache.org/r1702241
Log:
OAK-3388: Inconsistent read in cluster with clock differences
Add tests (currently ignored)
Modified:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java?rev=1702241&r1=1702240&r2=1702241&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java Thu Sep 10 13:00:04 2015
@@ -92,6 +92,7 @@ import org.apache.jackrabbit.oak.spi.sta
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.apache.jackrabbit.oak.stats.Clock;
import org.junit.After;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.slf4j.Logger;
@@ -1490,6 +1491,111 @@ public class DocumentNodeStoreTest {
store.dispose();
}
+ // OAK-3388
+ @Ignore
+ @Test
+ public void clusterWithClockDifferences() throws Exception {
+ MemoryDocumentStore store = new MemoryDocumentStore();
+ long now = System.currentTimeMillis();
+ Clock c1 = new Clock.Virtual();
+ c1.waitUntil(now);
+ Revision.setClock(c1);
+ DocumentNodeStore ns1 = builderProvider.newBuilder().clock(c1)
+ .setDocumentStore(store).setAsyncDelay(0).getNodeStore();
+ NodeBuilder b1 = ns1.getRoot().builder();
+ b1.child("node");
+ merge(ns1, b1);
+ // make /node visible
+ ns1.runBackgroundOperations();
+
+ Revision.resetClockToDefault();
+ Clock c2 = new Clock.Virtual();
+ // c2 is five seconds ahead
+ c2.waitUntil(now + 5000);
+ Revision.setClock(c2);
+
+ DocumentNodeStore ns2 = builderProvider.newBuilder().clock(c2)
+ .setDocumentStore(store).setAsyncDelay(0).getNodeStore();
+ // ns2 sees /node
+ assertTrue(ns2.getRoot().hasChildNode("node"));
+
+ // remove /node on ns2
+ NodeBuilder b2 = ns2.getRoot().builder();
+ b2.child("node").remove();
+ merge(ns2, b2);
+ ns2.runBackgroundOperations();
+
+ // add /node again on ns1
+ Revision.resetClockToDefault();
+ Revision.setClock(c1);
+ ns1.runBackgroundOperations();
+ b1 = ns1.getRoot().builder();
+ assertFalse(b1.hasChildNode("node"));
+ b1.child("node");
+ merge(ns1, b1);
+ ns1.runBackgroundOperations();
+
+ // check if /node is visible on ns2
+ Revision.resetClockToDefault();
+ Revision.setClock(c2);
+ ns2.runBackgroundOperations();
+ b2 = ns2.getRoot().builder();
+ assertTrue(b2.hasChildNode("node"));
+ }
+
+ // OAK-3388
+ @Ignore
+ @Test
+ public void clusterWithClockDifferences2() throws Exception {
+ MemoryDocumentStore store = new MemoryDocumentStore();
+ long now = System.currentTimeMillis();
+ Clock c1 = new Clock.Virtual();
+ c1.waitUntil(now);
+ Revision.setClock(c1);
+ DocumentNodeStore ns1 = builderProvider.newBuilder().clock(c1)
+ .setDocumentStore(store).setAsyncDelay(0).getNodeStore();
+ NodeBuilder b1 = ns1.getRoot().builder();
+ b1.child("node").setProperty("p", 1);
+ merge(ns1, b1);
+ // make /node visible
+ ns1.runBackgroundOperations();
+
+ Revision.resetClockToDefault();
+ Clock c2 = new Clock.Virtual();
+ // c2 is five seconds ahead
+ c2.waitUntil(now + 5000);
+ Revision.setClock(c2);
+
+ DocumentNodeStore ns2 = builderProvider.newBuilder().clock(c2)
+ .setDocumentStore(store).setAsyncDelay(0).getNodeStore();
+ // ns2 sees /node
+ assertTrue(ns2.getRoot().hasChildNode("node"));
+ assertEquals(1, ns2.getRoot().getChildNode("node").getProperty("p").getValue(Type.LONG).longValue());
+
+ // increment /node/p ns2
+ NodeBuilder b2 = ns2.getRoot().builder();
+ b2.child("node").setProperty("p", 2);
+ merge(ns2, b2);
+ ns2.runBackgroundOperations();
+
+ // increment /node/p2 on ns1
+ Revision.resetClockToDefault();
+ Revision.setClock(c1);
+ ns1.runBackgroundOperations();
+ b1 = ns1.getRoot().builder();
+ assertEquals(2, b1.getChildNode("node").getProperty("p").getValue(Type.LONG).longValue());
+ b1.child("node").setProperty("p", 3);
+ merge(ns1, b1);
+ ns1.runBackgroundOperations();
+
+ // check if /node/p=3 is visible on ns2
+ Revision.resetClockToDefault();
+ Revision.setClock(c2);
+ ns2.runBackgroundOperations();
+ b2 = ns2.getRoot().builder();
+ assertEquals(3, b2.getChildNode("node").getProperty("p").getValue(Type.LONG).longValue());
+ }
+
/**
* Utility class that eases creating single cluster id merge conflicts. The two methods:
* <ul>