jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1423428 - /jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/concurrent/ConcurrentTest.java
Date Tue, 18 Dec 2012 13:29:35 GMT
Author: mduerig
Date: Tue Dec 18 13:29:35 2012
New Revision: 1423428

URL: http://svn.apache.org/viewvc?rev=1423428&view=rev
Log:
OAK-532: Inconsistent journal with concurrent updates
 test case

Modified:
    jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/concurrent/ConcurrentTest.java

Modified: jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/concurrent/ConcurrentTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/concurrent/ConcurrentTest.java?rev=1423428&r1=1423427&r2=1423428&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/concurrent/ConcurrentTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/concurrent/ConcurrentTest.java
Tue Dec 18 13:29:35 2012
@@ -13,12 +13,16 @@
  */
 package org.apache.jackrabbit.mk.concurrent;
 
+import java.util.concurrent.atomic.AtomicInteger;
+
 import junit.framework.Assert;
 import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.api.MicroKernelException;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.junit.Ignore;
 import org.junit.Test;
 
-import java.util.concurrent.atomic.AtomicInteger;
+import static org.junit.Assert.assertEquals;
 
 /**
  * Test concurrent access to nodes, the journal, and revision.
@@ -52,4 +56,57 @@ public class ConcurrentTest {
         });
     }
 
+    @Test
+    @Ignore("OAK-532")  // FIXME OAK-532
+    public void journalConsistency() throws Exception {
+        while (true) {
+            final MicroKernel mk1 = new MicroKernelImpl();
+            final String rev = mk1.commit("", "+\"/a\":{}", null, null);
+
+            Thread t1 = new Thread("t1") {
+                @Override
+                public void run() {
+                    try {
+                        String r2 = mk1.commit("", "-\"/a\"+\"/c\":{}", rev, null);
+                    }
+                    catch (MicroKernelException ignore) { }
+                }
+            };
+            Thread t2 = new Thread("t2") {
+                @Override
+                public void run() {
+                    try {
+                        String r2 = mk1.commit("", "-\"/a\"+\"/b\":{}", rev, null);
+                    }
+                    catch (MicroKernelException ignore) { }
+                }
+            };
+
+            t1.start();
+            t2.start();
+
+            t1.join();
+            t2.join();
+
+            String journal = mk1.getJournal(rev, null, null);
+            int c = count("-\\\"/a\\", journal);
+            assertEquals(1, c);
+        }
+    }
+
+    private static int count(String subStr, String str) {
+        int lastIndex = 0;
+        int count =0;
+
+        while(lastIndex != -1){
+            lastIndex = str.indexOf(subStr, lastIndex);
+
+            if( lastIndex != -1) {
+                count ++;
+                lastIndex += subStr.length();
+            }
+        }
+        return count;
+    }
+
 }



Mime
View raw message