Author: mreutegg
Date: Wed Oct  8 10:20:31 2014
New Revision: 1630061

URL: http://svn.apache.org/r1630061
Log:
OAK-2167: Last revision recover incomplete

Add currently ignored test case.

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

Modified: 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java?rev=1630061&r1=1630060&r2=1630061&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LastRevRecoveryAgentTest.java
 Wed Oct  8 10:20:31 2014
@@ -24,21 +24,25 @@ import java.util.List;
 
 import com.google.common.collect.Lists;
 
+import org.apache.jackrabbit.oak.api.CommitFailedException;
 import 
org.apache.jackrabbit.oak.plugins.document.DocumentStoreFixture.RDBFixture;
-import org.apache.jackrabbit.oak.plugins.document.util.Utils;
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
 import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.stats.Clock;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
+import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES;
+import static 
org.apache.jackrabbit.oak.plugins.document.util.Utils.getIdFromPath;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 @RunWith(Parameterized.class)
 public class LastRevRecoveryAgentTest {
@@ -179,7 +183,51 @@ public class LastRevRecoveryAgentTest {
         assertFalse(ds1.getLastRevRecoveryAgent().isRecoveryNeeded());
     }
 
-    private NodeDocument getDocument(DocumentNodeStore nodeStore, String path) 
{
-        return nodeStore.getDocumentStore().find(Collection.NODES, 
Utils.getIdFromPath(path));
+    @Ignore("OAK-2167")
+    @Test
+    public void recoveryOfModifiedDocument() throws Exception {
+        NodeBuilder b1 = ds1.getRoot().builder();
+        b1.child("x").child("y").setProperty("p", "v1");
+        merge(ds1, b1);
+
+        ds1.runBackgroundOperations();
+        ds2.runBackgroundOperations();
+
+        NodeBuilder b2 = ds2.getRoot().builder();
+        b2.child("x").child("y").setProperty("p", "v2");
+        merge(ds2, b2);
+
+        // simulate a crash of ds2
+        long leaseTime = ds2.getClusterInfo().getLeaseTime();
+        clock.waitUntil(clock.getTime() + leaseTime * 2);
+
+        // this write will conflict because ds2 did not run
+        // background ops after setting p=v2
+        b1 = ds1.getRoot().builder();
+        b1.child("x").child("y").setProperty("p", "v11");
+        try {
+            merge(ds1, b1);
+            fail("CommitFailedException expected");
+        } catch (CommitFailedException e) {
+            // expected
+        }
+
+        ds1.getLastRevRecoveryAgent().recover(2);
+        ds1.runBackgroundOperations();
+
+        // now the write must succeed
+        b1 = ds1.getRoot().builder();
+        b1.child("x").child("y").setProperty("p", "v11");
+        merge(ds1, b1);
+    }
+
+    private static NodeDocument getDocument(DocumentNodeStore nodeStore,
+                                            String path) {
+        return nodeStore.getDocumentStore().find(NODES, getIdFromPath(path));
+    }
+
+    private static void merge(DocumentNodeStore store, NodeBuilder builder)
+            throws CommitFailedException {
+        store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
     }
 }


Reply via email to