diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java index 0e2ca87582c..ae3ab2ad87c 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java @@ -150,16 +150,16 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase } chaosMonkey.startTheMonkey(true, 10000); - - long runLength; - if (RUN_LENGTH != -1) { - runLength = RUN_LENGTH; - } else { - int[] runTimes = new int[] {5000,6000,10000,15000,25000,30000,30000,45000,90000,120000}; - runLength = runTimes[random().nextInt(runTimes.length - 1)]; - } - try { + long runLength; + if (RUN_LENGTH != -1) { + runLength = RUN_LENGTH; + } else { + int[] runTimes = new int[] {5000, 6000, 10000, 15000, 25000, 30000, + 30000, 45000, 90000, 120000}; + runLength = runTimes[random().nextInt(runTimes.length - 1)]; + } + Thread.sleep(runLength); } finally { chaosMonkey.stopTheMonkey(); diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java index 7afe466ed56..5975dfa4986 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java @@ -112,14 +112,16 @@ public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase { } chaosMonkey.startTheMonkey(false, 500); - long runLength; - if (RUN_LENGTH != -1) { - runLength = RUN_LENGTH; - } else { - int[] runTimes = new int[] {5000,6000,10000,25000,27000,30000,30000,45000,90000,120000}; - runLength = runTimes[random().nextInt(runTimes.length - 1)]; - } try { + long runLength; + if (RUN_LENGTH != -1) { + runLength = RUN_LENGTH; + } else { + int[] runTimes = new int[] {5000, 6000, 10000, 25000, 27000, 30000, + 30000, 45000, 90000, 120000}; + runLength = runTimes[random().nextInt(runTimes.length - 1)]; + } + Thread.sleep(runLength); } finally { chaosMonkey.stopTheMonkey(); diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java b/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java index 3e6091740da..7eebc1d3d9b 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java @@ -37,6 +37,7 @@ import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.core.CoreContainer; import org.apache.solr.core.SolrCore; import org.apache.solr.servlet.SolrDispatchFilter; +import org.apache.solr.update.DirectUpdateHandler2; import org.apache.zookeeper.KeeperException; import org.eclipse.jetty.servlet.FilterHolder; import org.slf4j.Logger; @@ -459,6 +460,13 @@ public class ChaosMonkey { return; } monkeyLog("starting"); + + + if (LuceneTestCase.random().nextBoolean()) { + monkeyLog("Jetty will not commit on shutdown"); + DirectUpdateHandler2.commitOnClose = false; + } + this.aggressivelyKillLeaders = killLeaders; startTime = System.currentTimeMillis(); // TODO: when kill leaders is on, lets kill a higher percentage of leaders @@ -537,6 +545,9 @@ public class ChaosMonkey { } catch (InterruptedException e) { Thread.currentThread().interrupt(); } + + DirectUpdateHandler2.commitOnClose = true; + float runtime = (System.currentTimeMillis() - startTime)/1000.0f; if (runtime > 20 && stops.get() == 0) { LuceneTestCase.fail("The Monkey ran for over 20 seconds and no jetties were stopped - this is worth investigating!");