From 1c8595c86a600d911ce16362d057ab357607350d Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Wed, 23 Oct 2013 22:37:47 +0000 Subject: [PATCH] SOLR-5384: randomlyEnableAutoSoftCommit in ChaosMonkeySafeLeaderTest is buggy. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1535204 13f79535-47bb-0310-9956-ffa450edef68 --- .../solr/cloud/ChaosMonkeySafeLeaderTest.java | 19 +++---------------- .../cloud/AbstractFullDistribZkTestBase.java | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 16 deletions(-) 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 41def4dd78a..67681acd87c 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java @@ -25,9 +25,6 @@ import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.impl.CloudSolrServer; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.core.Diagnostics; -import org.apache.solr.core.SolrCore; -import org.apache.solr.servlet.SolrDispatchFilter; -import org.apache.solr.update.DirectUpdateHandler2; import org.apache.solr.update.SolrCmdDistributor; import org.junit.After; import org.junit.AfterClass; @@ -35,7 +32,7 @@ import org.junit.Before; import org.junit.BeforeClass; @Slow -public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase { +public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase { private static final Integer RUN_LENGTH = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.runlength", "-1")); @@ -89,7 +86,7 @@ public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase { handle.put("QTime", SKIPVAL); handle.put("timestamp", SKIPVAL); - // randomly turn on 5 seconds 'soft' commit + // randomly turn on 1 seconds 'soft' commit randomlyEnableAutoSoftCommit(); del("*:*"); @@ -164,17 +161,7 @@ public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase { private void randomlyEnableAutoSoftCommit() { if (r.nextBoolean()) { - log.info("Turning on auto soft commit"); - for (CloudJettyRunner jetty : shardToJetty.get("shard1")) { - SolrCore core = ((SolrDispatchFilter) jetty.jetty.getDispatchFilter() - .getFilter()).getCores().getCore("collection1"); - try { - ((DirectUpdateHandler2) core.getUpdateHandler()).getCommitTracker() - .setTimeUpperBound(5000); - } finally { - core.close(); - } - } + enableAutoSoftCommit(1000); } else { log.info("Not turning on auto soft commit"); } diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java index 7b1f89ce5bd..f273e2746ba 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java @@ -46,7 +46,11 @@ import org.apache.solr.common.params.CollectionParams.CollectionAction; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.StrUtils; +import org.apache.solr.core.CoreContainer; +import org.apache.solr.core.SolrCore; import org.apache.solr.core.SolrResourceLoader; +import org.apache.solr.servlet.SolrDispatchFilter; +import org.apache.solr.update.DirectUpdateHandler2; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -1056,6 +1060,20 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes } } + protected void enableAutoSoftCommit(int time) { + log.info("Turning on auto soft commit: " + time); + for (List jettyList : shardToJetty.values()) { + for (CloudJettyRunner jetty : jettyList) { + CoreContainer cores = ((SolrDispatchFilter) jetty.jetty + .getDispatchFilter().getFilter()).getCores(); + for (SolrCore core : cores.getCores()) { + ((DirectUpdateHandler2) core.getUpdateHandler()) + .getSoftCommitTracker().setTimeUpperBound(time); + } + } + } + } + private String toStr(SolrDocumentList lst, int maxSz) { if (lst.size() <= maxSz) return lst.toString();