Index: oak-core/pom.xml =================================================================== --- oak-core/pom.xml (revision 1750606) +++ oak-core/pom.xml (working copy) @@ -304,6 +304,12 @@ test + org.jboss.byteman + byteman-bmunit + 3.0.6 + test + + org.slf4j jul-to-slf4j test Index: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BMUtils.java =================================================================== --- oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BMUtils.java (nonexistent) +++ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BMUtils.java (working copy) @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.plugins.document; + +import java.util.Iterator; +import java.util.List; + +import com.google.common.collect.Lists; + +import org.jboss.byteman.agent.submit.ScriptText; +import org.jboss.byteman.agent.submit.Submit; +import org.jboss.byteman.contrib.bmunit.BMUnit; +import org.jboss.byteman.objectweb.asm.ClassReader; +import org.jboss.byteman.objectweb.asm.tree.AbstractInsnNode; +import org.jboss.byteman.objectweb.asm.tree.ClassNode; +import org.jboss.byteman.objectweb.asm.tree.LineNumberNode; +import org.jboss.byteman.objectweb.asm.tree.MethodNode; + +/** + * BMUtils... + */ +public class BMUtils { + + public static void randomSleepsFor(Class clazz, double probability) + throws Exception { + List scripts = Lists.newArrayList(); + ClassReader reader = new ClassReader(clazz.getName()); + ClassNode cn = new ClassNode(); + reader.accept(cn, 0); + for (Object element : cn.methods) { + MethodNode mn = (MethodNode) element; + Iterator it = mn.instructions.iterator(); + while (it.hasNext()) { + AbstractInsnNode instrNode = (AbstractInsnNode) it.next(); + if (instrNode instanceof LineNumberNode) { + scripts.add(generateBMScript(clazz, probability, mn.name, (LineNumberNode) instrNode)); + } + } + } + new Submit(BMUnit.getHost(), BMUnit.getPort()).addScripts(scripts); + } + + public static void deleteAllRules() throws Exception { + new Submit(BMUnit.getHost(), BMUnit.getPort()).deleteAllRules(); + } + + private static ScriptText generateBMScript(Class clazz, + double probability, + String methodName, + LineNumberNode lnn) { + String name = clazz.getName() + ":" + lnn.line; + return new ScriptText(name, + "RULE " + name + "\n" + + "CLASS " + clazz.getName() + "\n" + + "METHOD " + methodName + "\n" + + "COMPILE \n" + + "AT LINE " + lnn.line + "\n" + + "IF true\n" + + "DO " + BMUtils.class.getName() + ".randomSleep(" + probability + ")\n" + + "ENDRULE"); + } + + public static void randomSleep(double p) { + if (Math.random() < p) { + try { + Thread.sleep(1); + } catch (InterruptedException e) { + // ignore + } + } + } +} Property changes on: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BMUtils.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: oak-jcr/pom.xml =================================================================== --- oak-jcr/pom.xml (revision 1750606) +++ oak-jcr/pom.xml (working copy) @@ -299,6 +299,12 @@ test + org.jboss.byteman + byteman-bmunit + 3.0.6 + test + + org.mongodb mongo-java-driver test Index: oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddReferencesMongoTest.java =================================================================== --- oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddReferencesMongoTest.java (nonexistent) +++ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddReferencesMongoTest.java (working copy) @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.jcr; + +import org.apache.jackrabbit.oak.NodeStoreFixtures; +import org.apache.jackrabbit.oak.plugins.document.BMUtils; +import org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore; +import org.jboss.byteman.contrib.bmunit.BMUnitRunner; +import org.junit.After; +import org.junit.Before; +import org.junit.runner.RunWith; + +@RunWith(BMUnitRunner.class) +public class ConcurrentAddReferencesMongoTest extends ConcurrentAddReferenceTest { + + public ConcurrentAddReferencesMongoTest() { + super(NodeStoreFixtures.DOCUMENT_NS); + } + + @Before + public void installRules() throws Exception { + BMUtils.randomSleepsFor(MongoDocumentStore.class, 0.000001); + } + + @After + public void deleteRules() throws Exception { + BMUtils.deleteAllRules(); + } +} Property changes on: oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddReferencesMongoTest.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddReferencesRDBTest.java =================================================================== --- oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddReferencesRDBTest.java (nonexistent) +++ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddReferencesRDBTest.java (working copy) @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.jcr; + +import org.apache.jackrabbit.oak.NodeStoreFixtures; +import org.apache.jackrabbit.oak.plugins.document.BMUtils; +import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore; +import org.jboss.byteman.contrib.bmunit.BMUnitRunner; +import org.junit.After; +import org.junit.Before; +import org.junit.runner.RunWith; + +@RunWith(BMUnitRunner.class) +public class ConcurrentAddReferencesRDBTest extends ConcurrentAddReferenceTest { + + public ConcurrentAddReferencesRDBTest() { + super(NodeStoreFixtures.DOCUMENT_RDB); + } + + @Before + public void installRules() throws Exception { + BMUtils.randomSleepsFor(RDBDocumentStore.class, 0.000001); + } + + @After + public void deleteRules() throws Exception { + BMUtils.deleteAllRules(); + } +} Property changes on: oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddReferencesRDBTest.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property