Skip to content

Apache Lucene open-source search software

SOLR-5417: fail if the chaosmonkey runs for over 20 seconds and doesn't kill a jetty

Mark Robert Miller56a116aae857
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 f34ea1f43b7..1161ce38cea 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
@@ -144,7 +144,7 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase
if (RUN_LENGTH != -1) {
runLength = RUN_LENGTH;
} else {
- int[] runTimes = new int[] {5000,6000,10000,15000,15000,30000,30000,45000,90000,120000};
+ int[] runTimes = new int[] {5000,6000,10000,15000,25000,30000,30000,45000,90000,120000};
runLength = runTimes[random().nextInt(runTimes.length - 1)];
}
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 67681acd87c..ff09b192fcf 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
@@ -104,7 +104,7 @@ public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase {
if (RUN_LENGTH != -1) {
runLength = RUN_LENGTH;
} else {
- int[] runTimes = new int[] {5000,6000,10000,15000,15000,30000,30000,45000,90000,120000};
+ int[] runTimes = new int[] {5000,6000,10000,25000,27000,30000,30000,45000,90000,120000};
runLength = runTimes[random().nextInt(runTimes.length - 1)];
}
try {
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 2e2c554beb5..a2bce0e903b 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
@@ -23,6 +23,8 @@ import java.util.Map;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
+import junit.framework.TestCase;
+
import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
@@ -74,7 +76,7 @@ public class ChaosMonkey {
private boolean causeConnectionLoss;
private boolean aggressivelyKillLeaders;
private Map<String,CloudJettyRunner> shardToLeaderJetty;
- private long startTime;
+ private volatile long startTime;
private Thread monkeyThread;
@@ -519,6 +521,10 @@ public class ChaosMonkey {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
+ float runtime = (System.currentTimeMillis() - startTime)/1000.0f;
+ if (runtime > 20 && stops.get() == 0) {
+ TestCase.fail("The Monkey ran for over 20 seconds and no jetties were stopped - this is worth investigating!");
+ }
}
public int getStarts() {