Author: adulceanu
Date: Fri Jan 6 10:59:59 2017
New Revision: 1777588
URL: http://svn.apache.org/viewvc?rev=1777588&view=rev
Log:
OAK-4954 - SetPropertyTest benchmark fails on Segment Tar
Test node is kept on a per fixture, per thread basis
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetPropertyTest.java
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java?rev=1777588&r1=1777587&r2=1777588&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
(original)
+++
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
Fri Jan 6 10:59:59 2017
@@ -89,6 +89,8 @@ public abstract class AbstractTest<T> ex
private PrintStream out;
+ private RepositoryFixture currentFixture;
+
/**
* <p>
* used to signal the {@link #runTest(int)} if stop running future test
planned or not. If set
@@ -191,6 +193,7 @@ public abstract class AbstractTest<T> ex
toString(), statsNamesJoined(true));
}
for (RepositoryFixture fixture : fixtures) {
+ currentFixture = fixture;
try {
Repository[] cluster = createRepository(fixture);
try {
@@ -528,6 +531,10 @@ public abstract class AbstractTest<T> ex
protected Credentials getCredentials() {
return credentials;
}
+
+ protected RepositoryFixture getCurrentFixture() {
+ return currentFixture;
+ }
/**
* Returns a new reader session that will be automatically closed once
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetPropertyTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetPropertyTest.java?rev=1777588&r1=1777587&r2=1777588&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetPropertyTest.java
(original)
+++
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/SetPropertyTest.java
Fri Jan 6 10:59:59 2017
@@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.benchmark;
+import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -24,6 +25,8 @@ import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.nodetype.NodeTypeManager;
+import org.apache.jackrabbit.oak.fixture.RepositoryFixture;
+
import com.google.common.collect.Maps;
/**
@@ -32,7 +35,12 @@ import com.google.common.collect.Maps;
*/
public class SetPropertyTest extends AbstractTest {
- private Map<Thread, Node> nodes = Maps.newIdentityHashMap();
+ /**
+ * Map holding node to be tested (below testNodeName) per current running
fixture, per thread.
+ * A simpler structure holding nodes on a per thread basis is not enough,
as runs with concurrencyLevel==1
+ * and warm-up in {@link AbstractTest} are done from the same thread
(re-using it between fixtures).
+ */
+ private Map<String, Map<Thread,Node>> map = new HashMap<>();
String testNodeName = "test" + TEST_ID;
@@ -46,6 +54,8 @@ public class SetPropertyTest extends Abs
@Override
public void beforeTest() throws RepositoryException {
+ Map<Thread, Node> nodes = getOrCreateNodesMap();
+
Thread t = Thread.currentThread();
Node node = nodes.get(t);
if (node == null) {
@@ -54,11 +64,14 @@ public class SetPropertyTest extends Abs
node.setProperty("count", -1);
s.save();
nodes.put(t, node);
+ map.put(getCurrentFixture().toString(), nodes);
}
}
@Override
public void runTest() throws Exception {
+ Map<Thread, Node> nodes = getOrCreateNodesMap();
+
Node node = nodes.get(Thread.currentThread());
Session session = node.getSession();
for (int i = 0; i < 1000; i++) {
@@ -84,5 +97,19 @@ public class SetPropertyTest extends Abs
return "nt:unstructured";
}
}
+
+ private Map<Thread, Node> getOrCreateNodesMap() {
+ RepositoryFixture currentFixture = getCurrentFixture();
+ if (currentFixture == null) {
+ throw new RuntimeException("Current running fixture was not
correctly set!");
+ }
+ String currentFixtureName = currentFixture.toString();
+
+ Map<Thread, Node> nodes = map.get(currentFixtureName);
+ if (nodes == null) {
+ nodes = Maps.newIdentityHashMap();
+ }
+ return nodes;
+ }
}