Author: mreutegg
Date: Wed Feb 24 13:02:20 2016
New Revision: 1732139
URL: http://svn.apache.org/viewvc?rev=1732139&view=rev
Log:
OAK-4052: NonLocalObservationIT fails occasionally
Modified:
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/NonLocalObservationIT.java
Modified:
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/NonLocalObservationIT.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/NonLocalObservationIT.java?rev=1732139&r1=1732138&r2=1732139&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/NonLocalObservationIT.java
(original)
+++
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/NonLocalObservationIT.java
Wed Feb 24 13:02:20 2016
@@ -118,7 +118,17 @@ public class NonLocalObservationIT exten
};
}
-
+
+ @Override
+ protected void prepareTestData(Session s) throws RepositoryException {
+ if (s.itemExists("/test")) {
+ s.getNode("/test").remove();
+ s.save();
+ }
+ s.getRootNode().addNode("test", "oak:Unstructured");
+ s.save();
+ }
+
private void addEventHandler(Session s, final String expectedNodeSuffix)
throws Exception {
ObservationManager o = s.getWorkspace().getObservationManager();
o.addEventListener(new EventListener() {
@@ -135,10 +145,10 @@ public class NonLocalObservationIT exten
String p;
try {
p = e.getPath();
- // System.out.println("expectedNodeSuffix:
+ // log.info("expectedNodeSuffix:
// "+expectedNodeSuffix+", path: " + p);
if (!p.endsWith(expectedNodeSuffix)) {
- System.out.println("EXCEPTION: expectedNodeSuffix:
" + expectedNodeSuffix + ", path: " + p);
+ log.info("EXCEPTION: expectedNodeSuffix: " +
expectedNodeSuffix + ", path: " + p);
throw new Exception("expectedNodeSuffix: " +
expectedNodeSuffix + ", non-local path: " + p);
}
} catch (Exception e1) {
@@ -151,29 +161,22 @@ public class NonLocalObservationIT exten
@Test
public void randomized() throws Exception {
- System.out.println(new Date() + ": initialization");
+ log.info(new Date() + ": initialization");
if (s1 == null) {
return;
}
- if (s1.itemExists("/test")) {
- s1.getNode("/test").remove();
- s1.save();
- }
- s1.getRootNode().addNode("test", "oak:Unstructured");
- s1.save();
addEventHandler(s1, "1");
addEventHandler(s2, "2");
- Thread.sleep(2000);
Random r = new Random(1);
// phase 1 is measuring how long 10000 iterations take
// (is taking 4-6sec on my laptop)
- System.out.println(new Date() + ": measuring 10000 iterations...");
+ log.info(new Date() + ": measuring 10000 iterations...");
long scaleMeasurement = doRandomized(r, 10000);
// phase 2 is 10 times measuring how long subsequent 10000 iterations
take
// (this used to fail due to 'many commit roots')
boolean ignoreFirstSpike = true;
for (int i = 0; i < 14; i++) {
- System.out.println(new Date() + ": test run of 10000
iterations...");
+ log.info(new Date() + ": test run of 10000 iterations...");
long testMeasurement = doRandomized(r, 10000);
Exception e = exception.get();
if (e != null) {
@@ -183,10 +186,10 @@ public class NonLocalObservationIT exten
// the
// scaleMeasurement
long max = (long) (scaleMeasurement * 3);
- System.out.println(new Date() + ": test run took " +
testMeasurement + ", scaleMeasurement=" + scaleMeasurement
+ log.info(new Date() + ": test run took " + testMeasurement + ",
scaleMeasurement=" + scaleMeasurement
+ ", plus 200% margin: " + max);
if (testMeasurement >= max && ignoreFirstSpike) {
- System.out.println(new Date() + ": this iteration would have
failed, but we're now allowing one spike (ignoreFirstSpike)");
+ log.info(new Date() + ": this iteration would have failed, but
we're now allowing one spike (ignoreFirstSpike)");
ignoreFirstSpike = false;
continue;
}
@@ -204,7 +207,7 @@ public class NonLocalObservationIT exten
long now = System.currentTimeMillis();
long diff = now - lastOut;
lastOut = now;
- System.out.println(new Date() + ": diff: " + diff + " for " +
i + "/" + 100000);
+ log.info(new Date() + ": diff: " + diff + " for " + i + "/" +
100000);
}
int sId = r.nextBoolean() ? 1 : 2;
Session s = sId == 1 ? s1 : s2;