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 2013/12/01 16:52:08 UTC
svn commit: r1546821 - in /lucene/dev/trunk/solr:
core/src/test/org/apache/solr/cloud/
test-framework/src/java/org/apache/solr/cloud/
Author: markrmiller
Date: Sun Dec 1 15:52:08 2013
New Revision: 1546821
URL: http://svn.apache.org/r1546821
Log:
SOLR-5509: Better string ids for these tests
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/ChaosMonkeySafeLeaderTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java
lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.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=1546821&r1=1546820&r2=1546821&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 Sun Dec 1 15:52:08 2013
@@ -51,6 +51,7 @@ public class ChaosMonkeyNothingIsSafeTes
@BeforeClass
public static void beforeSuperClass() {
+ schemaString = "schema15.xml"; // we need a string id
SolrCmdDistributor.testing_errorHook = new Diagnostics.Callable() {
@Override
public void call(Object... data) {
@@ -68,6 +69,17 @@ public class ChaosMonkeyNothingIsSafeTes
SolrCmdDistributor.testing_errorHook = null;
}
+ public static String[] fieldNames = new String[]{"f_i", "f_f", "f_d", "f_l", "f_dt"};
+ public static RandVal[] randVals = new RandVal[]{rint, rfloat, rdouble, rlong, rdate};
+
+ protected String[] getFieldNames() {
+ return fieldNames;
+ }
+
+ protected RandVal[] getRandValues() {
+ return randVals;
+ }
+
@Before
@Override
public void setUp() throws Exception {
@@ -115,9 +127,7 @@ public class ChaosMonkeyNothingIsSafeTes
int threadCount = 1;
int i = 0;
for (i = 0; i < threadCount; i++) {
- // ensure the id start is high enough that threads will not overlap doc ids
- StopableIndexingThread indexThread = new StopableIndexingThread(
- (i+1) * 25000000, true);
+ StopableIndexingThread indexThread = new StopableIndexingThread(Integer.toString(i), true);
threads.add(indexThread);
indexThread.start();
}
@@ -134,7 +144,7 @@ public class ChaosMonkeyNothingIsSafeTes
boolean runFullThrottle = random().nextBoolean();
if (runFullThrottle) {
FullThrottleStopableIndexingThread ftIndexThread = new FullThrottleStopableIndexingThread(
- clients, (i+1) * 50000, true);
+ clients, "ft1", true);
threads.add(ftIndexThread);
ftIndexThread.start();
}
@@ -248,8 +258,8 @@ public class ChaosMonkeyNothingIsSafeTes
private List<SolrServer> clients;
public FullThrottleStopableIndexingThread(List<SolrServer> clients,
- int startI, boolean doDeletes) {
- super(startI, doDeletes);
+ String id, boolean doDeletes) {
+ super(id, doDeletes);
setName("FullThrottleStopableIndexingThread");
setDaemon(true);
this.clients = clients;
@@ -267,18 +277,19 @@ public class ChaosMonkeyNothingIsSafeTes
@Override
public void run() {
- int i = startI;
+ int i = 0;
int numDeletes = 0;
int numAdds = 0;
while (true && !stop) {
+ String id = this.id + "-" + i;
++i;
if (doDeletes && random().nextBoolean() && deletes.size() > 0) {
- Integer delete = deletes.remove(0);
+ String delete = deletes.remove(0);
try {
numDeletes++;
- suss.deleteById(Integer.toString(delete));
+ suss.deleteById(delete);
} catch (Exception e) {
changeUrlOnError(e);
//System.err.println("REQUEST FAILED:");
@@ -292,12 +303,10 @@ public class ChaosMonkeyNothingIsSafeTes
if (numAdds > 4000)
continue;
SolrInputDocument doc = getDoc(
+ "id",
id,
- i,
i1,
50,
- tlong,
- 50,
t1,
"Saxon heptarchies that used to rip around so in old times and raise Cain. My, you ought to seen old Henry the Eight when he was in bloom. He WAS a blossom. He used to marry a new wife every day, and chop off her head next morning. And he would do it just as indifferent as if ");
suss.add(doc);
@@ -309,7 +318,7 @@ public class ChaosMonkeyNothingIsSafeTes
}
if (doDeletes && random().nextBoolean()) {
- deletes.add(i);
+ deletes.add(id);
}
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java?rev=1546821&r1=1546820&r2=1546821&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java Sun Dec 1 15:52:08 2013
@@ -38,6 +38,7 @@ public class ChaosMonkeySafeLeaderTest e
@BeforeClass
public static void beforeSuperClass() {
+ schemaString = "schema15.xml"; // we need a string id
SolrCmdDistributor.testing_errorHook = new Diagnostics.Callable() {
@Override
public void call(Object... data) {
@@ -55,6 +56,17 @@ public class ChaosMonkeySafeLeaderTest e
SolrCmdDistributor.testing_errorHook = null;
}
+ public static String[] fieldNames = new String[]{"f_i", "f_f", "f_d", "f_l", "f_dt"};
+ public static RandVal[] randVals = new RandVal[]{rint, rfloat, rdouble, rlong, rdate};
+
+ protected String[] getFieldNames() {
+ return fieldNames;
+ }
+
+ protected RandVal[] getRandValues() {
+ return randVals;
+ }
+
@Before
@Override
public void setUp() throws Exception {
@@ -94,7 +106,7 @@ public class ChaosMonkeySafeLeaderTest e
List<StopableIndexingThread> threads = new ArrayList<StopableIndexingThread>();
int threadCount = 2;
for (int i = 0; i < threadCount; i++) {
- StopableIndexingThread indexThread = new StopableIndexingThread(10000 + i*50000, true);
+ StopableIndexingThread indexThread = new StopableIndexingThread(Integer.toString(i), true);
threads.add(indexThread);
indexThread.start();
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java?rev=1546821&r1=1546820&r2=1546821&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java Sun Dec 1 15:52:08 2013
@@ -40,8 +40,20 @@ public class RecoveryZkTest extends Abst
super();
sliceCount = 1;
shardCount = 2;
+ schemaString = "schema15.xml"; // we need a string id
}
+ public static String[] fieldNames = new String[]{"f_i", "f_f", "f_d", "f_l", "f_dt"};
+ public static RandVal[] randVals = new RandVal[]{rint, rfloat, rdouble, rlong, rdate};
+
+ protected String[] getFieldNames() {
+ return fieldNames;
+ }
+
+ protected RandVal[] getRandValues() {
+ return randVals;
+ }
+
@Override
public void doTest() throws Exception {
handle.clear();
@@ -54,10 +66,10 @@ public class RecoveryZkTest extends Abst
int maxDoc = maxDocList[random().nextInt(maxDocList.length - 1)];
- indexThread = new StopableIndexingThread(0, true, maxDoc);
+ indexThread = new StopableIndexingThread("1", true, maxDoc);
indexThread.start();
- indexThread2 = new StopableIndexingThread(10000, true, maxDoc);
+ indexThread2 = new StopableIndexingThread("2", true, maxDoc);
indexThread2.start();
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1546821&r1=1546820&r2=1546821&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Sun Dec 1 15:52:08 2013
@@ -17,10 +17,29 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
+import static org.apache.solr.cloud.OverseerCollectionProcessor.CREATE_NODE_SET;
+import static org.apache.solr.cloud.OverseerCollectionProcessor.MAX_SHARDS_PER_NODE;
+import static org.apache.solr.cloud.OverseerCollectionProcessor.NUM_SLICES;
+import static org.apache.solr.cloud.OverseerCollectionProcessor.REPLICATION_FACTOR;
+import static org.apache.solr.cloud.OverseerCollectionProcessor.SHARDS_PROP;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+
import org.apache.commons.io.FilenameUtils;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.lucene.util.LuceneTestCase.Slow;
-import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServer;
@@ -58,26 +77,6 @@ import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Random;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import static org.apache.solr.cloud.OverseerCollectionProcessor.CREATE_NODE_SET;
-import static org.apache.solr.cloud.OverseerCollectionProcessor.MAX_SHARDS_PER_NODE;
-import static org.apache.solr.cloud.OverseerCollectionProcessor.NUM_SLICES;
-import static org.apache.solr.cloud.OverseerCollectionProcessor.REPLICATION_FACTOR;
-import static org.apache.solr.cloud.OverseerCollectionProcessor.SHARDS_PROP;
-
/**
* TODO: we should still test this works as a custom update chain as well as
* what we test now - the default update chain
@@ -848,23 +847,23 @@ public abstract class AbstractFullDistri
}
protected void indexAbunchOfDocs() throws Exception {
- indexr(id, 2, i1, 50, tlong, 50, t1, "to come to the aid of their country.");
- indexr(id, 3, i1, 2, tlong, 2, t1, "how now brown cow");
- indexr(id, 4, i1, -100, tlong, 101, t1,
+ indexr(id, 2, i1, 50, t1, "to come to the aid of their country.");
+ indexr(id, 3, i1, 2, t1, "how now brown cow");
+ indexr(id, 4, i1, -100, t1,
"the quick fox jumped over the lazy dog");
- indexr(id, 5, i1, 500, tlong, 500, t1,
+ indexr(id, 5, i1, 500, t1,
"the quick fox jumped way over the lazy dog");
- indexr(id, 6, i1, -600, tlong, 600, t1, "humpty dumpy sat on a wall");
- indexr(id, 7, i1, 123, tlong, 123, t1, "humpty dumpy had a great fall");
- indexr(id, 8, i1, 876, tlong, 876, t1,
+ indexr(id, 6, i1, -600, t1, "humpty dumpy sat on a wall");
+ indexr(id, 7, i1, 123, t1, "humpty dumpy had a great fall");
+ indexr(id, 8, i1, 876, t1,
"all the kings horses and all the kings men");
- indexr(id, 9, i1, 7, tlong, 7, t1, "couldn't put humpty together again");
- indexr(id, 10, i1, 4321, tlong, 4321, t1, "this too shall pass");
- indexr(id, 11, i1, -987, tlong, 987, t1,
+ indexr(id, 9, i1, 7, t1, "couldn't put humpty together again");
+ indexr(id, 10, i1, 4321, t1, "this too shall pass");
+ indexr(id, 11, i1, -987, t1,
"An eye for eye only ends up making the whole world blind.");
- indexr(id, 12, i1, 379, tlong, 379, t1,
+ indexr(id, 12, i1, 379, t1,
"Great works are performed, not by strength, but by perseverance.");
- indexr(id, 13, i1, 232, tlong, 232, t1, "no eggs on wall, lesson learned",
+ indexr(id, 13, i1, 232, t1, "no eggs on wall, lesson learned",
oddField, "odd man out");
indexr(id, 14, "SubjectTerms_mfacet", new String[] {"mathematical models",
@@ -1336,19 +1335,19 @@ public abstract class AbstractFullDistri
class StopableIndexingThread extends StopableThread {
private volatile boolean stop = false;
- protected final int startI;
- protected final List<Integer> deletes = new ArrayList<Integer>();
+ protected final String id;
+ protected final List<String> deletes = new ArrayList<String>();
protected final AtomicInteger fails = new AtomicInteger();
protected boolean doDeletes;
private int numCycles;
- public StopableIndexingThread(int startI, boolean doDeletes) {
- this(startI, doDeletes, -1);
+ public StopableIndexingThread(String id, boolean doDeletes) {
+ this(id, doDeletes, -1);
}
- public StopableIndexingThread(int startI, boolean doDeletes, int numCycles) {
+ public StopableIndexingThread(String id, boolean doDeletes, int numCycles) {
super("StopableIndexingThread");
- this.startI = startI;
+ this.id = id;
this.doDeletes = doDeletes;
this.numCycles = numCycles;
setDaemon(true);
@@ -1356,7 +1355,7 @@ public abstract class AbstractFullDistri
@Override
public void run() {
- int i = startI;
+ int i = 0;
int numDone = 0;
int numDeletes = 0;
int numAdds = 0;
@@ -1368,19 +1367,20 @@ public abstract class AbstractFullDistri
}
}
++numDone;
+ String id = this.id + "-" + i;
++i;
boolean addFailed = false;
if (doDeletes && random().nextBoolean() && deletes.size() > 0) {
- Integer delete = deletes.remove(0);
+ String delete = deletes.remove(0);
try {
numDeletes++;
UpdateRequest req = new UpdateRequest();
- req.deleteById(Integer.toString(delete));
+ req.deleteById(delete);
req.setParam("CONTROL", "TRUE");
req.process(controlClient);
- cloudClient.deleteById(Integer.toString(delete));
+ cloudClient.deleteById(delete);
} catch (Exception e) {
System.err.println("REQUEST FAILED:");
e.printStackTrace();
@@ -1394,7 +1394,7 @@ public abstract class AbstractFullDistri
try {
numAdds++;
- indexr(id, i, i1, 50, tlong, 50, t1,
+ indexr("id", id, i1, 50, t1,
"to come to the aid of their country.");
} catch (Exception e) {
addFailed = true;
@@ -1408,7 +1408,7 @@ public abstract class AbstractFullDistri
}
if (!addFailed && doDeletes && random().nextBoolean()) {
- deletes.add(i);
+ deletes.add(id);
}
try {