From oak-commits-return-2459-apmail-jackrabbit-oak-commits-archive=jackrabbit.apache.org@jackrabbit.apache.org Tue Dec 18 13:30:00 2012 Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0F8F9DEB1 for ; Tue, 18 Dec 2012 13:30:00 +0000 (UTC) Received: (qmail 20058 invoked by uid 500); 18 Dec 2012 13:30:00 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 20032 invoked by uid 500); 18 Dec 2012 13:29:59 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 20018 invoked by uid 99); 18 Dec 2012 13:29:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Dec 2012 13:29:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Dec 2012 13:29:56 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D72962388906; Tue, 18 Dec 2012 13:29:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: oak-commits@jackrabbit.apache.org From: mduerig@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121218132935.D72962388906@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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; + } + }