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 2018/07/04 13:18:13 UTC
svn commit: r1835056 -
/jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Author: mreutegg
Date: Wed Jul 4 13:18:13 2018
New Revision: 1835056
URL: http://svn.apache.org/viewvc?rev=1835056&view=rev
Log:
OAK-7564: Commit fails when forced journal push throws exception
Ignored test
Modified:
jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Modified: jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java?rev=1835056&r1=1835055&r2=1835056&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java (original)
+++ jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java Wed Jul 4 13:18:13 2018
@@ -2909,6 +2909,65 @@ public class DocumentNodeStoreTest {
assertTrue("Two added paths should have forced flush", numChangedPaths == 0);
}
+ // OAK-7564
+ @Ignore("OAK-7564")
+ @Test
+ public void forceJournalFlushWithException() throws Exception {
+ AtomicBoolean failJournalOps = new AtomicBoolean();
+ DocumentStore store = new MemoryDocumentStore() {
+ @Override
+ public <T extends Document> boolean create(Collection<T> collection,
+ List<UpdateOp> updateOps) {
+ if (collection == Collection.JOURNAL && failJournalOps.get()) {
+ throw new DocumentStoreException("failure");
+ }
+ return super.create(collection, updateOps);
+ }
+ };
+ DocumentNodeStore ns = builderProvider.newBuilder().setAsyncDelay(0)
+ .setDocumentStore(store).getNodeStore();
+ ns.setMaxBackOffMillis(0);
+ ns.setJournalPushThreshold(2);
+
+ NodeBuilder builder = ns.getRoot().builder();
+ builder.child("foo");
+ builder.child("bar");
+ // fail operations that want to create journal documents
+ failJournalOps.set(true);
+ // now two possible outcomes are fine.
+ // Either the merge fails with an exception and the changes
+ // didn't make it to the node store
+ // OR
+ // the merge succeeds and the changes must be visible.
+ boolean success = false;
+ try {
+ merge(ns, builder);
+ success = true;
+ } catch (CommitFailedException e) {
+ // permitted as well
+ } finally {
+ // resume proper journal operations
+ failJournalOps.set(false);
+ }
+ if (success) {
+ // check if the changes are there
+ assertTrue(ns.getRoot().hasChildNode("foo"));
+ assertTrue(ns.getRoot().hasChildNode("bar"));
+ } else {
+ // check changes are not visible and didn't corrupt the
+ // repository. that is, we can add the nodes after enabling
+ // operations again
+ assertFalse(ns.getRoot().hasChildNode("foo"));
+ assertFalse(ns.getRoot().hasChildNode("bar"));
+
+ builder = ns.getRoot().builder();
+ builder.child("foo");
+ builder.child("bar");
+ merge(ns, builder);
+ }
+ ns.runBackgroundOperations();
+ }
+
@Test
public void commitRootSameAsModifiedPath() throws Exception{
WriteCountingStore ws = new WriteCountingStore(true);