From dab5e2aa8942200ba58ec5e6ecc5f9c2c01d0604 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Sun, 3 Nov 2013 15:54:18 +0000 Subject: [PATCH] tests: allow the monkey to be disabled and bring back some randomization to exp and conn loss git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1538390 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/solr/cloud/ChaosMonkey.java | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) 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 9d33ea36006..ec8d61b8c06 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 @@ -56,8 +56,9 @@ public class ChaosMonkey { private static final int EXPIRE_PERCENT = 10; // 0 - 10 = 0 - 100% private Map> shardToJetty; - private static final boolean CONN_LOSS = Boolean.valueOf(System.getProperty("solr.tests.cloud.cm.connloss", "true")); - private static final boolean EXP = Boolean.valueOf(System.getProperty("solr.tests.cloud.cm.exp", "true")); + private static final Boolean MONKEY_ENABLED = Boolean.valueOf(System.getProperty("solr.tests.cloud.cm.enabled", "true")); + private static final Boolean CONN_LOSS = Boolean.valueOf(System.getProperty("solr.tests.cloud.cm.connloss", null)); + private static final Boolean EXP = Boolean.valueOf(System.getProperty("solr.tests.cloud.cm.exp", null)); private ZkTestServer zkServer; private ZkStateReader zkStateReader; @@ -85,10 +86,25 @@ public class ChaosMonkey { this.zkServer = zkServer; this.zkStateReader = zkStateReader; this.collection = collection; - Random random = LuceneTestCase.random(); - expireSessions = EXP; //= random.nextBoolean(); - causeConnectionLoss = CONN_LOSS;//= random.nextBoolean(); + if (!MONKEY_ENABLED) { + monkeyLog("The Monkey is Disabled and will not run"); + return; + } + + Random random = LuceneTestCase.random(); + if (EXP != null) { + expireSessions = EXP; + } else { + expireSessions = random.nextBoolean(); + } + if (CONN_LOSS != null) { + causeConnectionLoss = CONN_LOSS; + } else { + causeConnectionLoss = random.nextBoolean(); + } + + monkeyLog("init - expire sessions:" + expireSessions + " cause connection loss:" + causeConnectionLoss); } @@ -420,6 +436,10 @@ public class ChaosMonkey { // synchronously starts and stops shards randomly, unless there is only one // active shard up for a slice or if there is one active and others recovering public void startTheMonkey(boolean killLeaders, final int roundPauseUpperLimit) { + if (!MONKEY_ENABLED) { + monkeyLog("The Monkey is disabled and will not start"); + return; + } monkeyLog("starting"); this.aggressivelyKillLeaders = killLeaders; startTime = System.currentTimeMillis();