You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by tf...@apache.org on 2017/05/03 20:26:28 UTC
[4/4] lucene-solr:jira/solr-10233: Added explicit commits to
ChaosMonkey tests
Added explicit commits to ChaosMonkey tests
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/48426336
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/48426336
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/48426336
Branch: refs/heads/jira/solr-10233
Commit: 484263360310f2aed2e24df27729e2b4ecf13811
Parents: 688f12d
Author: Tomas Fernandez Lobbe <tf...@apache.org>
Authored: Wed May 3 13:26:14 2017 -0700
Committer: Tomas Fernandez Lobbe <tf...@apache.org>
Committed: Wed May 3 13:26:14 2017 -0700
----------------------------------------------------------------------
...keyNothingIsSafeWithPassiveReplicasTest.java | 10 ++-
...MonkeySafeLeaderWithPassiveReplicasTest.java | 20 ++++--
.../solr/cloud/StoppableCommitThread.java | 69 ++++++++++++++++++++
.../solr/cloud/StoppableIndexingThread.java | 2 +-
.../solr/cloud/StoppableSearchThread.java | 2 +-
5 files changed, 94 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/48426336/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPassiveReplicasTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPassiveReplicasTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPassiveReplicasTest.java
index db45392..71c2924 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPassiveReplicasTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPassiveReplicasTest.java
@@ -36,6 +36,7 @@ import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.core.SolrCore;
+import org.apache.solr.util.TestInjection;
import org.apache.solr.util.TimeOut;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -43,9 +44,11 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
+
@Slow
@SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776")
-//@ThreadLeakLingering(linger = 60000)
+@ThreadLeakLingering(linger = 60000)
@SuppressObjectReleaseTracker(bugUrl="Testing purposes")
public class ChaosMonkeyNothingIsSafeWithPassiveReplicasTest extends AbstractFullDistribZkTestBase {
private static final int FAIL_TOLERANCE = 100;
@@ -73,6 +76,7 @@ public class ChaosMonkeyNothingIsSafeWithPassiveReplicasTest extends AbstractFul
@AfterClass
public static void afterSuperClass() {
System.clearProperty("solr.autoCommit.maxTime");
+ TestInjection.waitForReplicasInSync = null;
clearErrorHook();
}
@@ -167,6 +171,10 @@ public class ChaosMonkeyNothingIsSafeWithPassiveReplicasTest extends AbstractFul
searchThread.start();
}
+ StoppableCommitThread commitThread = new StoppableCommitThread(cloudClient, 1000, false);
+ threads.add(commitThread);
+ commitThread.start();
+
// TODO: we only do this sometimes so that we can sometimes compare against control,
// it's currently hard to know what requests failed when using ConcurrentSolrUpdateServer
boolean runFullThrottle = random().nextBoolean();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/48426336/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderWithPassiveReplicasTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderWithPassiveReplicasTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderWithPassiveReplicasTest.java
index 582da64..556a61b 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderWithPassiveReplicasTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderWithPassiveReplicasTest.java
@@ -31,6 +31,7 @@ import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.DocCollection;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.util.TestInjection;
import org.apache.solr.util.TimeOut;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -64,6 +65,7 @@ public class ChaosMonkeySafeLeaderWithPassiveReplicasTest extends AbstractFullDi
public static void beforeSuperClass() {
schemaString = "schema15.xml"; // we need a string id
System.setProperty("solr.autoCommit.maxTime", "15000");
+ TestInjection.waitForReplicasInSync = null;
setErrorHook();
}
@@ -122,7 +124,7 @@ public class ChaosMonkeySafeLeaderWithPassiveReplicasTest extends AbstractFullDi
tryDelete();
- List<StoppableIndexingThread> threads = new ArrayList<>();
+ List<StoppableThread> threads = new ArrayList<>();
int threadCount = 2;
int batchSize = 1;
if (random().nextBoolean()) {
@@ -143,6 +145,10 @@ public class ChaosMonkeySafeLeaderWithPassiveReplicasTest extends AbstractFullDi
indexThread.start();
}
+ StoppableCommitThread commitThread = new StoppableCommitThread(cloudClient, 1000, false);
+ threads.add(commitThread);
+ commitThread.start();
+
chaosMonkey.startTheMonkey(false, 500);
try {
long runLength;
@@ -164,17 +170,19 @@ public class ChaosMonkeySafeLeaderWithPassiveReplicasTest extends AbstractFullDi
chaosMonkey.stopTheMonkey();
}
- for (StoppableIndexingThread indexThread : threads) {
- indexThread.safeStop();
+ for (StoppableThread thread : threads) {
+ thread.safeStop();
}
// wait for stop...
- for (StoppableIndexingThread thread : threads) {
+ for (StoppableThread thread : threads) {
thread.join();
}
- for (StoppableIndexingThread indexThread : threads) {
- assertEquals(0, indexThread.getFailCount());
+ for (StoppableThread thread : threads) {
+ if (thread instanceof StoppableIndexingThread) {
+ assertEquals(0, ((StoppableIndexingThread)thread).getFailCount());
+ }
}
// try and wait for any replications and what not to finish...
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/48426336/solr/test-framework/src/java/org/apache/solr/cloud/StoppableCommitThread.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/StoppableCommitThread.java b/solr/test-framework/src/java/org/apache/solr/cloud/StoppableCommitThread.java
new file mode 100644
index 0000000..f87ebb5
--- /dev/null
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/StoppableCommitThread.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.cloud;
+
+import java.lang.invoke.MethodHandles;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.cloud.AbstractFullDistribZkTestBase.StoppableThread;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StoppableCommitThread extends StoppableThread {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private final SolrClient cloudClient;
+ private final long timeBetweenCommitsMs;
+ private final boolean softCommits;
+ private volatile boolean stop = false;
+ private final AtomicInteger numCommits = new AtomicInteger(0);
+ private final AtomicInteger numFails = new AtomicInteger(0);
+
+ public StoppableCommitThread(SolrClient cloudClient, long timeBetweenCommitsMs, boolean softCommits) {
+ super("StoppableCommitThread");
+ this.cloudClient = cloudClient;
+ this.timeBetweenCommitsMs = timeBetweenCommitsMs;
+ this.softCommits = softCommits;
+ }
+
+ @Override
+ public void run() {
+ log.debug("StoppableCommitThread started");
+ while (!stop) {
+ try {
+ cloudClient.commit(false, false, softCommits);
+ numCommits.incrementAndGet();
+ } catch (Exception e) {
+ numFails.incrementAndGet();
+ }
+ try {
+ Thread.sleep(timeBetweenCommitsMs);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ break;
+ }
+ }
+ log.debug("StoppableCommitThread finished. Committed {} times. Failed {} times.", numCommits.get(), numFails.get());
+ }
+
+ @Override
+ public void safeStop() {
+ this.stop = true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/48426336/solr/test-framework/src/java/org/apache/solr/cloud/StoppableIndexingThread.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/StoppableIndexingThread.java b/solr/test-framework/src/java/org/apache/solr/cloud/StoppableIndexingThread.java
index 7dd88c1..0385d73 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/StoppableIndexingThread.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/StoppableIndexingThread.java
@@ -132,7 +132,7 @@ public class StoppableIndexingThread extends AbstractFullDistribZkTestBase.Stopp
if (docs.size() > 0 && pauseBetweenUpdates) {
try {
- Thread.currentThread().sleep(AbstractFullDistribZkTestBase.random().nextInt(500) + 50);
+ Thread.sleep(AbstractFullDistribZkTestBase.random().nextInt(500) + 50);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/48426336/solr/test-framework/src/java/org/apache/solr/cloud/StoppableSearchThread.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/StoppableSearchThread.java b/solr/test-framework/src/java/org/apache/solr/cloud/StoppableSearchThread.java
index fa916c6..c579f22 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/StoppableSearchThread.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/StoppableSearchThread.java
@@ -47,7 +47,7 @@ class StoppableSearchThread extends AbstractFullDistribZkTestBase.StoppableThrea
Random random = LuceneTestCase.random();
int numSearches = 0;
- while (true && !stop) {
+ while (!stop) {
numSearches++;
try {
//to come to the aid of their country.