You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2012/07/24 23:49:57 UTC
svn commit: r1365313 - in
/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud:
ChaosMonkeyNothingIsSafeTest.java FullSolrCloudTest.java
Author: markrmiller
Date: Tue Jul 24 21:49:56 2012
New Revision: 1365313
URL: http://svn.apache.org/viewvc?rev=1365313&view=rev
Log:
add a StopableSearchThread
Modified:
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java?rev=1365313&r1=1365312&r2=1365313&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java Tue Jul 24 21:49:56 2012
@@ -87,7 +87,7 @@ public class ChaosMonkeyNothingIsSafeTes
// as it's not supported for recovery
// del("*:*");
- List<StopableIndexingThread> threads = new ArrayList<StopableIndexingThread>();
+ List<StopableThread> threads = new ArrayList<StopableThread>();
int threadCount = 1;
int i = 0;
for (i = 0; i < threadCount; i++) {
@@ -97,6 +97,14 @@ public class ChaosMonkeyNothingIsSafeTes
indexThread.start();
}
+ threadCount = 1;
+ i = 0;
+ for (i = 0; i < threadCount; i++) {
+ StopableSearchThread searchThread = new StopableSearchThread();
+ threads.add(searchThread);
+ searchThread.start();
+ }
+
FullThrottleStopableIndexingThread ftIndexThread = new FullThrottleStopableIndexingThread(
clients, i * 50000, true);
threads.add(ftIndexThread);
@@ -110,12 +118,12 @@ public class ChaosMonkeyNothingIsSafeTes
chaosMonkey.stopTheMonkey();
}
- for (StopableIndexingThread indexThread : threads) {
+ for (StopableThread indexThread : threads) {
indexThread.safeStop();
}
// wait for stop...
- for (StopableIndexingThread indexThread : threads) {
+ for (StopableThread indexThread : threads) {
indexThread.join();
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java?rev=1365313&r1=1365312&r2=1365313&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java Tue Jul 24 21:49:56 2012
@@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@@ -1283,7 +1284,14 @@ public class FullSolrCloudTest extends A
return rsp;
}
- class StopableIndexingThread extends Thread {
+ abstract class StopableThread extends Thread {
+ public StopableThread(String name) {
+ super(name);
+ }
+ public abstract void safeStop();
+ }
+
+ class StopableIndexingThread extends StopableThread {
private volatile boolean stop = false;
protected final int startI;
protected final List<Integer> deletes = new ArrayList<Integer>();
@@ -1357,6 +1365,55 @@ public class FullSolrCloudTest extends A
};
+ class StopableSearchThread extends StopableThread {
+ private volatile boolean stop = false;
+ protected final AtomicInteger fails = new AtomicInteger();
+ private String[] QUERIES = new String[] {"to come","their country","aid","co*"};
+
+ public StopableSearchThread() {
+ super("StopableSearchThread");
+ setDaemon(true);
+ }
+
+ @Override
+ public void run() {
+ Random random = random();
+ int numSearches = 0;
+
+ while (true && !stop) {
+ numSearches++;
+ try {
+ //to come to the aid of their country.
+ cloudClient.query(new SolrQuery(QUERIES[random.nextInt(QUERIES.length)]));
+ } catch (Exception e) {
+ System.err.println("QUERY REQUEST FAILED:");
+ e.printStackTrace();
+ if (e instanceof SolrServerException) {
+ System.err.println("ROOT CAUSE:");
+ ((SolrServerException) e).getRootCause().printStackTrace();
+ }
+ fails.incrementAndGet();
+ }
+ try {
+ Thread.sleep(random.nextInt(4000) + 300);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ System.err.println("num searches done:" + numSearches + " with " + fails + " fails");
+ }
+
+ public void safeStop() {
+ stop = true;
+ }
+
+ public int getFails() {
+ return fails.get();
+ }
+
+ };
+
protected void waitForThingsToLevelOut(int waitForRecTimeSeconds) throws Exception {
log.info("Wait for recoveries to finish - wait " + waitForRecTimeSeconds + " for each attempt");
int cnt = 0;