Apache Lucene open-source search software
SOLR-5509: Better string ids for these tests
Mark Robert Millerbbd4548428bf
diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.javaindex a99848742a3..0e2ca87582c 100644--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java@@ -51,6 +51,7 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase@BeforeClasspublic static void beforeSuperClass() {+ schemaString = "schema15.xml"; // we need a string idSolrCmdDistributor.testing_errorHook = new Diagnostics.Callable() {@Overridepublic void call(Object... data) {@@ -68,6 +69,17 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBaseSolrCmdDistributor.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@Overridepublic void setUp() throws Exception {@@ -115,9 +127,7 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBaseint 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 ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBaseboolean 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 ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBaseprivate 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 ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase@Overridepublic 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 ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBaseif (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 ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase}if (doDeletes && random().nextBoolean()) {- deletes.add(i);+ deletes.add(id);}}diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.javaindex ff09b192fcf..7afe466ed56 100644--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java@@ -38,6 +38,7 @@ public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase {@BeforeClasspublic static void beforeSuperClass() {+ schemaString = "schema15.xml"; // we need a string idSolrCmdDistributor.testing_errorHook = new Diagnostics.Callable() {@Overridepublic void call(Object... data) {@@ -55,6 +56,17 @@ public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase {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@Overridepublic void setUp() throws Exception {@@ -94,7 +106,7 @@ public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase {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();}diff --git a/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java b/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.javaindex 28e473a39bb..6bb1328cfbd 100644--- a/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java@@ -40,8 +40,20 @@ public class RecoveryZkTest extends AbstractFullDistribZkTestBase {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;+ }+@Overridepublic void doTest() throws Exception {handle.clear();@@ -54,10 +66,10 @@ public class RecoveryZkTest extends AbstractFullDistribZkTestBase {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();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.javaindex 6e15ed7d283..db92d136eb4 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@@ -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 AbstractFullDistribZkTestBase extends AbstractDistribZkTes}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 AbstractFullDistribZkTestBase extends AbstractDistribZkTesclass 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 AbstractFullDistribZkTestBase extends AbstractDistribZkTes@Overridepublic void run() {- int i = startI;+ int i = 0;int numDone = 0;int numDeletes = 0;int numAdds = 0;@@ -1368,19 +1367,20 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes}}++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 AbstractFullDistribZkTestBase extends AbstractDistribZkTestry {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 AbstractFullDistribZkTestBase extends AbstractDistribZkTes}if (!addFailed && doDeletes && random().nextBoolean()) {- deletes.add(i);+ deletes.add(id);}try {