Apache Lucene open-source search software
SOLR-6902: Use JUnit rules instead of inheritance with distributed Solr tests to allow for multiple tests without the same class
Erick Erickson7fda449473be
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 5fda6a09c6a..48e97489bbc 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -54,6 +54,10 @@ Other Changes* SOLR-6895: Deprecated SolrServer classes have been removed (Alan Woodward,Erik Hatcher)+* SOLR-6902Use JUnit rules instead of inheritance with distributed Solr+ tests to allow for multiple tests without the same class.+ (Ramkumar Aiyengar, Erick Erickson, Mike McCandless)+================== 5.1.0 ==================Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this releasediff --git a/solr/contrib/clustering/src/test/org/apache/solr/handler/clustering/DistributedClusteringComponentTest.java b/solr/contrib/clustering/src/test/org/apache/solr/handler/clustering/DistributedClusteringComponentTest.javaindex da654c78fe3..62b4b48c657 100644--- a/solr/contrib/clustering/src/test/org/apache/solr/handler/clustering/DistributedClusteringComponentTest.java+++ b/solr/contrib/clustering/src/test/org/apache/solr/handler/clustering/DistributedClusteringComponentTest.java@@ -20,6 +20,7 @@ package org.apache.solr.handler.clustering;import org.apache.solr.BaseDistributedSearchTestCase;import org.apache.solr.SolrTestCaseJ4.SuppressSSL;import org.apache.solr.common.params.CommonParams;+import org.junit.Test;@SuppressSSLpublic class DistributedClusteringComponentTest extends@@ -30,8 +31,8 @@ public class DistributedClusteringComponentTest extendsreturn getFile("clustering/solr/collection1").getParent();}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {del("*:*");int numberOfDocs = 0;for (String[] doc : AbstractClusteringTestCase.DOCUMENTS) {@@ -47,7 +48,7 @@ public class DistributedClusteringComponentTest extendsCommonParams.Q, "*:*",CommonParams.SORT, id + " desc",ClusteringParams.USE_SEARCH_RESULTS, "true");- // destroy is not needed because tearDown method of base class does it.+ // destroy is not needed because distribTearDown method of base class does it.//destroyServers();}diff --git a/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineGoLiveMiniMRTest.java b/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineGoLiveMiniMRTest.javaindex 002f7e39f47..3823d7c6ef6 100644--- a/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineGoLiveMiniMRTest.java+++ b/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineGoLiveMiniMRTest.java@@ -71,9 +71,7 @@ import org.apache.solr.common.util.NamedList;import org.apache.solr.hadoop.hack.MiniMRClientCluster;import org.apache.solr.hadoop.hack.MiniMRClientClusterFactory;import org.apache.solr.morphlines.solr.AbstractSolrMorphlineTestBase;-import org.junit.After;import org.junit.AfterClass;-import org.junit.Before;import org.junit.BeforeClass;import org.junit.Test;@@ -120,10 +118,9 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {this.inputAvroFile1 = "sample-statuses-20120521-100919.avro";this.inputAvroFile2 = "sample-statuses-20120906-141433.avro";this.inputAvroFile3 = "sample-statuses-20120906-141433-medium.avro";-- fixShardCount = true;+sliceCount = TEST_NIGHTLY ? 7 : 3;- shardCount = TEST_NIGHTLY ? 7 : 3;+ fixShardCount(TEST_NIGHTLY ? 7 : 3);}@BeforeClass@@ -197,9 +194,8 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {}@Override- @Before- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("host", "127.0.0.1");System.setProperty("numShards", Integer.toString(sliceCount));URI uri = dfsCluster.getFileSystem().getUri();@@ -208,9 +204,8 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {}@Override- @After- public void tearDown() throws Exception {- super.tearDown();+ public void distribTearDown() throws Exception {+ super.distribTearDown();System.clearProperty("host");System.clearProperty("numShards");System.clearProperty("solr.hdfs.home");@@ -242,12 +237,6 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {return jobConf;}- @Test- @Override- public void testDistribSearch() throws Exception {- super.testDistribSearch();- }-@Testpublic void testBuildShardUrls() throws Exception {// 2x3@@ -350,9 +339,9 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {};return concat(head, args);}-- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {waitForRecoveriesToFinish(false);@@ -691,7 +680,7 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {}private void getShardUrlArgs(List<String> args) {- for (int i = 0; i < shardCount; i++) {+ for (int i = 0; i < getShardCount(); i++) {args.add("--shard-url");args.add(cloudJettys.get(i).url);}diff --git a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineZkTestBase.java b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineZkTestBase.javaindex fc403351cc2..84514e2e370 100644--- a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineZkTestBase.java+++ b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineZkTestBase.java@@ -27,10 +27,7 @@ import org.apache.solr.cloud.AbstractFullDistribZkTestBase;import org.apache.solr.cloud.AbstractZkTestCase;import org.apache.solr.common.SolrDocument;import org.apache.solr.common.cloud.SolrZkClient;-import org.junit.After;-import org.junit.Before;import org.junit.BeforeClass;-import org.junit.Test;import org.kitesdk.morphline.api.Collector;import org.kitesdk.morphline.api.Command;import org.kitesdk.morphline.api.MorphlineContext;@@ -61,9 +58,8 @@ public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistri}public AbstractSolrMorphlineZkTestBase() {- fixShardCount = true;sliceCount = 3;- shardCount = 3;+ fixShardCount(3);}@BeforeClass@@ -76,9 +72,8 @@ public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistri}@Override- @Before- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("host", "127.0.0.1");System.setProperty("numShards", Integer.toString(sliceCount));uploadConfFiles();@@ -86,19 +81,12 @@ public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistri}@Override- @After- public void tearDown() throws Exception {- super.tearDown();+ public void distribTearDown() throws Exception {+ super.distribTearDown();System.clearProperty("host");System.clearProperty("numShards");}- @Test- @Override- public void testDistribSearch() throws Exception {- super.testDistribSearch();- }-@Overrideprotected void commit() throws Exception {Notifications.notifyCommitTransaction(morphline);diff --git a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAliasTest.java b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAliasTest.javaindex d6a2e10f19f..a9ba3a93f2f 100644--- a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAliasTest.java+++ b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAliasTest.java@@ -33,6 +33,7 @@ import org.apache.solr.common.params.CollectionParams.CollectionAction;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;import org.junit.BeforeClass;+import org.junit.Test;import org.kitesdk.morphline.api.Record;import org.kitesdk.morphline.base.Fields;import org.kitesdk.morphline.base.Notifications;@@ -48,8 +49,9 @@ import java.util.Iterator;@Slowpublic class SolrMorphlineZkAliasTest extends AbstractSolrMorphlineZkTestBase {- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {waitForRecoveriesToFinish(false);diff --git a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAvroTest.java b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAvroTest.javaindex 263b4720ae5..6b539e6245f 100644--- a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAvroTest.java+++ b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAvroTest.java@@ -35,6 +35,8 @@ import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.client.solrj.SolrQuery;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.SolrDocument;+import org.junit.BeforeClass;+import org.junit.Test;import org.kitesdk.morphline.api.Record;import org.kitesdk.morphline.base.Fields;import org.kitesdk.morphline.base.Notifications;@@ -53,8 +55,9 @@ import java.util.List;@Slowpublic class SolrMorphlineZkAvroTest extends AbstractSolrMorphlineZkTestBase {- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {Joiner joiner = Joiner.on(File.separator);File file = new File(joiner.join(RESOURCES_DIR, "test-documents", "sample-statuses-20120906-141433-medium.avro"));diff --git a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkTest.java b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkTest.javaindex fef15329e47..c3a2a130390 100644--- a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkTest.java+++ b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkTest.java@@ -28,6 +28,7 @@ import org.apache.solr.client.solrj.SolrQuery;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.SolrDocument;import org.junit.BeforeClass;+import org.junit.Test;import org.kitesdk.morphline.api.Record;import org.kitesdk.morphline.base.Fields;import org.kitesdk.morphline.base.Notifications;@@ -42,8 +43,9 @@ import java.util.Iterator;@Slowpublic class SolrMorphlineZkTest extends AbstractSolrMorphlineZkTestBase {- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {waitForRecoveriesToFinish(false);diff --git a/solr/core/src/test/org/apache/solr/DistributedIntervalFacetingTest.java b/solr/core/src/test/org/apache/solr/DistributedIntervalFacetingTest.javaindex 275e9945e6b..b6d0bfaf3e7 100644--- a/solr/core/src/test/org/apache/solr/DistributedIntervalFacetingTest.java+++ b/solr/core/src/test/org/apache/solr/DistributedIntervalFacetingTest.java@@ -10,6 +10,7 @@ import org.apache.solr.client.solrj.response.IntervalFacet.Count;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.params.ModifiableSolrParams;import org.junit.BeforeClass;+import org.junit.Test;/** Licensed to the Apache Software Foundation (ASF) under one or more@@ -37,8 +38,8 @@ public class DistributedIntervalFacetingTest extendsconfigString = "solrconfig-basic.xml";}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {del("*:*");commit();testRandom();diff --git a/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java b/solr/core/src/test/org/apache/solr/TestDistributedGrouping.javaindex e6ef47e5589..7b86bd8bdc3 100644--- a/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java+++ b/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java@@ -24,6 +24,7 @@ import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;+import org.junit.Test;/*** TODO? perhaps use:@@ -43,8 +44,8 @@ public class TestDistributedGrouping extends BaseDistributedSearchTestCase {String tdate_b = "b_n_tdt";String oddField="oddField_s";- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {del("*:*");commit();diff --git a/solr/core/src/test/org/apache/solr/TestDistributedMissingSort.java b/solr/core/src/test/org/apache/solr/TestDistributedMissingSort.javaindex 7dd58152174..f877c543a90 100644--- a/solr/core/src/test/org/apache/solr/TestDistributedMissingSort.java+++ b/solr/core/src/test/org/apache/solr/TestDistributedMissingSort.java@@ -19,6 +19,7 @@ package org.apache.solr;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.client.solrj.response.QueryResponse;+import org.junit.Test;/*** Tests sortMissingFirst and sortMissingLast in distributed sort@@ -37,8 +38,8 @@ public class TestDistributedMissingSort extends BaseDistributedSearchTestCase {String string1_ml = "five_s1_ml"; // StringField, sortMissingLast=true, multiValued=falseString string1_mf = "six_s1_mf"; // StringField, sortMissingFirst=true, multiValued=false- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {index();testSortMissingLast();testSortMissingFirst();diff --git a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java b/solr/core/src/test/org/apache/solr/TestDistributedSearch.javaindex be50d6230e8..76e98ca8f38 100644--- a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java+++ b/solr/core/src/test/org/apache/solr/TestDistributedSearch.java@@ -37,6 +37,7 @@ import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.params.ShardParams;import org.apache.solr.common.util.NamedList;+import org.junit.Test;/*** TODO? perhaps use:@@ -61,8 +62,8 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {String missingField="ignore_exception__missing_but_valid_field_t";String invalidField="ignore_exception__invalid_field_not_in_schema";- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {QueryResponse rsp = null;int backupStress = stress; // make a copy so we can restorediff --git a/solr/core/src/test/org/apache/solr/TestHighlightDedupGrouping.java b/solr/core/src/test/org/apache/solr/TestHighlightDedupGrouping.javaindex fbccf9754f9..3d1ec6bace8 100644--- a/solr/core/src/test/org/apache/solr/TestHighlightDedupGrouping.java+++ b/solr/core/src/test/org/apache/solr/TestHighlightDedupGrouping.java@@ -17,11 +17,11 @@package org.apache.solr;-import org.apache.lucene.util.TestUtil;import org.apache.lucene.util.TestUtil;import org.apache.solr.client.solrj.SolrServerException;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.SolrInputDocument;+import org.junit.Test;import java.io.IOException;@@ -35,14 +35,9 @@ public class TestHighlightDedupGrouping extends BaseDistributedSearchTestCase {private static final String group_ti1 = "group_ti1";private static final String shard_i1 = "shard_i1";- public TestHighlightDedupGrouping() {- super();- fixShardCount = true;- shardCount = 2;- }-- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 2)+ public void test() throws Exception {basicTest();randomizedTest();}@@ -57,7 +52,7 @@ public class TestHighlightDedupGrouping extends BaseDistributedSearchTestCase {int docid = 1;int group = 5;- for (int shard = 0 ; shard < shardCount ; ++shard) {+ for (int shard = 0 ; shard < getShardCount(); ++shard) {addDoc(docid, group, shard); // add the same doc to both shardsclients.get(shard).commit();}@@ -67,7 +62,7 @@ public class TestHighlightDedupGrouping extends BaseDistributedSearchTestCase {"shards", shards,"group", "true","group.field", id_s1,- "group.limit", Integer.toString(shardCount),+ "group.limit", Integer.toString(getShardCount()),"hl", "true","hl.fl", id_s1));@@ -93,15 +88,15 @@ public class TestHighlightDedupGrouping extends BaseDistributedSearchTestCase {++docsInGroup[group];boolean makeDuplicate = 0 == TestUtil.nextInt(random(), 0, numDocs / percentDuplicates);if (makeDuplicate) {- for (int shard = 0 ; shard < shardCount ; ++shard) {+ for (int shard = 0 ; shard < getShardCount(); ++shard) {addDoc(docid, group, shard);}} else {- int shard = TestUtil.nextInt(random(), 0, shardCount - 1);+ int shard = TestUtil.nextInt(random(), 0, getShardCount() - 1);addDoc(docid, group, shard);}}- for (int shard = 0 ; shard < shardCount ; ++shard) {+ for (int shard = 0 ; shard < getShardCount(); ++shard) {clients.get(shard).commit();}diff --git a/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java b/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.javaindex 414e77f4bf6..fed79f7b6a5 100644--- a/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java@@ -37,12 +37,11 @@ import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.params.CollectionParams.CollectionAction;import org.apache.solr.common.params.ModifiableSolrParams;-import org.junit.After;import org.junit.AfterClass;-import org.junit.Before;import org.junit.BeforeClass;import org.slf4j.Logger;import org.slf4j.LoggerFactory;+import org.junit.Test;/*** Test sync phase that occurs when Leader goes down and a new Leader is@@ -62,28 +61,20 @@ public class AliasIntegrationTest extends AbstractFullDistribZkTestBase {}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));}-- @Override- @After- public void tearDown() throws Exception {- super.tearDown();- resetExceptionIgnores();- }-+public AliasIntegrationTest() {super();sliceCount = 1;- shardCount = random().nextBoolean() ? 3 : 4;+ fixShardCount(random().nextBoolean() ? 3 : 4);}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {handle.clear();handle.put("timestamp", SKIPVAL);diff --git a/solr/core/src/test/org/apache/solr/cloud/AsyncMigrateRouteKeyTest.java b/solr/core/src/test/org/apache/solr/cloud/AsyncMigrateRouteKeyTest.javaindex 82414b209f3..7e7b4ad9155 100644--- a/solr/core/src/test/org/apache/solr/cloud/AsyncMigrateRouteKeyTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/AsyncMigrateRouteKeyTest.java@@ -24,7 +24,7 @@ import org.apache.solr.client.solrj.request.QueryRequest;import org.apache.solr.common.params.CollectionParams;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;-import org.junit.Before;+import org.junit.Test;import java.io.IOException;@@ -36,13 +36,8 @@ public class AsyncMigrateRouteKeyTest extends MigrateRouteKeyTest {private static final int MAX_WAIT_SECONDS = 2 * 60;- @Override- @Before- public void setUp() throws Exception {- super.setUp();- }-- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {waitForThingsToLevelOut(15);multipleShardMigrateTest();diff --git a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.javaindex e1f3c4b5731..6aa4713229e 100644--- a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java+++ b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java@@ -38,6 +38,7 @@ import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;import org.apache.solr.handler.ReplicationHandler;+import org.junit.Test;import java.io.File;import java.io.FilenameFilter;@@ -58,21 +59,12 @@ public class BasicDistributedZk2Test extends AbstractFullDistribZkTestBase {public BasicDistributedZk2Test() {super();- fixShardCount = true;-sliceCount = 2;- shardCount = 4;}- /*- * (non-Javadoc)- *- * @see org.apache.solr.BaseDistributedSearchTestCase#doTest()- *- * Create 3 shards, each with one replica- */- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {boolean testFinished = false;try {handle.clear();diff --git a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.javaindex c3a25f2e6c9..97ecca8e223 100644--- a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java@@ -50,8 +50,8 @@ import org.apache.solr.common.params.UpdateParams;import org.apache.solr.common.util.NamedList;import org.apache.solr.update.DirectUpdateHandler2;import org.apache.solr.util.DefaultSolrThreadFactory;-import org.junit.Before;import org.junit.BeforeClass;+import org.junit.Test;import java.io.IOException;import java.util.ArrayList;@@ -106,20 +106,16 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {public static void beforeThisClass2() throws Exception {}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));System.setProperty("solr.xml.persist", "true");}public BasicDistributedZkTest() {- fixShardCount = true;-sliceCount = 2;- shardCount = 4;completionService = new ExecutorCompletionService<>(executor);pending = new HashSet<>();@@ -133,7 +129,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {} else {// use shard ids rather than physical locationsStringBuilder sb = new StringBuilder();- for (int i = 0; i < shardCount; i++) {+ for (int i = 0; i < getShardCount(); i++) {if (i > 0)sb.append(',');sb.append("shard" + (i + 3));@@ -141,9 +137,10 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {params.set("shards", sb.toString());}}-- @Override- public void doTest() throws Exception {++ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {// setLoggingLevel(null);ZkStateReader zkStateReader = cloudClient.getZkStateReader();@@ -1160,8 +1157,8 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {}@Override- public void tearDown() throws Exception {- super.tearDown();+ public void distribTearDown() throws Exception {+ super.distribTearDown();if (commondCloudSolrClient != null) {commondCloudSolrClient.shutdown();}@@ -1175,9 +1172,8 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {otherCollectionClients = null;List<Runnable> tasks = executor.shutdownNow();assertTrue(tasks.isEmpty());-+System.clearProperty("numShards");- System.clearProperty("zkHost");System.clearProperty("solr.xml.persist");// insurancediff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.javaindex 5ef74aedfd8..2f5209959c8 100644--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java@@ -18,7 +18,6 @@ package org.apache.solr.cloud;*/import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;-import org.apache.http.client.HttpClient;import org.apache.http.impl.client.CloseableHttpClient;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.SolrTestCaseJ4.SuppressSSL;@@ -33,10 +32,9 @@ import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.util.IOUtils;import org.apache.solr.core.Diagnostics;import org.apache.solr.update.SolrCmdDistributor;-import org.junit.After;import org.junit.AfterClass;-import org.junit.Before;import org.junit.BeforeClass;+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -88,10 +86,9 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBasereturn randVals;}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();// can help to hide this when testing and looking at logs//ignoreException("shard update error");System.setProperty("numShards", Integer.toString(sliceCount));@@ -99,28 +96,27 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase}@Override- @After- public void tearDown() throws Exception {+ public void distribTearDown() throws Exception {System.clearProperty("numShards");- super.tearDown();- resetExceptionIgnores();+ super.distribTearDown();}public ChaosMonkeyNothingIsSafeTest() {super();sliceCount = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.slicecount", "-1"));- shardCount = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.shardcount", "-1"));-if (sliceCount == -1) {sliceCount = random().nextInt(TEST_NIGHTLY ? 5 : 3) + 1;}- if (shardCount == -1) {- shardCount = sliceCount + random().nextInt(TEST_NIGHTLY ? 12 : 2);++ int numShards = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.shardcount", "-1"));+ if (numShards == -1) {+ numShards = sliceCount + random().nextInt(TEST_NIGHTLY ? 12 : 2);}+ fixShardCount(numShards);}-- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {boolean testsSuccesful = false;try {handle.clear();diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.javaindex 44dd9dca35e..412fe3d681f 100644--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java@@ -28,10 +28,9 @@ import org.apache.solr.client.solrj.impl.CloudSolrClient;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.core.Diagnostics;import org.apache.solr.update.SolrCmdDistributor;-import org.junit.After;import org.junit.AfterClass;-import org.junit.Before;import org.junit.BeforeClass;+import org.junit.Test;@Slowpublic class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase {@@ -69,39 +68,37 @@ public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase {return randVals;}- @Before@Override- public void setUp() throws Exception {+ public void distribSetUp() throws Exception {useFactory("solr.StandardDirectoryFactory");- super.setUp();+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));}@Override- @After- public void tearDown() throws Exception {+ public void distribTearDown() throws Exception {System.clearProperty("numShards");- super.tearDown();- resetExceptionIgnores();+ super.distribTearDown();}public ChaosMonkeySafeLeaderTest() {super();sliceCount = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.slicecount", "-1"));- shardCount = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.shardcount", "-1"));-if (sliceCount == -1) {sliceCount = random().nextInt(TEST_NIGHTLY ? 5 : 3) + 1;}- if (shardCount == -1) {- shardCount = sliceCount + random().nextInt(TEST_NIGHTLY ? 12 : 2);++ int numShards = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.shardcount", "-1"));+ if (numShards == -1) {+ numShards = sliceCount + random().nextInt(TEST_NIGHTLY ? 12 : 2);}+ fixShardCount(numShards);}-- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {handle.clear();handle.put("timestamp", SKIPVAL);diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.javaindex 9c3be9bafee..a99d6ffadb1 100644--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java@@ -31,9 +31,8 @@ import org.apache.solr.handler.component.HttpShardHandlerFactory;import org.apache.solr.update.UpdateShardHandler;import org.apache.solr.util.MockConfigSolr;import org.apache.zookeeper.KeeperException;-import org.junit.After;-import org.junit.Before;import org.junit.Ignore;+import org.junit.Test;import java.io.IOException;import java.util.Collection;@@ -50,20 +49,8 @@ public class ChaosMonkeyShardSplitTest extends ShardSplitTest {static final int TIMEOUT = 10000;private AtomicInteger killCounter = new AtomicInteger();- @Before- @Override- public void setUp() throws Exception {- super.setUp();- }-- @Override- @After- public void tearDown() throws Exception {- super.tearDown();- }-- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {waitForThingsToLevelOut(15);ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();diff --git a/solr/core/src/test/org/apache/solr/cloud/CloudExitableDirectoryReaderTest.java b/solr/core/src/test/org/apache/solr/cloud/CloudExitableDirectoryReaderTest.javaindex c1e9fea3fd1..bc522c4eeab 100644--- a/solr/core/src/test/org/apache/solr/cloud/CloudExitableDirectoryReaderTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/CloudExitableDirectoryReaderTest.java@@ -22,6 +22,7 @@ import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.lucene.util.TestUtil;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.params.ModifiableSolrParams;+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -43,8 +44,8 @@ public class CloudExitableDirectoryReaderTest extends AbstractFullDistribZkTestBreturn configString;}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {handle.clear();handle.put("timestamp", SKIPVAL);waitForRecoveriesToFinish(false);diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIAsyncDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIAsyncDistributedZkTest.javaindex 99262f70b97..e6371c4a5c8 100644--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIAsyncDistributedZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIAsyncDistributedZkTest.java@@ -28,7 +28,7 @@ import org.apache.solr.client.solrj.request.CollectionAdminRequest.SplitShard;import org.apache.solr.client.solrj.response.CollectionAdminResponse;import org.apache.solr.common.util.NamedList;import org.apache.solr.update.DirectUpdateHandler2;-import org.junit.Before;+import org.junit.Test;import java.io.IOException;@@ -40,10 +40,9 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkTprivate static final int MAX_TIMEOUT_SECONDS = 60;private static final boolean DEBUG = false;- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();useJettyDataDir = false;@@ -52,23 +51,12 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkT}public CollectionsAPIAsyncDistributedZkTest() {- fixShardCount = true;-sliceCount = 1;- shardCount = 1;}- @Override- public void doTest() throws Exception {-- testSolrJAPICalls();-- if (DEBUG) {- super.printLayout();- }- }-- private void testSolrJAPICalls() throws Exception {+ @Test+ @ShardsFixed(num = 1)+ public void testSolrJAPICalls() throws Exception {SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)));try {Create createCollectionRequest = new Create();@@ -115,6 +103,10 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkT} finally {client.shutdown();}++ if (DEBUG) {+ printLayout();+ }}private String getRequestStateAfterCompletion(String requestId, int waitForSeconds, SolrClient client)@@ -141,10 +133,9 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkT}@Override- public void tearDown() throws Exception {- super.tearDown();+ public void distribTearDown() throws Exception {+ super.distribTearDown();System.clearProperty("numShards");- System.clearProperty("zkHost");System.clearProperty("solr.xml.persist");// insurancediff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.javaindex f96c7c3df95..8c543d2f73b 100644--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java@@ -57,8 +57,8 @@ import org.apache.solr.core.SolrInfoMBean.Category;import org.apache.solr.servlet.SolrDispatchFilter;import org.apache.solr.update.DirectUpdateHandler2;import org.apache.solr.util.DefaultSolrThreadFactory;-import org.junit.Before;import org.junit.BeforeClass;+import org.junit.Test;import javax.management.MBeanServer;import javax.management.MBeanServerFactory;@@ -117,10 +117,9 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();useJettyDataDir = false;@@ -161,10 +160,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBapublic CollectionsAPIDistributedZkTest() {- fixShardCount = true;-sliceCount = 2;- shardCount = 4;completionService = new ExecutorCompletionService<>(executor);pending = new HashSet<>();checkCreatedVsState = false;@@ -179,7 +175,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa} else {// use shard ids rather than physical locationsStringBuilder sb = new StringBuilder();- for (int i = 0; i < shardCount; i++) {+ for (int i = 0; i < getShardCount(); i++) {if (i > 0)sb.append(',');sb.append("shard" + (i + 3));@@ -187,9 +183,10 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBaparams.set("shards", sb.toString());}}-- @Override- public void doTest() throws Exception {++ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {testNodesUsedByCreate();testCollectionsAPI();testCollectionsAPIAddRemoveStress();@@ -600,7 +597,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBaint cnt = random().nextInt(TEST_NIGHTLY ? 6 : 1) + 1;for (int i = 0; i < cnt; i++) {- int numShards = TestUtil.nextInt(random(), 0, shardCount) + 1;+ int numShards = TestUtil.nextInt(random(), 0, getShardCount()) + 1;int replicationFactor = TestUtil.nextInt(random(), 0, 3) + 1;int maxShardsPerNode = (((numShards * replicationFactor) / getCommonCloudSolrClient().getZkStateReader().getClusterState().getLiveNodes().size())) + 1;@@ -896,7 +893,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBafor (int i = 0; i < cnt; i++) {String collectionName = "awholynewstresscollection_" + name + "_" + i;- int numShards = TestUtil.nextInt(random(), 0, shardCount * 2) + 1;+ int numShards = TestUtil.nextInt(random(), 0, getShardCount() * 2) + 1;int replicationFactor = TestUtil.nextInt(random(), 0, 3) + 1;int maxShardsPerNode = (((numShards * 2 * replicationFactor) / getCommonCloudSolrClient().getZkStateReader().getClusterState().getLiveNodes().size())) + 1;@@ -1202,10 +1199,9 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa}@Override- public void tearDown() throws Exception {- super.tearDown();+ public void distribTearDown() throws Exception {+ super.distribTearDown();System.clearProperty("numShards");- System.clearProperty("zkHost");System.clearProperty("solr.xml.persist");// insurancediff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTests.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTests.javaindex d247e1cf899..29eb7f934c4 100644--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTests.java+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTests.java@@ -34,6 +34,7 @@ import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.params.CoreAdminParams;import org.apache.solr.common.util.NamedList;import org.apache.zookeeper.KeeperException;+import org.junit.Test;import java.io.File;import java.io.IOException;@@ -49,9 +50,9 @@ import static org.apache.solr.cloud.ReplicaPropertiesBase.verifyUniqueAcrossColl@LuceneTestCase.Slowpublic class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {-- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {testCreateAndDeleteCollection();testCreateAndDeleteShard();testReloadCollection();@@ -67,19 +68,6 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {testBalanceShardUnique();}- public void tearDown() throws Exception {- if (controlClient != null) {- controlClient.shutdown();- }- if (cloudClient != null) {- cloudClient.shutdown();- }- if (controlClientCloud != null) {- controlClientCloud.shutdown();- }- super.tearDown();- }-protected void testCreateAndDeleteCollection() throws Exception {String collectionName = "solrj_test";CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create();diff --git a/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java b/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.javaindex 2db4fc4cbff..d624d793c58 100644--- a/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java@@ -60,8 +60,8 @@ import org.apache.solr.common.params.CollectionParams.CollectionAction;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.update.DirectUpdateHandler2;import org.apache.solr.util.DefaultSolrThreadFactory;-import org.junit.Before;import org.junit.BeforeClass;+import org.junit.Test;/*** Tests the Custom Sharding API.@@ -84,10 +84,9 @@ public class CustomCollectionTest extends AbstractFullDistribZkTestBase {public static void beforeThisClass2() throws Exception {}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));System.setProperty("solr.xml.persist", "true");}@@ -98,10 +97,7 @@ public class CustomCollectionTest extends AbstractFullDistribZkTestBase {public CustomCollectionTest() {- fixShardCount = true;-sliceCount = 2;- shardCount = 4;completionService = new ExecutorCompletionService<>(executor);pending = new HashSet<>();checkCreatedVsState = false;@@ -116,7 +112,7 @@ public class CustomCollectionTest extends AbstractFullDistribZkTestBase {} else {// use shard ids rather than physical locationsStringBuilder sb = new StringBuilder();- for (int i = 0; i < shardCount; i++) {+ for (int i = 0; i < getShardCount(); i++) {if (i > 0)sb.append(',');sb.append("shard" + (i + 3));@@ -125,8 +121,9 @@ public class CustomCollectionTest extends AbstractFullDistribZkTestBase {}}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {testCustomCollectionsAPI();testRouteFieldForHashRouter();testCreateShardRepFactor();@@ -492,10 +489,9 @@ public class CustomCollectionTest extends AbstractFullDistribZkTestBase {}@Override- public void tearDown() throws Exception {- super.tearDown();+ public void distribTearDown() throws Exception {+ super.distribTearDown();System.clearProperty("numShards");- System.clearProperty("zkHost");System.clearProperty("solr.xml.persist");// insurancediff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java b/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.javaindex e81fb1bbd1f..49b18ad165d 100644--- a/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java@@ -29,8 +29,7 @@ import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.params.CoreAdminParams;import org.apache.solr.common.params.MapSolrParams;import org.apache.solr.common.util.NamedList;-import org.junit.After;-import org.junit.Before;+import org.junit.Test;import java.net.URL;import java.util.Map;@@ -41,22 +40,8 @@ import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;//@Ignore("Not currently valid see SOLR-5580")public class DeleteInactiveReplicaTest extends DeleteReplicaTest{- @Override- public void doTest() throws Exception {- deleteInactiveReplicaTest();- }-- @Before- public void setUp() throws Exception {- super.setUp();- }-- @After- public void tearDown() throws Exception {- super.tearDown();- }-- private void deleteInactiveReplicaTest() throws Exception {+ @Test+ public void deleteInactiveReplicaTest() throws Exception {CloudSolrClient client = createCloudClient(null);String collectionName = "delDeadColl";diff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteLastCustomShardedReplicaTest.java b/solr/core/src/test/org/apache/solr/cloud/DeleteLastCustomShardedReplicaTest.javaindex 3e86bea7f29..0515c76c5df 100644--- a/solr/core/src/test/org/apache/solr/cloud/DeleteLastCustomShardedReplicaTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/DeleteLastCustomShardedReplicaTest.java@@ -27,10 +27,9 @@ import org.apache.solr.common.cloud.Replica;import org.apache.solr.common.cloud.ZkNodeProps;import org.apache.solr.common.params.MapSolrParams;import org.apache.solr.common.params.SolrParams;-import org.junit.After;-import org.junit.Before;import org.junit.BeforeClass;import org.junit.Ignore;+import org.junit.Test;import java.io.IOException;import java.util.HashMap;@@ -53,18 +52,17 @@ public class DeleteLastCustomShardedReplicaTest extends AbstractFullDistribZkTes}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));System.setProperty("solr.xml.persist", "true");client = createCloudClient(null);}- @After- public void tearDown() throws Exception {- super.tearDown();+ @Override+ public void distribTearDown() throws Exception {+ super.distribTearDown();client.shutdown();}@@ -73,16 +71,13 @@ public class DeleteLastCustomShardedReplicaTest extends AbstractFullDistribZkTes}public DeleteLastCustomShardedReplicaTest() {- fixShardCount = true;-sliceCount = 2;- shardCount = 2;-checkCreatedVsState = false;}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 2)+ public void test() throws Exception {int replicationFactor = 1;int maxShardsPerNode = 5;diff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.javaindex e8f3450293b..c128c72b0b4 100644--- a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java@@ -32,9 +32,8 @@ import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.params.MapSolrParams;import org.apache.solr.common.params.SolrParams;import org.apache.solr.common.util.NamedList;-import org.junit.After;-import org.junit.Before;import org.junit.BeforeClass;+import org.junit.Test;import java.io.File;import java.io.IOException;@@ -56,18 +55,17 @@ public class DeleteReplicaTest extends AbstractFullDistribZkTestBase {}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));System.setProperty("solr.xml.persist", "true");client = createCloudClient(null);}- @After- public void tearDown() throws Exception {- super.tearDown();+ @Override+ public void distribTearDown() throws Exception {+ super.distribTearDown();client.shutdown();}@@ -76,20 +74,13 @@ public class DeleteReplicaTest extends AbstractFullDistribZkTestBase {}public DeleteReplicaTest() {- fixShardCount = true;-sliceCount = 2;- shardCount = 4;-checkCreatedVsState = false;}- @Override- public void doTest() throws Exception {- deleteLiveReplicaTest();- }-- private void deleteLiveReplicaTest() throws Exception {+ @Test+ @ShardsFixed(num = 4)+ public void deleteLiveReplicaTest() throws Exception {String collectionName = "delLiveColl";CloudSolrClient client = createCloudClient(null);try {diff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteShardTest.java b/solr/core/src/test/org/apache/solr/cloud/DeleteShardTest.javaindex 5655f6b4019..823efa75892 100644--- a/solr/core/src/test/org/apache/solr/cloud/DeleteShardTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/DeleteShardTest.java@@ -30,8 +30,7 @@ import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.params.CollectionParams;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.zookeeper.KeeperException;-import org.junit.After;-import org.junit.Before;+import org.junit.Test;import java.io.IOException;import java.util.HashMap;@@ -41,46 +40,28 @@ public class DeleteShardTest extends AbstractFullDistribZkTestBase {public DeleteShardTest() {super();- fixShardCount = true;- shardCount = 2;sliceCount = 2;}@Override- @Before- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", "2");System.setProperty("solr.xml.persist", "true");}@Override- @After- public void tearDown() throws Exception {- super.tearDown();-- if (VERBOSE || printLayoutOnTearDown) {- super.printLayout();- }- if (controlClient != null) {- controlClient.shutdown();- }- if (cloudClient != null) {- cloudClient.shutdown();- }- if (controlClientCloud != null) {- controlClientCloud.shutdown();- }- super.tearDown();-+ public void distribTearDown() throws Exception {+ super.distribTearDown();System.clearProperty("numShards");System.clearProperty("solr.xml.persist");}// TODO: Custom hash slice deletion test- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 2)+ public void test() throws Exception {ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();Slice slice1 = clusterState.getSlice(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1);diff --git a/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java b/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.javaindex 29a3cb6ca46..0e16f39b4e4 100644--- a/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java@@ -37,6 +37,7 @@ import static org.apache.solr.common.params.CursorMarkParams.CURSOR_MARK_NEXT;import static org.apache.solr.common.params.CursorMarkParams.CURSOR_MARK_START;import org.apache.solr.search.CursorMark; //jdoc+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -69,8 +70,8 @@ public class DistribCursorPagingTest extends AbstractFullDistribZkTestBase {return configString;}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {boolean testFinished = false;try {handle.clear();diff --git a/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.javaindex 17b63c5f84d..7a1772fc15c 100644--- a/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java@@ -26,6 +26,7 @@ import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.update.processor.DocExpirationUpdateProcessorFactory; // jdocimport org.apache.solr.update.processor.DocExpirationUpdateProcessorFactoryTest;+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -52,8 +53,8 @@ public class DistribDocExpirationUpdateProcessorTest extends AbstractFullDistribreturn configString;}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {assertTrue("only one shard?!?!?!", 1 < shardToJetty.keySet().size());log.info("number of shards: {}", shardToJetty.keySet().size());diff --git a/solr/core/src/test/org/apache/solr/cloud/ExternalCollectionsTest.java b/solr/core/src/test/org/apache/solr/cloud/ExternalCollectionsTest.javaindex cd274c11995..3952d261e8e 100644--- a/solr/core/src/test/org/apache/solr/cloud/ExternalCollectionsTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ExternalCollectionsTest.java@@ -27,30 +27,22 @@ import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.handler.BlobHandler;import org.apache.solr.handler.TestBlobHandler;import org.apache.zookeeper.data.Stat;-import org.junit.After;-import org.junit.Before;-import org.junit.BeforeClass;+import org.junit.Test;public class ExternalCollectionsTest extends AbstractFullDistribZkTestBase {private CloudSolrClient client;- @BeforeClass- public static void beforeThisClass2() throws Exception {-- }-- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));System.setProperty("solr.xml.persist", "true");client = createCloudClient(null);}- @After- public void tearDown() throws Exception {- super.tearDown();+ @Override+ public void distribTearDown() throws Exception {+ super.distribTearDown();client.shutdown();}@@ -59,17 +51,13 @@ public class ExternalCollectionsTest extends AbstractFullDistribZkTestBase {}public ExternalCollectionsTest() {- fixShardCount = true;-- sliceCount = 2;- shardCount = 4;-checkCreatedVsState = false;}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {testZkNodeLocation();testConfNameAndCollectionNameSame();}diff --git a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.javaindex ba6c553fa5e..22deeeb74df 100644--- a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java@@ -39,6 +39,7 @@ import org.apache.solr.update.VersionInfo;import org.apache.solr.update.processor.DistributedUpdateProcessor;import org.apache.zookeeper.CreateMode;import org.junit.BeforeClass;+import org.junit.Test;import java.io.IOException;import java.util.ArrayList;@@ -58,13 +59,12 @@ public class FullSolrCloudDistribCmdsTest extends AbstractFullDistribZkTestBasepublic FullSolrCloudDistribCmdsTest() {super();- fixShardCount = true;- shardCount = 6;sliceCount = 3;}-- @Override- public void doTest() throws Exception {++ @Test+ @ShardsFixed(num = 6)+ public void test() throws Exception {handle.clear();handle.put("timestamp", SKIPVAL);@@ -499,11 +499,6 @@ public class FullSolrCloudDistribCmdsTest extends AbstractFullDistribZkTestBasereturn client.query(query);}- @Override- public void tearDown() throws Exception {- super.tearDown();- }-protected SolrInputDocument addRandFields(SolrInputDocument sdoc) {return sdoc;}diff --git a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.javaindex ea50a7d5704..46c28d2653f 100644--- a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java@@ -36,8 +36,7 @@ import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.util.NamedList;import org.apache.solr.core.CoreContainer;import org.apache.solr.servlet.SolrDispatchFilter;-import org.junit.After;-import org.junit.Before;+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -73,26 +72,15 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {public HttpPartitionTest() {super();sliceCount = 2;- shardCount = 3;+ fixShardCount(3);}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));}- @Override- @After- public void tearDown() throws Exception {- try {- super.tearDown();- } catch (Exception exc) {}-- resetExceptionIgnores();- }-/*** Overrides the parent implementation to install a SocketProxy in-front of the Jetty server.*/@@ -104,8 +92,8 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {return createProxiedJetty(solrHome, dataDir, shardList, solrConfigOverride, schemaOverride);}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {waitForThingsToLevelOut(30000);testLeaderInitiatedRecoveryCRUD();diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.javaindex f4577e66152..4a83b48c70c 100644--- a/solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.java@@ -28,6 +28,7 @@ import org.apache.solr.client.solrj.embedded.JettySolrRunner;import org.apache.solr.client.solrj.impl.HttpSolrClient;import org.apache.solr.client.solrj.request.CollectionAdminRequest;import org.apache.solr.common.cloud.Replica;+import org.junit.Test;/*** Tests leader-initiated recovery scenarios after a leader node fails@@ -42,8 +43,8 @@ public class LeaderFailoverAfterPartitionTest extends HttpPartitionTest {}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {waitForThingsToLevelOut(30000);// kill a leader and make sure recovery occurs as expecteddiff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderInitiatedRecoveryOnCommitTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderInitiatedRecoveryOnCommitTest.javaindex 9e5a06c009d..5f9d529c06f 100644--- a/solr/core/src/test/org/apache/solr/cloud/LeaderInitiatedRecoveryOnCommitTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/LeaderInitiatedRecoveryOnCommitTest.java@@ -22,8 +22,7 @@ import org.apache.solr.client.solrj.impl.HttpSolrClient;import org.apache.solr.client.solrj.request.CollectionAdminRequest;import org.apache.solr.common.cloud.Replica;import org.apache.solr.common.cloud.ZkCoreNodeProps;-import org.junit.After;-import org.junit.Before;+import org.junit.Test;import java.io.File;import java.util.List;@@ -35,29 +34,22 @@ public class LeaderInitiatedRecoveryOnCommitTest extends BasicDistributedZkTestpublic LeaderInitiatedRecoveryOnCommitTest() {super();sliceCount = 1;- shardCount = 4;+ fixShardCount(4);}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));}@Override- @After- public void tearDown() throws Exception {+ public void distribTearDown() throws Exception {System.clearProperty("numShards");- try {- super.tearDown();- } catch (Exception exc) {- }+ super.distribTearDown();- resetExceptionIgnores();-- // close socket proxies after super.tearDown+ // close socket proxies after super.distribTearDownif (!proxies.isEmpty()) {for (SocketProxy proxy : proxies.values()) {proxy.close();@@ -65,8 +57,8 @@ public class LeaderInitiatedRecoveryOnCommitTest extends BasicDistributedZkTest}}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {oneShardTest();multiShardTest();}@@ -171,4 +163,4 @@ public class LeaderInitiatedRecoveryOnCommitTest extends BasicDistributedZkTestreturn createProxiedJetty(solrHome, dataDir, shardList, solrConfigOverride, schemaOverride);}-}\ No newline at end of file+}diff --git a/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java b/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.javaindex 3bd56cee324..1fc35b56ce0 100644--- a/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java@@ -33,8 +33,7 @@ import org.apache.solr.common.cloud.ZkNodeProps;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.update.DirectUpdateHandler2;import org.apache.zookeeper.KeeperException;-import org.junit.After;-import org.junit.Before;+import org.junit.Test;import java.io.IOException;import java.util.HashMap;@@ -52,31 +51,15 @@ public class MigrateRouteKeyTest extends BasicDistributedZkTest {}@Override- @Before- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));System.setProperty("solr.xml.persist", "true");}@Override- @After- public void tearDown() throws Exception {- super.tearDown();-- if (VERBOSE || printLayoutOnTearDown) {- super.printLayout();- }- if (controlClient != null) {- controlClient.shutdown();- }- if (cloudClient != null) {- cloudClient.shutdown();- }- if (controlClientCloud != null) {- controlClientCloud.shutdown();- }- super.tearDown();+ public void distribTearDown() throws Exception {+ super.distribTearDown();System.clearProperty("zkHost");System.clearProperty("numShards");@@ -86,8 +69,8 @@ public class MigrateRouteKeyTest extends BasicDistributedZkTest {DirectUpdateHandler2.commitOnClose = true;}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {waitForThingsToLevelOut(15);if (usually()) {diff --git a/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java b/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.javaindex 0162c5c1e9b..757afbf6092 100644--- a/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java@@ -30,7 +30,7 @@ import org.apache.solr.common.params.CollectionParams;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;import org.apache.solr.update.DirectUpdateHandler2;-import org.junit.Before;+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -49,10 +49,9 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase {private static final int NUM_COLLECTIONS = 4;- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();useJettyDataDir = false;@@ -61,13 +60,12 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase {}public MultiThreadedOCPTest() {- fixShardCount = true;sliceCount = 2;- shardCount = 4;}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {testParallelCollectionAPICalls();testTaskExclusivity();@@ -311,10 +309,9 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase {}@Override- public void tearDown() throws Exception {- super.tearDown();+ public void distribTearDown() throws Exception {+ super.distribTearDown();System.clearProperty("numShards");- System.clearProperty("zkHost");System.clearProperty("solr.xml.persist");// insurancediff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.javaindex 9333996da79..345ae49cddf 100644--- a/solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.java@@ -46,9 +46,8 @@ import org.apache.solr.common.params.CollectionParams.CollectionAction;import org.apache.solr.common.params.MapSolrParams;import org.apache.solr.common.params.SolrParams;import org.apache.zookeeper.data.Stat;-import org.junit.After;-import org.junit.Before;import org.junit.BeforeClass;+import org.junit.Test;@LuceneTestCase.Slow@SuppressSSL // See SOLR-5776@@ -60,18 +59,17 @@ public class OverseerRolesTest extends AbstractFullDistribZkTestBase{}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));System.setProperty("solr.xml.persist", "true");client = createCloudClient(null);}- @After- public void tearDown() throws Exception {- super.tearDown();+ @Override+ public void distribTearDown() throws Exception {+ super.distribTearDown();client.shutdown();}@@ -80,16 +78,14 @@ public class OverseerRolesTest extends AbstractFullDistribZkTestBase{}public OverseerRolesTest() {- fixShardCount = true;-sliceCount = 2;- shardCount = TEST_NIGHTLY ? 6 : 2;+ fixShardCount(TEST_NIGHTLY ? 6 : 2);checkCreatedVsState = false;}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {testQuitCommand();testOverseerRole();}diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerStatusTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerStatusTest.javaindex f1793e70839..419e4ce8e61 100644--- a/solr/core/src/test/org/apache/solr/cloud/OverseerStatusTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/OverseerStatusTest.java@@ -17,20 +17,11 @@ package org.apache.solr.cloud;* limitations under the License.*/-import org.apache.solr.client.solrj.SolrRequest;-import org.apache.solr.client.solrj.SolrServerException;-import org.apache.solr.client.solrj.impl.HttpSolrClient;-import org.apache.solr.client.solrj.request.QueryRequest;import org.apache.solr.client.solrj.response.CollectionAdminResponse;-import org.apache.solr.common.cloud.DocRouter;import org.apache.solr.common.params.CollectionParams;-import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;import org.apache.solr.common.util.SimpleOrderedMap;-import org.junit.After;-import org.junit.Before;--import java.io.IOException;+import org.junit.Test;public class OverseerStatusTest extends BasicDistributedZkTest {@@ -39,33 +30,14 @@ public class OverseerStatusTest extends BasicDistributedZkTest {}@Override- @Before- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));System.setProperty("solr.xml.persist", "true");}- @Override- @After- public void tearDown() throws Exception {- if (VERBOSE || printLayoutOnTearDown) {- super.printLayout();- }- if (controlClient != null) {- controlClient.shutdown();- }- if (cloudClient != null) {- cloudClient.shutdown();- }- if (controlClientCloud != null) {- controlClientCloud.shutdown();- }- super.tearDown();- }-- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {waitForThingsToLevelOut(15);// find existing command counts because collection may be created by base test class toodiff --git a/solr/core/src/test/org/apache/solr/cloud/RecoveryAfterSoftCommitTest.java b/solr/core/src/test/org/apache/solr/cloud/RecoveryAfterSoftCommitTest.javaindex fe6a67b1d1c..6c6d4a6b556 100644--- a/solr/core/src/test/org/apache/solr/cloud/RecoveryAfterSoftCommitTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/RecoveryAfterSoftCommitTest.java@@ -28,15 +28,15 @@ import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.cloud.Replica;import org.junit.AfterClass;import org.junit.BeforeClass;+import org.junit.Test;// See SOLR-6640@SolrTestCaseJ4.SuppressSSLpublic class RecoveryAfterSoftCommitTest extends AbstractFullDistribZkTestBase {public RecoveryAfterSoftCommitTest() {- fixShardCount = true;sliceCount = 1;- shardCount = 2;+ fixShardCount(2);}@BeforeClass@@ -60,8 +60,8 @@ public class RecoveryAfterSoftCommitTest extends AbstractFullDistribZkTestBase {return createProxiedJetty(solrHome, dataDir, shardList, solrConfigOverride, schemaOverride);}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {// flush twicefor (int i=0; i<4; i++) {SolrInputDocument document = new SolrInputDocument();diff --git a/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java b/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.javaindex 638fd34d762..9966178138a 100644--- a/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java@@ -25,6 +25,7 @@ import org.apache.solr.client.solrj.SolrServerException;import org.apache.solr.client.solrj.embedded.JettySolrRunner;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.cloud.ZkStateReader;+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -39,7 +40,7 @@ public class RecoveryZkTest extends AbstractFullDistribZkTestBase {public RecoveryZkTest() {super();sliceCount = 1;- shardCount = 2;+ fixShardCount(2);schemaString = "schema15.xml"; // we need a string id}@@ -54,8 +55,8 @@ public class RecoveryZkTest extends AbstractFullDistribZkTestBase {return randVals;}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {handle.clear();handle.put("timestamp", SKIPVAL);@@ -148,7 +149,7 @@ public class RecoveryZkTest extends AbstractFullDistribZkTestBase {@Override- public void tearDown() throws Exception {+ public void distribTearDown() throws Exception {// make sure threads have been stopped...indexThread.safeStop();indexThread2.safeStop();@@ -156,7 +157,7 @@ public class RecoveryZkTest extends AbstractFullDistribZkTestBase {indexThread.join();indexThread2.join();- super.tearDown();+ super.distribTearDown();}// skip the randoms - they can deadlock...diff --git a/solr/core/src/test/org/apache/solr/cloud/RemoteQueryErrorTest.java b/solr/core/src/test/org/apache/solr/cloud/RemoteQueryErrorTest.javaindex 20e49dc93ec..d344a338dea 100644--- a/solr/core/src/test/org/apache/solr/cloud/RemoteQueryErrorTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/RemoteQueryErrorTest.java@@ -21,6 +21,7 @@ import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrInputDocument;+import org.junit.Test;import java.util.ArrayList;import java.util.List;@@ -36,11 +37,11 @@ public class RemoteQueryErrorTest extends AbstractFullDistribZkTestBase {public RemoteQueryErrorTest() {super();sliceCount = 1;- shardCount = random().nextBoolean() ? 3 : 4;+ fixShardCount(random().nextBoolean() ? 3 : 4);}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {handle.clear();handle.put("timestamp", SKIPVAL);@@ -70,4 +71,4 @@ public class RemoteQueryErrorTest extends AbstractFullDistribZkTestBase {}}}-}\ No newline at end of file+}diff --git a/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java b/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.javaindex 965f35b0f99..f6e17489ebb 100644--- a/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java@@ -19,15 +19,10 @@ package org.apache.solr.cloud;import java.io.File;import java.net.ServerSocket;-import java.net.URI;-import java.net.URL;import java.util.ArrayList;-import java.util.HashMap;import java.util.List;import java.util.Locale;-import java.util.Map;-import org.apache.lucene.util.LuceneTestCase.AwaitsFix;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.SolrTestCaseJ4.SuppressSSL;import org.apache.solr.client.solrj.embedded.JettySolrRunner;@@ -36,10 +31,8 @@ import org.apache.solr.client.solrj.request.UpdateRequest;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.cloud.Replica;import org.apache.solr.common.cloud.ZkCoreNodeProps;-import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.util.NamedList;-import org.junit.After;-import org.junit.Before;+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -59,31 +52,25 @@ public class ReplicationFactorTest extends AbstractFullDistribZkTestBase {public ReplicationFactorTest() {super();sliceCount = 3;- shardCount = 3;+ fixShardCount(3);}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));}@Override- @After- public void tearDown() throws Exception {+ public void distribTearDown() throws Exception {log.info("tearing down replicationFactorTest!");System.clearProperty("numShards");- try {- super.tearDown();- } catch (Exception exc) {}-- resetExceptionIgnores();-- log.info("super.tearDown complete, closing all socket proxies");+ super.distribTearDown();++ log.info("super.distribTearDown complete, closing all socket proxies");if (!proxies.isEmpty()) {for (SocketProxy proxy : proxies.values()) {proxy.close();@@ -111,10 +98,10 @@ public class ReplicationFactorTest extends AbstractFullDistribZkTestBase {port = s.getLocalPort();}return port;- }-- @Override- public void doTest() throws Exception {+ }++ @Test+ public void test() throws Exception {log.info("replication factor test running");waitForThingsToLevelOut(30000);diff --git a/solr/core/src/test/org/apache/solr/cloud/RollingRestartTest.java b/solr/core/src/test/org/apache/solr/cloud/RollingRestartTest.javaindex 9e90821bc18..4523d528d96 100644--- a/solr/core/src/test/org/apache/solr/cloud/RollingRestartTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/RollingRestartTest.java@@ -21,8 +21,7 @@ import org.apache.commons.collections.CollectionUtils;import org.apache.solr.common.cloud.SolrZkClient;import org.apache.solr.common.params.CollectionParams;import org.apache.zookeeper.KeeperException;-import org.junit.After;-import org.junit.Before;+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -36,29 +35,25 @@ public class RollingRestartTest extends AbstractFullDistribZkTestBase {private static final long MAX_WAIT_TIME = TimeUnit.NANOSECONDS.convert(300, TimeUnit.SECONDS);public RollingRestartTest() {- fixShardCount = true;sliceCount = 2;- shardCount = TEST_NIGHTLY ? 16 : 2;+ fixShardCount(TEST_NIGHTLY ? 16 : 2);}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));useFactory("solr.StandardDirectoryFactory");}@Override- @After- public void tearDown() throws Exception {+ public void distribTearDown() throws Exception {System.clearProperty("numShards");- super.tearDown();- resetExceptionIgnores();+ super.distribTearDown();}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {waitForRecoveriesToFinish(false);restartWithRolesTest();@@ -75,11 +70,11 @@ public class RollingRestartTest extends AbstractFullDistribZkTestBase {cloudClient.getZkStateReader().getZkClient().printLayoutToStdOut();int numDesignateOverseers = TEST_NIGHTLY ? 16 : 2;- numDesignateOverseers = Math.max(shardCount, numDesignateOverseers);+ numDesignateOverseers = Math.max(getShardCount(), numDesignateOverseers);List<String> designates = new ArrayList<>();List<CloudJettyRunner> designateJettys = new ArrayList<>();for (int i = 0; i < numDesignateOverseers; i++) {- int n = random().nextInt(shardCount);+ int n = random().nextInt(getShardCount());String nodeName = cloudJettys.get(n).nodeName;log.info("Chose {} as overseer designate", nodeName);invokeCollectionApi(CollectionParams.ACTION, CollectionParams.CollectionAction.ADDROLE.toLower(), "role", "overseer", "node", nodeName);diff --git a/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java b/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.javaindex fff1bf4faff..ee6fddcb8ff 100644--- a/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java@@ -41,6 +41,7 @@ import org.apache.solr.common.params.SolrParams;import org.apache.solr.util.SSLTestConfig;import org.apache.solr.SolrTestCaseJ4.SuppressSSL;import org.apache.lucene.util.LuceneTestCase.Slow;+import org.junit.Test;/*** We want to make sure that when migrating between http and https modes the@@ -51,9 +52,9 @@ import org.apache.lucene.util.LuceneTestCase.Slow;@SuppressSSL@BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-6213")public class SSLMigrationTest extends AbstractFullDistribZkTestBase {-- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {//Migrate from HTTP -> HTTPS -> HTTPassertReplicaInformation("http");testMigrateSSL(new SSLTestConfig(true, false));@@ -118,4 +119,4 @@ public class SSLMigrationTest extends AbstractFullDistribZkTestBase {new LBHttpSolrClient(urls.toArray(new String[]{})).request(request);}-}\ No newline at end of file+}diff --git a/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java b/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.javaindex 99a04d91dfa..fdb08711069 100644--- a/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java@@ -18,6 +18,7 @@ package org.apache.solr.cloud;*/import org.junit.BeforeClass;+import org.junit.Test;public class ShardRoutingCustomTest extends AbstractFullDistribZkTestBase {@@ -34,8 +35,8 @@ public class ShardRoutingCustomTest extends AbstractFullDistribZkTestBase {sliceCount = 0;}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {boolean testFinished = false;try {doCustomSharding();diff --git a/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java b/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.javaindex 0171c3a6fb2..a3c7c0034e7 100644--- a/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java@@ -23,6 +23,7 @@ import org.apache.solr.client.solrj.request.UpdateRequest;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.params.ShardParams;import org.junit.BeforeClass;+import org.junit.Test;import java.util.List;import java.util.Map;@@ -49,8 +50,6 @@ public class ShardRoutingTest extends AbstractFullDistribZkTestBase {public ShardRoutingTest() {schemaString = "schema15.xml"; // we need a string idsuper.sliceCount = 4;- super.shardCount = 8;- super.fixShardCount = true; // we only want to test with exactly 4 slices.// from negative to positive, the upper bits of the hash ranges should be// shard1: top bits:10 80000000:bfffffff@@ -92,8 +91,9 @@ public class ShardRoutingTest extends AbstractFullDistribZkTestBase {***/}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 8)+ public void test() throws Exception {boolean testFinished = false;try {handle.clear();diff --git a/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java b/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.javaindex 62cf546d699..d092e13f44d 100644--- a/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java@@ -39,8 +39,7 @@ import org.apache.solr.common.cloud.ZkNodeProps;import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.params.CollectionParams;import org.apache.solr.common.params.ModifiableSolrParams;-import org.junit.After;-import org.junit.Before;+import org.junit.Test;import java.io.IOException;import java.util.ArrayList;@@ -66,33 +65,14 @@ public class ShardSplitTest extends BasicDistributedZkTest {}@Override- @Before- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("numShards", Integer.toString(sliceCount));System.setProperty("solr.xml.persist", "true");}- @Override- @After- public void tearDown() throws Exception {- if (VERBOSE || printLayoutOnTearDown) {- super.printLayout();- }- if (controlClient != null) {- controlClient.shutdown();- }- if (cloudClient != null) {- cloudClient.shutdown();- }- if (controlClientCloud != null) {- controlClientCloud.shutdown();- }- super.tearDown();- }-- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {waitForThingsToLevelOut(15);if (usually()) {diff --git a/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java b/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.javaindex c9347ff9663..8c15a62421c 100644--- a/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java@@ -49,6 +49,7 @@ import org.apache.solr.util.DefaultSolrThreadFactory;import org.junit.AfterClass;import org.junit.Before;import org.junit.BeforeClass;+import org.junit.Test;import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;@@ -80,10 +81,9 @@ public class SharedFSAutoReplicaFailoverTest extends AbstractFullDistribZkTestBadfsCluster = null;}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();useJettyDataDir = false;System.setProperty("solr.xml.persist", "true");}@@ -94,18 +94,16 @@ public class SharedFSAutoReplicaFailoverTest extends AbstractFullDistribZkTestBapublic SharedFSAutoReplicaFailoverTest() {- fixShardCount = true;-sliceCount = 2;- shardCount = 4;completionService = new ExecutorCompletionService<>(executor);pending = new HashSet<>();checkCreatedVsState = false;}-- @Override- public void doTest() throws Exception {++ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {try {testBasics();} finally {@@ -238,8 +236,8 @@ public class SharedFSAutoReplicaFailoverTest extends AbstractFullDistribZkTestBa}@Override- public void tearDown() throws Exception {- super.tearDown();+ public void distribTearDown() throws Exception {+ super.distribTearDown();System.clearProperty("solr.xml.persist");}}diff --git a/solr/core/src/test/org/apache/solr/cloud/SimpleCollectionCreateDeleteTest.java b/solr/core/src/test/org/apache/solr/cloud/SimpleCollectionCreateDeleteTest.javaindex bf50d8d37cc..05611835e7b 100644--- a/solr/core/src/test/org/apache/solr/cloud/SimpleCollectionCreateDeleteTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/SimpleCollectionCreateDeleteTest.java@@ -22,17 +22,17 @@ import org.apache.solr.client.solrj.request.QueryRequest;import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;+import org.junit.Test;public class SimpleCollectionCreateDeleteTest extends AbstractFullDistribZkTestBase {public SimpleCollectionCreateDeleteTest() {- fixShardCount = true;sliceCount = 1;- shardCount = 1;}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 1)+ public void test() throws Exception {String overseerNode = OverseerCollectionProcessor.getLeaderNode(cloudClient.getZkStateReader().getZkClient());String notOverseerNode = null;for (CloudJettyRunner cloudJetty : cloudJettys) {diff --git a/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java b/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.javaindex ef2278fa23a..5df99cd5747 100644--- a/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java@@ -32,10 +32,9 @@ import org.apache.solr.common.cloud.Slice;import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.params.CollectionParams.CollectionAction;import org.apache.solr.common.params.ModifiableSolrParams;-import org.junit.After;import org.junit.AfterClass;-import org.junit.Before;import org.junit.BeforeClass;+import org.junit.Test;import java.io.IOException;import java.util.ArrayList;@@ -61,33 +60,30 @@ public class SyncSliceTest extends AbstractFullDistribZkTestBase {}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();// we expect this time of exception as shards go up and down...//ignoreException(".*");System.setProperty("numShards", Integer.toString(sliceCount));}@Override- @After- public void tearDown() throws Exception {+ public void distribTearDown() throws Exception {if (!success) {printLayoutOnTearDown = true;}- super.tearDown();- resetExceptionIgnores();+ super.distribTearDown();}public SyncSliceTest() {super();sliceCount = 1;- shardCount = TEST_NIGHTLY ? 7 : 4;+ fixShardCount(TEST_NIGHTLY ? 7 : 4);}-- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {handle.clear();handle.put("timestamp", SKIPVAL);@@ -160,7 +156,7 @@ public class SyncSliceTest extends AbstractFullDistribZkTestBase {Set<CloudJettyRunner> jetties = new HashSet<>();jetties.addAll(shardToJetty.get("shard1"));jetties.remove(leaderJetty);- assertEquals(shardCount - 1, jetties.size());+ assertEquals(getShardCount() - 1, jetties.size());chaosMonkey.killJetty(leaderJetty);@@ -224,7 +220,7 @@ public class SyncSliceTest extends AbstractFullDistribZkTestBase {jetties = new HashSet<>();jetties.addAll(shardToJetty.get("shard1"));jetties.remove(leaderJetty);- assertEquals(shardCount - 1, jetties.size());+ assertEquals(getShardCount() - 1, jetties.size());// kill the current leaderdiff --git a/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java b/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.javaindex 5c0d4b77c7e..8b14bfc8b54 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java@@ -16,8 +16,6 @@*/package org.apache.solr.cloud;-import org.apache.commons.collections.CollectionUtils;-import org.apache.lucene.util.CollectionUtil;import org.apache.lucene.util.TestUtil;import org.apache.solr.SolrTestCaseJ4.SuppressSSL;import org.apache.solr.client.solrj.SolrServerException;@@ -38,6 +36,7 @@ import org.apache.commons.lang.StringUtils;import org.junit.BeforeClass;+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -95,8 +94,8 @@ public class TestCloudPivotFacet extends AbstractFullDistribZkTestBase {log.info("init'ing useFieldRandomizedFactor = {}", useFieldRandomizedFactor);}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {sanityCheckAssertDoubles();diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java b/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.javaindex 929204832c2..4672811e60c 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java@@ -33,7 +33,7 @@ import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.params.ShardParams;import org.apache.solr.common.util.NamedList;import org.apache.zookeeper.KeeperException;-import org.junit.Before;+import org.junit.Test;import static org.apache.solr.cloud.OverseerCollectionProcessor.SHARD_UNIQUE;@@ -54,16 +54,14 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {}@Override- @Before- public void setUp() throws Exception {- fixShardCount = true;+ public void distribSetUp() throws Exception {sliceCount = 2;- shardCount = 2;- super.setUp();+ super.distribSetUp();}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 2)+ public void test() throws Exception {CloudSolrClient client = createCloudClient(null);try {createCollection(null, COLLECTION_NAME, 2, 2, 2, client, null, "conf1");diff --git a/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java b/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.javaindex 8238a04b7db..751c6a06cab 100755--- a/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java@@ -24,6 +24,7 @@ import org.apache.solr.common.SolrDocument;import org.apache.solr.common.SolrException;import org.apache.solr.common.util.StrUtils;import org.junit.BeforeClass;+import org.junit.Test;import java.util.HashMap;import java.util.HashSet;@@ -53,8 +54,6 @@ public class TestDistribDocBasedVersion extends AbstractFullDistribZkTestBase {public TestDistribDocBasedVersion() {schemaString = "schema15.xml"; // we need a string idsuper.sliceCount = 2;- super.shardCount = 4;- super.fixShardCount = true; // we only want to test with exactly 2 slices./***@@ -87,8 +86,9 @@ public class TestDistribDocBasedVersion extends AbstractFullDistribZkTestBase {***/}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {boolean testFinished = false;try {handle.clear();@@ -346,10 +346,4 @@ public class TestDistribDocBasedVersion extends AbstractFullDistribZkTestBase {req.setParams(params(reqParams));req.process(cloudClient);}-- @Override- public void tearDown() throws Exception {- super.tearDown();- }-}diff --git a/solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.java b/solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.javaindex 21e819b1554..dff071d473a 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.java@@ -27,7 +27,7 @@ import org.apache.solr.common.params.CollectionParams;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;import org.apache.zookeeper.KeeperException;-import org.junit.Before;+import org.junit.Test;import java.io.IOException;import java.util.ArrayList;@@ -42,15 +42,7 @@ public class TestRebalanceLeaders extends AbstractFullDistribZkTestBase {public TestRebalanceLeaders() {schemaString = "schema15.xml"; // we need a string id- }-- @Override- @Before- public void setUp() throws Exception {- fixShardCount = true;sliceCount = 4;- shardCount = 4;- super.setUp();}int reps = 10;@@ -60,8 +52,9 @@ public class TestRebalanceLeaders extends AbstractFullDistribZkTestBase {Map<String, Replica> expected = new HashMap<>();- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {CloudSolrClient client = createCloudClient(null);reps = random().nextInt(9) + 1; // make sure and do at least one.try {diff --git a/solr/core/src/test/org/apache/solr/cloud/TestReplicaProperties.java b/solr/core/src/test/org/apache/solr/cloud/TestReplicaProperties.javaindex 5c854fa5d2a..767f0dc17e4 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestReplicaProperties.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestReplicaProperties.java@@ -36,7 +36,7 @@ import org.apache.solr.common.params.CollectionParams;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;import org.apache.zookeeper.KeeperException;-import org.junit.Before;+import org.junit.Test;@Slowpublic class TestReplicaProperties extends ReplicaPropertiesBase {@@ -45,19 +45,12 @@ public class TestReplicaProperties extends ReplicaPropertiesBase {public TestReplicaProperties() {schemaString = "schema15.xml"; // we need a string id- }-- @Override- @Before- public void setUp() throws Exception {- fixShardCount = true;sliceCount = 2;- shardCount = 4;- super.setUp();}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {CloudSolrClient client = createCloudClient(null);try {// Mix up a bunch of different combinations of shards and replicas in order to exercise boundary cases.diff --git a/solr/core/src/test/org/apache/solr/cloud/TestRequestStatusCollectionAPI.java b/solr/core/src/test/org/apache/solr/cloud/TestRequestStatusCollectionAPI.javaindex a852c2ccf8a..639bc78e30a 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestRequestStatusCollectionAPI.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestRequestStatusCollectionAPI.java@@ -24,7 +24,7 @@ import org.apache.solr.client.solrj.request.QueryRequest;import org.apache.solr.common.params.CollectionParams;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;-import org.junit.Before;+import org.junit.Test;import java.io.IOException;@@ -36,14 +36,8 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {schemaString = "schema15.xml"; // we need a string id}- @Override- @Before- public void setUp() throws Exception {- super.setUp();-- }-- public void doTest() {+ @Test+ public void test() throws Exception {ModifiableSolrParams params = new ModifiableSolrParams();params.set(CollectionParams.ACTION, CollectionParams.CollectionAction.CREATE.toString());diff --git a/solr/core/src/test/org/apache/solr/cloud/TestShortCircuitedRequests.java b/solr/core/src/test/org/apache/solr/cloud/TestShortCircuitedRequests.javaindex 8886ec4a6b2..babc51d69d5 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestShortCircuitedRequests.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestShortCircuitedRequests.java@@ -23,18 +23,18 @@ import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.cloud.Replica;import org.apache.solr.common.params.ShardParams;import org.apache.solr.common.util.NamedList;+import org.junit.Test;public class TestShortCircuitedRequests extends AbstractFullDistribZkTestBase {public TestShortCircuitedRequests() {schemaString = "schema15.xml"; // we need a string idsuper.sliceCount = 4;- super.shardCount = 4;- super.fixShardCount = true; // we only want to test with exactly 4 slices.}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {waitForRecoveriesToFinish(false);assertEquals(4, cloudClient.getZkStateReader().getClusterState().getCollection(DEFAULT_COLLECTION).getSlices().size());index("id", "a!doc1"); // shard3diff --git a/solr/core/src/test/org/apache/solr/cloud/TriLevelCompositeIdRoutingTest.java b/solr/core/src/test/org/apache/solr/cloud/TriLevelCompositeIdRoutingTest.javaindex 9419c53845a..a2065fc5e16 100644--- a/solr/core/src/test/org/apache/solr/cloud/TriLevelCompositeIdRoutingTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/TriLevelCompositeIdRoutingTest.java@@ -21,6 +21,7 @@ import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.SolrDocument;import org.junit.BeforeClass;+import org.junit.Test;import java.util.HashMap;import java.util.HashSet;@@ -47,14 +48,12 @@ public class TriLevelCompositeIdRoutingTest extends ShardRoutingTest {public TriLevelCompositeIdRoutingTest() {schemaString = "schema15.xml"; // we need a string id- super.sliceCount = TEST_NIGHTLY ? 12 : 2; // a lot of slices for more ranges and buckets- super.shardCount = TEST_NIGHTLY ? 24 : 3;- super.fixShardCount = true;-+ sliceCount = TEST_NIGHTLY ? 12 : 2; // a lot of slices for more ranges and buckets+ fixShardCount(TEST_NIGHTLY ? 24 : 3);}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {boolean testFinished = false;try {handle.clear();@@ -74,7 +73,6 @@ public class TriLevelCompositeIdRoutingTest extends ShardRoutingTest {}}-private void doTriLevelHashingTest() throws Exception {log.info("### STARTING doTriLevelHashingTest");// for now, we know how ranges will be distributed to shards.@@ -153,10 +151,4 @@ public class TriLevelCompositeIdRoutingTest extends ShardRoutingTest {private String getKey(String id) {return id.substring(0, id.lastIndexOf('!'));}-- @Override- public void tearDown() throws Exception {- super.tearDown();- }-}diff --git a/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.javaindex 095f9d4e139..f0ecb026204 100644--- a/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java@@ -31,8 +31,7 @@ import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.update.DirectUpdateHandler2;import org.apache.solr.util.DefaultSolrThreadFactory;-import org.junit.Before;-import org.junit.BeforeClass;+import org.junit.Test;import java.io.File;import java.io.IOException;@@ -48,17 +47,6 @@ import java.util.concurrent.TimeUnit;@Slow@SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776")public class UnloadDistributedZkTest extends BasicDistributedZkTest {-- @BeforeClass- public static void beforeThisClass3() throws Exception {-- }-- @Before- @Override- public void setUp() throws Exception {- super.setUp();- }protected String getSolrXml() {return "solr-no-core.xml";@@ -68,9 +56,9 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {super();checkCreatedVsState = false;}-- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {testCoreUnloadAndLeaders(); // longtestUnloadLotsOfCores(); // long@@ -427,13 +415,4 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {executor.awaitTermination(120, TimeUnit.SECONDS);adminClient.shutdown();}------ @Override- public void tearDown() throws Exception {- super.tearDown();- }}diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsChaosMonkeySafeLeaderTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsChaosMonkeySafeLeaderTest.javaindex c39de4e6bd7..eb4a48bfea5 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsChaosMonkeySafeLeaderTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsChaosMonkeySafeLeaderTest.java@@ -23,7 +23,6 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.cloud.ChaosMonkeySafeLeaderTest;import org.junit.AfterClass;-import org.junit.Before;import org.junit.BeforeClass;import com.carrotsearch.randomizedtesting.annotations.Nightly;@@ -47,10 +46,9 @@ public class HdfsChaosMonkeySafeLeaderTest extends ChaosMonkeySafeLeaderTest {dfsCluster = null;}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();// super class may hard code directoryuseFactory("org.apache.solr.core.HdfsDirectoryFactory");diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsSyncSliceTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsSyncSliceTest.javaindex 8f51c1ae2ee..13d9cffe46e 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsSyncSliceTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsSyncSliceTest.java@@ -23,7 +23,6 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.cloud.SyncSliceTest;import org.junit.AfterClass;-import org.junit.Before;import org.junit.BeforeClass;import com.carrotsearch.randomizedtesting.annotations.Nightly;@@ -46,14 +45,7 @@ public class HdfsSyncSliceTest extends SyncSliceTest {HdfsTestUtil.teardownClass(dfsCluster);dfsCluster = null;}-- @Before- @Override- public void setUp() throws Exception {- super.setUp();- }-@Overrideprotected String getDataDir(String dataDir) throws IOException {return HdfsTestUtil.getDataDir(dfsCluster, dataDir);diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsWriteToMultipleCollectionsTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsWriteToMultipleCollectionsTest.javaindex 0d9ae42ba7b..b0126a2f19f 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsWriteToMultipleCollectionsTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsWriteToMultipleCollectionsTest.java@@ -40,6 +40,7 @@ import org.apache.solr.store.blockcache.Cache;import org.apache.solr.util.RefCounted;import org.junit.AfterClass;import org.junit.BeforeClass;+import org.junit.Test;import java.io.IOException;import java.util.ArrayList;@@ -77,15 +78,15 @@ public class HdfsWriteToMultipleCollectionsTest extends BasicDistributedZkTest {public HdfsWriteToMultipleCollectionsTest() {super();sliceCount = 1;- shardCount = 3;+ fixShardCount(3);}protected String getSolrXml() {return "solr-no-core.xml";}-- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {int docCount = random().nextInt(1313) + 1;int cnt = random().nextInt(4) + 1;for (int i = 0; i < cnt; i++) {diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.javaindex cdbd348fd89..23fcd5acaea 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java@@ -48,6 +48,7 @@ import org.junit.BeforeClass;import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import org.junit.Test;@Slow@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s)@@ -80,16 +81,16 @@ public class StressHdfsTest extends BasicDistributedZkTest {public StressHdfsTest() {super();sliceCount = 1;- shardCount = TEST_NIGHTLY ? 7 : random().nextInt(2) + 1;+ fixShardCount(TEST_NIGHTLY ? 7 : random().nextInt(2) + 1);testRestartIntoSafeMode = random().nextBoolean();}protected String getSolrXml() {return "solr-no-core.xml";}-- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {randomlyEnableAutoSoftCommit();int cnt = random().nextInt(2) + 1;@@ -138,11 +139,11 @@ public class StressHdfsTest extends BasicDistributedZkTest {int nShards;int maxReplicasPerNode;if (overshard) {- nShards = shardCount * 2;+ nShards = getShardCount() * 2;maxReplicasPerNode = 8;rep = 1;} else {- nShards = shardCount / 2;+ nShards = getShardCount() / 2;maxReplicasPerNode = 1;rep = 2;if (nShards == 0) nShards = 1;diff --git a/solr/core/src/test/org/apache/solr/core/TestDynamicLoading.java b/solr/core/src/test/org/apache/solr/core/TestDynamicLoading.javaindex a679e7430b2..d46d474601c 100644--- a/solr/core/src/test/org/apache/solr/core/TestDynamicLoading.java+++ b/solr/core/src/test/org/apache/solr/core/TestDynamicLoading.java@@ -26,7 +26,7 @@ import org.apache.solr.handler.TestBlobHandler;import org.apache.solr.util.RESTfulServerProvider;import org.apache.solr.util.RestTestHarness;import org.apache.solr.util.SimplePostTool;-import org.junit.After;+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -57,21 +57,17 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {}}- @After- public void testDown() throws Exception {- super.tearDown();+ @Override+ public void distribTearDown() throws Exception {+ super.distribTearDown();for (RestTestHarness r : restTestHarnesses) {r.close();}}- @Override- public void doTest() throws Exception {- setupHarnesses();- dynamicLoading();- }-- private void dynamicLoading() throws Exception {+ @Test+ public void testDynamicLoading() throws Exception {+ setupHarnesses();String payload = "{\n" +"'create-requesthandler' : { 'name' : '/test1', 'class': 'org.apache.solr.core.BlobStoreTestRequestHandler' , 'lib':'test','version':'1'}\n" +"}";diff --git a/solr/core/src/test/org/apache/solr/handler/TestBlobHandler.java b/solr/core/src/test/org/apache/solr/handler/TestBlobHandler.javaindex f912b444297..4d14b172cc8 100644--- a/solr/core/src/test/org/apache/solr/handler/TestBlobHandler.java+++ b/solr/core/src/test/org/apache/solr/handler/TestBlobHandler.java@@ -37,6 +37,7 @@ import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.core.ConfigOverlay;import org.apache.solr.update.DirectUpdateHandler2;import org.apache.solr.util.SimplePostTool;+import org.junit.Test;import org.noggit.JSONParser;import org.noggit.ObjectBuilder;import org.slf4j.Logger;@@ -48,17 +49,16 @@ import java.nio.ByteBuffer;import java.nio.charset.StandardCharsets;import java.text.MessageFormat;import java.util.Arrays;-import java.util.Collections;import java.util.List;import java.util.Map;-import java.util.concurrent.TimeUnit;import static org.apache.solr.core.ConfigOverlay.getObjectByPath;public class TestBlobHandler extends AbstractFullDistribZkTestBase {static final Logger log = LoggerFactory.getLogger(TestBlobHandler.class);- private void doBlobHandlerTest() throws Exception {+ @Test+ public void doBlobHandlerTest() throws Exception {SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)));try {CollectionAdminResponse response1;@@ -116,8 +116,8 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {}@Override- public void tearDown() throws Exception {- super.tearDown();+ public void distribTearDown() throws Exception {+ super.distribTearDown();System.clearProperty("numShards");System.clearProperty("zkHost");@@ -194,10 +194,4 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {httpPost.releaseConnection();}}-- @Override- public void doTest() throws Exception {- doBlobHandlerTest();-- }}diff --git a/solr/core/src/test/org/apache/solr/handler/TestConfigReload.java b/solr/core/src/test/org/apache/solr/handler/TestConfigReload.javaindex e1ff1415515..506c028c37f 100644--- a/solr/core/src/test/org/apache/solr/handler/TestConfigReload.java+++ b/solr/core/src/test/org/apache/solr/handler/TestConfigReload.java@@ -47,7 +47,7 @@ import org.apache.solr.util.RestTestHarness;import org.apache.zookeeper.CreateMode;import org.apache.zookeeper.KeeperException;import org.apache.zookeeper.data.Stat;-import org.junit.After;+import org.junit.Test;import org.noggit.JSONParser;import org.noggit.ObjectBuilder;import org.slf4j.Logger;@@ -71,16 +71,16 @@ public class TestConfigReload extends AbstractFullDistribZkTestBase {}}- @After- public void tearDown() throws Exception {- super.tearDown();+ @Override+ public void distribTearDown() throws Exception {+ super.distribTearDown();for (RestTestHarness h : restTestHarnesses) {h.close();}}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {setupHarnesses();try {reloadTest();diff --git a/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java b/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.javaindex 774ecdac367..1c5b62c6476 100644--- a/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java+++ b/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java@@ -20,7 +20,6 @@ package org.apache.solr.handler;import java.text.MessageFormat;import java.util.ArrayList;-import java.util.Arrays;import java.util.List;import java.util.Map;import java.util.Objects;@@ -37,7 +36,7 @@ import org.apache.solr.core.RequestParams;import org.apache.solr.core.TestSolrConfigHandler;import org.apache.solr.util.RESTfulServerProvider;import org.apache.solr.util.RestTestHarness;-import org.junit.After;+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -59,17 +58,17 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {restTestHarnesses.add(harness);}}-- @After- public void tearDown() throws Exception {- super.tearDown();++ @Override+ public void distribTearDown() throws Exception {+ super.distribTearDown();for (RestTestHarness r : restTestHarnesses) {r.close();}}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {setupHarnesses();testReqHandlerAPIs();testReqParams();diff --git a/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerConcurrent.java b/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerConcurrent.javaindex f2473866c01..bae4ab5caa8 100644--- a/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerConcurrent.java+++ b/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerConcurrent.java@@ -46,7 +46,7 @@ import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.core.ConfigOverlay;import org.apache.solr.util.RESTfulServerProvider;import org.apache.solr.util.RestTestHarness;-import org.junit.After;+import org.junit.Test;import org.noggit.JSONParser;import org.noggit.ObjectBuilder;import org.slf4j.Logger;@@ -70,17 +70,17 @@ public class TestSolrConfigHandlerConcurrent extends AbstractFullDistribZkTestBarestTestHarnesses.add(harness);}}-- @After- public void tearDown() throws Exception {- super.tearDown();++ @Override+ public void distribTearDown() throws Exception {+ super.distribTearDown();for (RestTestHarness h : restTestHarnesses) {h.close();}}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {Map editable_prop_map = (Map) new ObjectBuilder(new JSONParser(new StringReader(ConfigOverlay.MAPPING))).getObject();Map caches = (Map) editable_prop_map.get("query");diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedExpandComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedExpandComponentTest.javaindex 9cd6f52c016..a2d48809d86 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedExpandComponentTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedExpandComponentTest.java@@ -21,12 +21,10 @@ import org.apache.solr.BaseDistributedSearchTestCase;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.SolrDocument;import org.apache.solr.common.SolrDocumentList;-import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.ModifiableSolrParams;-import org.apache.solr.common.util.NamedList;import org.junit.BeforeClass;+import org.junit.Test;-import java.nio.ByteBuffer;import java.util.Map;import java.util.Iterator;@@ -38,8 +36,6 @@ import java.util.Iterator;public class DistributedExpandComponentTest extends BaseDistributedSearchTestCase {public DistributedExpandComponentTest() {- fixShardCount = true;- shardCount = 3;stress = 0;}@@ -48,8 +44,9 @@ public class DistributedExpandComponentTest extends BaseDistributedSearchTestCasinitCore("solrconfig-collapseqparser.xml", "schema11.xml");}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 3)+ public void test() throws Exception {final String group = (random().nextBoolean() ? "group_s" : "group_s_dv");del("*:*");diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLargeTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLargeTest.javaindex 17f0030fc5c..6c9da194ad7 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLargeTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLargeTest.java@@ -32,18 +32,15 @@ import org.apache.solr.common.params.FacetParams;import org.apache.solr.common.params.SolrParams;import junit.framework.AssertionFailedError;+import org.junit.Test;public class DistributedFacetPivotLargeTest extends BaseDistributedSearchTestCase {public static final String SPECIAL = "";- public DistributedFacetPivotLargeTest() {- this.fixShardCount = true;- this.shardCount = 4; // we leave one empty as an edge case- }-- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {this.stress = 0 ;handle.clear();handle.put("QTime", SKIPVAL);diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLongTailTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLongTailTest.javaindex d675d8e7a99..350a4f7f9e7 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLongTailTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLongTailTest.java@@ -26,6 +26,7 @@ import org.apache.solr.client.solrj.response.PivotField;import org.apache.solr.common.params.FacetParams;import org.apache.solr.common.params.SolrParams;import org.apache.solr.common.params.ModifiableSolrParams;+import org.junit.Test;/*** test demonstrating how overrequesting helps finds top-terms in the "long tail"@@ -39,11 +40,6 @@ import org.apache.solr.common.params.ModifiableSolrParams;*/public class DistributedFacetPivotLongTailTest extends BaseDistributedSearchTestCase {- public DistributedFacetPivotLongTailTest(){- this.fixShardCount = true;- this.shardCount = 3;- }-private int docNumber = 0;public int getDocNum() {@@ -51,8 +47,9 @@ public class DistributedFacetPivotLongTailTest extends BaseDistributedSearchTestreturn docNumber;}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 3)+ public void test() throws Exception {final SolrClient shard0 = clients.get(0);final SolrClient shard1 = clients.get(1);diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallAdvancedTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallAdvancedTest.javaindex e269dea74b8..64cc0f94d09 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallAdvancedTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallAdvancedTest.java@@ -25,6 +25,7 @@ import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.params.FacetParams;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.params.SolrParams;+import org.junit.Test;import java.util.List;@@ -37,13 +38,9 @@ import java.util.List;*/public class DistributedFacetPivotSmallAdvancedTest extends BaseDistributedSearchTestCase {- public DistributedFacetPivotSmallAdvancedTest() {- this.fixShardCount = true;- this.shardCount = 2;- }-- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 2)+ public void test() throws Exception {del("*:*");final SolrClient shard0 = clients.get(0);diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallTest.javaindex 1407a80fa42..19baf831eb4 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallTest.java@@ -32,16 +32,13 @@ import org.apache.solr.common.params.SolrParams;import org.apache.solr.common.params.ModifiableSolrParams;import junit.framework.AssertionFailedError;+import org.junit.Test;public class DistributedFacetPivotSmallTest extends BaseDistributedSearchTestCase {-- public DistributedFacetPivotSmallTest() {- this.fixShardCount = true;- this.shardCount = 4;- }-- @Override- public void doTest() throws Exception {++ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {del("*:*");diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotWhiteBoxTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotWhiteBoxTest.javaindex d17af16e13e..8fbfe5a366f 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotWhiteBoxTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotWhiteBoxTest.java@@ -22,18 +22,15 @@ import org.apache.solr.client.solrj.response.PivotField;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.params.SolrParams;+import org.junit.Test;import java.util.List;public class DistributedFacetPivotWhiteBoxTest extends BaseDistributedSearchTestCase {- public DistributedFacetPivotWhiteBoxTest() {- this.fixShardCount = true;- this.shardCount = 4;- }-- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {del("*:*");diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedMLTComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedMLTComponentTest.javaindex 19449273116..6bf513676d6 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedMLTComponentTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedMLTComponentTest.java@@ -20,8 +20,8 @@ package org.apache.solr.handler.component;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.BaseDistributedSearchTestCase;import org.apache.solr.common.params.MoreLikeThisParams;-import org.junit.BeforeClass;import org.junit.Ignore;+import org.junit.Test;/*** Test for distributed MoreLikeThisComponent's@@ -38,29 +38,18 @@ public class DistributedMLTComponentTest extends BaseDistributedSearchTestCase {public DistributedMLTComponentTest(){- fixShardCount=true;- shardCount=3;stress=0;}- @BeforeClass- public static void beforeClass() throws Exception {-- }-@Override- public void setUp() throws Exception {+ public void distribSetUp() throws Exception {requestHandlerName = "mltrh";- super.setUp();+ super.distribSetUp();}- @Override- public void tearDown() throws Exception {- super.tearDown();- }-- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 3)+ public void test() throws Exception {del("*:*");index(id, "1", "lowerfilt", "toyota");index(id, "2", "lowerfilt", "chevrolet");diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentCustomSortTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentCustomSortTest.javaindex 883946a57a3..20a57dbaba0 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentCustomSortTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentCustomSortTest.java@@ -19,9 +19,8 @@ package org.apache.solr.handler.component;import org.apache.solr.BaseDistributedSearchTestCase;import org.apache.solr.client.solrj.response.QueryResponse;-import org.apache.solr.common.SolrDocument;-import org.apache.solr.common.SolrDocumentList;import org.junit.BeforeClass;+import org.junit.Test;import java.nio.ByteBuffer;@@ -33,8 +32,6 @@ import java.nio.ByteBuffer;public class DistributedQueryComponentCustomSortTest extends BaseDistributedSearchTestCase {public DistributedQueryComponentCustomSortTest() {- fixShardCount = true;- shardCount = 3;stress = 0;}@@ -43,8 +40,9 @@ public class DistributedQueryComponentCustomSortTest extends BaseDistributedSearinitCore("solrconfig.xml", "schema-custom-field.xml");}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 3)+ public void test() throws Exception {del("*:*");index(id, "1", "text", "a", "payload", ByteBuffer.wrap(new byte[] { 0x12, 0x62, 0x15 }), // 2diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.javaindex 158a32a35fa..ed328fb75e8 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.java@@ -20,11 +20,11 @@ package org.apache.solr.handler.component;import org.apache.solr.BaseDistributedSearchTestCase;import org.apache.solr.client.solrj.SolrServerException;import org.apache.solr.client.solrj.response.QueryResponse;-import org.apache.solr.cloud.AbstractFullDistribZkTestBase;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.params.ShardParams;import org.apache.solr.common.util.SimpleOrderedMap;import org.junit.BeforeClass;+import org.junit.Test;import java.nio.ByteBuffer;import java.util.Map;@@ -40,8 +40,6 @@ import java.util.Map;public class DistributedQueryComponentOptimizationTest extends BaseDistributedSearchTestCase {public DistributedQueryComponentOptimizationTest() {- fixShardCount = true;- shardCount = 3;stress = 0;}@@ -50,8 +48,9 @@ public class DistributedQueryComponentOptimizationTest extends BaseDistributedSeinitCore("solrconfig.xml", "schema-custom-field.xml");}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 3)+ public void test() throws Exception {del("*:*");index(id, "1", "text", "a", "test_sS", "21", "payload", ByteBuffer.wrap(new byte[] { 0x12, 0x62, 0x15 }), // 2diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryElevationComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryElevationComponentTest.javaindex 19dfb32abdb..e8e908d4740 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryElevationComponentTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryElevationComponentTest.java@@ -26,6 +26,7 @@ import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.params.CommonParams;import org.junit.AfterClass;import org.junit.BeforeClass;+import org.junit.Test;/***@@ -39,8 +40,6 @@ public class DistributedQueryElevationComponentTest extends BaseDistributedSearc}public DistributedQueryElevationComponentTest() {- fixShardCount = true;- shardCount = 3;stress = 0;// TODO: a better way to do this?@@ -59,8 +58,9 @@ public class DistributedQueryElevationComponentTest extends BaseDistributedSearcSystem.clearProperty("elevate.data.file");}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 3)+ public void test() throws Exception {del("*:*");diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.javaindex fedc9455c2f..bbf53589fd2 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java@@ -32,6 +32,7 @@ import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.params.SpellingParams;import org.apache.solr.common.util.NamedList;import org.junit.BeforeClass;+import org.junit.Test;/*** Test for SpellCheckComponent's distributed querying@@ -57,16 +58,6 @@ public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTesuseFactory(null); // need an FS factory}- @Override- public void setUp() throws Exception {- super.setUp();- }-- @Override- public void tearDown() throws Exception {- super.tearDown();- }-private void q(Object... q) throws Exception {final ModifiableSolrParams params = new ModifiableSolrParams();@@ -95,9 +86,9 @@ public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTesAssert.fail("Control data did not return any suggestions.");}}-- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {del("*:*");index(id, "1", "lowerfilt", "toyota");index(id, "2", "lowerfilt", "chevrolet");diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedSuggestComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedSuggestComponentTest.javaindex dc08fb028f5..7f08ecbb7a9 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedSuggestComponentTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedSuggestComponentTest.java@@ -31,6 +31,7 @@ import org.apache.solr.common.util.NamedList;import org.apache.solr.common.util.SimpleOrderedMap;import org.apache.solr.spelling.suggest.SuggesterParams;import org.junit.BeforeClass;+import org.junit.Test;/*** Test for SuggestComponent's distributed querying@@ -54,16 +55,6 @@ public class DistributedSuggestComponentTest extends BaseDistributedSearchTestCauseFactory(null); // need an FS factory}- @Override- public void setUp() throws Exception {- super.setUp();- }-- @Override- public void tearDown() throws Exception {- super.tearDown();- }-@Overridepublic void validateControlData(QueryResponse control) throws Exception{@@ -74,10 +65,10 @@ public class DistributedSuggestComponentTest extends BaseDistributedSearchTestCaif(sc.size() == 0 && command == null) {Assert.fail("Control data did not return any suggestions or execute any command");}- }-- @Override- public void doTest() throws Exception {+ }++ @Test+ public void test() throws Exception {del("*:*");index(id, "1", "cat", "This is another title", "price", "10", "weight", "10");index(id, "2", "cat", "Yet another", "price", "15", "weight", "10");diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.javaindex ee9bfb3d741..ef097601082 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java@@ -18,6 +18,7 @@ package org.apache.solr.handler.component;*/import org.apache.solr.BaseDistributedSearchTestCase;+import org.junit.Test;/*** Test for TermsComponent distributed querying@@ -27,8 +28,8 @@ import org.apache.solr.BaseDistributedSearchTestCase;*/public class DistributedTermsComponentTest extends BaseDistributedSearchTestCase {- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {del("*:*");index(id, 18, "b_t", "snake spider shark snail slug seal");index(id, 19, "b_t", "snake spider shark snail slug");diff --git a/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java b/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.javaindex 5cd77dea595..bc184f848f2 100644--- a/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java@@ -22,6 +22,7 @@ import org.apache.lucene.util.Constants;import org.apache.solr.BaseDistributedSearchTestCase;import org.apache.solr.common.params.TermVectorParams;import org.junit.BeforeClass;+import org.junit.Test;public class TermVectorComponentDistributedTest extends BaseDistributedSearchTestCase {@BeforeClass@@ -30,8 +31,8 @@ public class TermVectorComponentDistributedTest extends BaseDistributedSearchTesConstants.JAVA_VENDOR.startsWith("IBM"));}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {handle.clear();handle.put("timestamp", SKIPVAL);diff --git a/solr/core/src/test/org/apache/solr/schema/TestBulkSchemaConcurrent.java b/solr/core/src/test/org/apache/solr/schema/TestBulkSchemaConcurrent.javaindex 40c2ad6d01a..6caafb7777d 100644--- a/solr/core/src/test/org/apache/solr/schema/TestBulkSchemaConcurrent.java+++ b/solr/core/src/test/org/apache/solr/schema/TestBulkSchemaConcurrent.java@@ -38,8 +38,8 @@ import org.apache.solr.cloud.AbstractFullDistribZkTestBase;import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.util.RESTfulServerProvider;import org.apache.solr.util.RestTestHarness;-import org.junit.After;import org.junit.BeforeClass;+import org.junit.Test;import org.noggit.JSONParser;import org.noggit.ObjectBuilder;import org.slf4j.Logger;@@ -70,17 +70,17 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {restTestHarnesses.add(harness);}}-- @After- public void tearDown() throws Exception {- super.tearDown();++ @Override+ public void distribTearDown() throws Exception {+ super.distribTearDown();for (RestTestHarness r : restTestHarnesses) {r.close();}}-- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {final int threadCount = 5;setupHarnesses();diff --git a/solr/core/src/test/org/apache/solr/schema/TestCloudManagedSchema.java b/solr/core/src/test/org/apache/solr/schema/TestCloudManagedSchema.javaindex 3af081370d9..2254d1f0acf 100644--- a/solr/core/src/test/org/apache/solr/schema/TestCloudManagedSchema.java+++ b/solr/core/src/test/org/apache/solr/schema/TestCloudManagedSchema.java@@ -26,6 +26,7 @@ import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;import org.apache.zookeeper.KeeperException;import org.junit.BeforeClass;+import org.junit.Test;import java.io.IOException;import java.nio.charset.StandardCharsets;@@ -47,9 +48,9 @@ public class TestCloudManagedSchema extends AbstractFullDistribZkTestBase {protected String getCloudSolrConfig() {return "solrconfig-managed-schema.xml";}-- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {ModifiableSolrParams params = new ModifiableSolrParams();params.set(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.STATUS.toString());QueryRequest request = new QueryRequest(params);diff --git a/solr/core/src/test/org/apache/solr/schema/TestCloudManagedSchemaConcurrent.java b/solr/core/src/test/org/apache/solr/schema/TestCloudManagedSchemaConcurrent.javaindex f2a48f1b32a..7fa4b06f551 100644--- a/solr/core/src/test/org/apache/solr/schema/TestCloudManagedSchemaConcurrent.java+++ b/solr/core/src/test/org/apache/solr/schema/TestCloudManagedSchemaConcurrent.java@@ -36,8 +36,8 @@ import org.apache.solr.util.RESTfulServerProvider;import org.apache.solr.util.RestTestHarness;import org.apache.zookeeper.data.Stat;import org.eclipse.jetty.servlet.ServletHolder;-import org.junit.After;import org.junit.BeforeClass;+import org.junit.Test;import org.restlet.ext.servlet.ServerServlet;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -54,10 +54,7 @@ public class TestCloudManagedSchemaConcurrent extends AbstractFullDistribZkTestBpublic TestCloudManagedSchemaConcurrent() {super();- fixShardCount = true;-sliceCount = 4;- shardCount = 8;}@BeforeClass@@ -65,10 +62,10 @@ public class TestCloudManagedSchemaConcurrent extends AbstractFullDistribZkTestBSystem.setProperty("managed.schema.mutable", "true");System.setProperty("enable.update.log", "true");}-- @After- public void tearDown() throws Exception {- super.tearDown();++ @Override+ public void distribTearDown() throws Exception {+ super.distribTearDown();for (RestTestHarness h : restTestHarnesses) {h.close();}@@ -245,10 +242,11 @@ public class TestCloudManagedSchemaConcurrent extends AbstractFullDistribZkTestBreturn expectedAddFieldTypes;}-- @Override- public void doTest() throws Exception {++ @Test+ @ShardsFixed(num = 8)+ public void test() throws Exception {verifyWaitForSchemaUpdateToPropagate();setupHarnesses();concurrentOperationsTest();diff --git a/solr/core/src/test/org/apache/solr/schema/TestCloudSchemaless.java b/solr/core/src/test/org/apache/solr/schema/TestCloudSchemaless.javaindex fd048b72189..1df5640cadc 100644--- a/solr/core/src/test/org/apache/solr/schema/TestCloudSchemaless.java+++ b/solr/core/src/test/org/apache/solr/schema/TestCloudSchemaless.java@@ -29,7 +29,7 @@ import org.apache.solr.util.RestTestHarness;import org.eclipse.jetty.servlet.ServletHolder;import org.junit.After;import org.junit.BeforeClass;-import org.junit.Before;+import org.junit.Test;import org.restlet.ext.servlet.ServerServlet;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -49,11 +49,10 @@ public class TestCloudSchemaless extends AbstractFullDistribZkTestBase {private static final Logger log = LoggerFactory.getLogger(TestCloudManagedSchemaConcurrent.class);private static final String SUCCESS_XPATH = "/response/lst[@name='responseHeader']/int[@name='status'][.='0']";- @Before@Override- public void setUp() throws Exception {+ public void distribSetUp() throws Exception {- super.setUp();+ super.distribSetUp();useJettyDataDir = false;@@ -70,10 +69,7 @@ public class TestCloudSchemaless extends AbstractFullDistribZkTestBase {public TestCloudSchemaless() {schemaString = "schema-add-schema-fields-update-processor.xml";- fixShardCount = true;-sliceCount = 4;- shardCount = 8;}@BeforeClass@@ -122,8 +118,9 @@ public class TestCloudSchemaless extends AbstractFullDistribZkTestBase {return expectedAddFields;}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 8)+ public void test() throws Exception {setupHarnesses();// First, add a bunch of documents in a single update with the same new field.diff --git a/solr/core/src/test/org/apache/solr/search/AnalyticsMergeStrategyTest.java b/solr/core/src/test/org/apache/solr/search/AnalyticsMergeStrategyTest.javaindex 08555638999..f62a8df0134 100644--- a/solr/core/src/test/org/apache/solr/search/AnalyticsMergeStrategyTest.java+++ b/solr/core/src/test/org/apache/solr/search/AnalyticsMergeStrategyTest.java@@ -22,6 +22,7 @@ import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;import org.junit.BeforeClass;+import org.junit.Test;/*** Test for QueryComponent's distributed querying@@ -31,8 +32,6 @@ import org.junit.BeforeClass;public class AnalyticsMergeStrategyTest extends BaseDistributedSearchTestCase {public AnalyticsMergeStrategyTest() {- fixShardCount = true;- shardCount = 3;stress = 0;}@@ -41,8 +40,9 @@ public class AnalyticsMergeStrategyTest extends BaseDistributedSearchTestCase {initCore("solrconfig-analytics-query.xml", "schema15.xml");}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 3)+ public void test() throws Exception {del("*:*");index_specific(0,"id","1", "sort_i", "5");diff --git a/solr/core/src/test/org/apache/solr/search/MergeStrategyTest.java b/solr/core/src/test/org/apache/solr/search/MergeStrategyTest.javaindex 6a9466fd7c9..ee733c42100 100644--- a/solr/core/src/test/org/apache/solr/search/MergeStrategyTest.java+++ b/solr/core/src/test/org/apache/solr/search/MergeStrategyTest.java@@ -21,13 +21,12 @@ import org.apache.solr.BaseDistributedSearchTestCase;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.SolrDocument;import org.apache.solr.common.SolrDocumentList;-import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.ModifiableSolrParams;-import org.apache.solr.common.util.NamedList;import org.apache.solr.handler.component.MergeStrategy;import org.apache.solr.handler.component.ResponseBuilder;import org.apache.solr.handler.component.ShardRequest;import org.junit.BeforeClass;+import org.junit.Test;import java.util.Arrays;@@ -39,8 +38,6 @@ import java.util.Arrays;public class MergeStrategyTest extends BaseDistributedSearchTestCase {public MergeStrategyTest() {- fixShardCount = true;- shardCount = 3;stress = 0;}@@ -49,8 +46,9 @@ public class MergeStrategyTest extends BaseDistributedSearchTestCase {initCore("solrconfig-plugcollector.xml", "schema15.xml");}- @Override- public void doTest() throws Exception {+ @Test+ @ShardsFixed(num = 3)+ public void test() throws Exception {del("*:*");index_specific(0,"id","1", "sort_i", "5");diff --git a/solr/core/src/test/org/apache/solr/search/mlt/CloudMLTQParserTest.java b/solr/core/src/test/org/apache/solr/search/mlt/CloudMLTQParserTest.javaindex 4c58030d462..51cd8abd59f 100644--- a/solr/core/src/test/org/apache/solr/search/mlt/CloudMLTQParserTest.java+++ b/solr/core/src/test/org/apache/solr/search/mlt/CloudMLTQParserTest.java@@ -23,6 +23,7 @@ import org.apache.solr.common.SolrDocument;import org.apache.solr.common.SolrDocumentList;import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.ModifiableSolrParams;+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -35,8 +36,6 @@ public class CloudMLTQParserTest extends AbstractFullDistribZkTestBase {static Logger log = LoggerFactory.getLogger(CloudMLTQParserTest.class);public CloudMLTQParserTest() {- fixShardCount = true;- shardCount = 2;sliceCount = 2;configString = "solrconfig.xml";@@ -47,8 +46,10 @@ public class CloudMLTQParserTest extends AbstractFullDistribZkTestBase {protected String getCloudSolrConfig() {return configString;}-- public void doTest() throws Exception {++ @Test+ @ShardsFixed(num = 2)+ public void test() throws Exception {waitForRecoveriesToFinish(false);diff --git a/solr/core/src/test/org/apache/solr/search/stats/TestBaseStatsCache.java b/solr/core/src/test/org/apache/solr/search/stats/TestBaseStatsCache.javaindex 048c1a50b51..3ecd2de954d 100644--- a/solr/core/src/test/org/apache/solr/search/stats/TestBaseStatsCache.java+++ b/solr/core/src/test/org/apache/solr/search/stats/TestBaseStatsCache.java@@ -30,13 +30,13 @@ public abstract class TestBaseStatsCache extends TestDefaultStatsCache {protected abstract String getStatsCacheClassName();@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("solr.statsCache", getStatsCacheClassName());}- public void tearDown() throws Exception {- super.tearDown();+ public void distribTearDown() throws Exception {+ super.distribTearDown();System.clearProperty("solr.statsCache");}diff --git a/solr/core/src/test/org/apache/solr/search/stats/TestDefaultStatsCache.java b/solr/core/src/test/org/apache/solr/search/stats/TestDefaultStatsCache.javaindex 74ba1a18620..b93b8973c85 100644--- a/solr/core/src/test/org/apache/solr/search/stats/TestDefaultStatsCache.java+++ b/solr/core/src/test/org/apache/solr/search/stats/TestDefaultStatsCache.java@@ -22,23 +22,24 @@ import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.SolrDocumentList;import org.apache.solr.common.params.ModifiableSolrParams;+import org.junit.Test;public class TestDefaultStatsCache extends BaseDistributedSearchTestCase {private int docId = 0;@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();System.setProperty("solr.statsCache", LocalStatsCache.class.getName());}- public void tearDown() throws Exception {- super.tearDown();+ public void distribTearDown() throws Exception {+ super.distribTearDown();System.clearProperty("solr.statsCache");}-- @Override- public void doTest() throws Exception {++ @Test+ public void test() throws Exception {del("*:*");for (int i = 0; i < clients.size(); i++) {int shard = i + 1;diff --git a/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java b/solr/core/src/test/org/apache/solr/update/PeerSyncTest.javaindex 17c9b47aa0e..afabcd91d26 100644--- a/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java+++ b/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java@@ -25,6 +25,7 @@ import org.apache.solr.client.solrj.request.QueryRequest;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;import org.apache.solr.common.util.StrUtils;+import org.junit.Test;import java.io.IOException;import java.util.Arrays;@@ -41,18 +42,16 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {params(DISTRIB_UPDATE_PARAM, FROM_LEADER);public PeerSyncTest() {- fixShardCount = true;- shardCount = 3;stress = 0;// TODO: a better way to do this?configString = "solrconfig-tlog.xml";schemaString = "schema.xml";}--- @Override- public void doTest() throws Exception {++ @Test+ @ShardsFixed(num = 3)+ public void test() throws Exception {handle.clear();handle.put("timestamp", SKIPVAL);handle.put("score", SKIPVAL);diff --git a/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java b/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.javaindex a1c561e53b3..dc923e65672 100644--- a/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java+++ b/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java@@ -48,6 +48,7 @@ import org.apache.solr.update.SolrCmdDistributor.RetryNode;import org.apache.solr.update.SolrCmdDistributor.StdNode;import org.apache.solr.update.processor.DistributedUpdateProcessor;import org.junit.BeforeClass;+import org.junit.Test;import org.xml.sax.SAXException;import javax.xml.parsers.ParserConfigurationException;@@ -90,8 +91,6 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {}});- fixShardCount = true;- shardCount = 4;stress = 0;}@@ -136,9 +135,10 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {shards = sb.toString();}-- @Override- public void doTest() throws Exception {++ @Test+ @ShardsFixed(num = 4)+ public void test() throws Exception {del("*:*");SolrCmdDistributor cmdDistrib = new SolrCmdDistributor(updateShardHandler);@@ -320,7 +320,7 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {cmdDistrib.finish();- assertEquals(shardCount, commits.get());+ assertEquals(getShardCount(), commits.get());for (SolrClient c : clients) {NamedList<Object> resp = c.request(new LukeRequest());@@ -517,14 +517,9 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {}@Override- public void setUp() throws Exception {- super.setUp();- }-- @Override- public void tearDown() throws Exception {+ public void distribTearDown() throws Exception {updateShardHandler.close();- super.tearDown();+ super.distribTearDown();}private void testDistribOpenSearcher() {diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.javaindex 4b96dfbb4bb..7a928301a90 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java@@ -21,7 +21,6 @@ import com.google.common.collect.Lists;import com.google.common.collect.Maps;import com.google.common.collect.Sets;-import org.apache.http.client.HttpClient;import org.apache.http.impl.client.CloseableHttpClient;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.client.solrj.SolrQuery;@@ -46,10 +45,9 @@ import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.params.ShardParams;import org.apache.solr.common.util.NamedList;import org.apache.zookeeper.KeeperException;-import org.junit.After;import org.junit.AfterClass;-import org.junit.Before;import org.junit.BeforeClass;+import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -97,31 +95,23 @@ public class CloudSolrClientTest extends AbstractFullDistribZkTestBase {return SOLR_HOME;}- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();// we expect this time of exception as shards go up and down...//ignoreException(".*");System.setProperty("numShards", Integer.toString(sliceCount));}- @Override- @After- public void tearDown() throws Exception {- super.tearDown();- resetExceptionIgnores();- }-public CloudSolrClientTest() {super();sliceCount = 2;- shardCount = 3;+ fixShardCount(3);}- @Override- public void doTest() throws Exception {+ @Test+ public void test() throws Exception {allTests();stateVersionParamTest();customHttpClientTest();diff --git a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.javaindex e573d2cba3b..5ecd2189043 100644--- a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java@@ -39,12 +39,19 @@ import org.apache.solr.schema.TrieDateField;import org.eclipse.jetty.servlet.ServletHolder;import org.junit.AfterClass;import org.junit.BeforeClass;-import org.junit.Test;+import org.junit.Rule;+import org.junit.rules.TestRule;+import org.junit.runner.Description;+import org.junit.runners.model.Statement;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import java.io.File;import java.io.IOException;+import java.lang.annotation.ElementType;+import java.lang.annotation.Retention;+import java.lang.annotation.RetentionPolicy;+import java.lang.annotation.Target;import java.nio.file.Path;import java.util.ArrayList;import java.util.Arrays;@@ -63,6 +70,20 @@ import java.util.concurrent.atomic.AtomicInteger;/*** Helper base class for distributed search test cases*+ * By default, all tests in sub-classes will be executed with+ * 1, 2, ... DEFAULT_MAX_SHARD_COUNT number of shards set up repeatedly.+ *+ * In general, it's preferable to annotate the tests in sub-classes with a+ * {@literal @}ShardsFixed(num = N) or a {@literal @}ShardsRepeat(min = M, max = N)+ * to indicate whether the test should be called once, with a fixed number of shards,+ * or called repeatedly for number of shards = M to N.+ *+ * In some cases though, if the number of shards has to be fixed, but the number+ * itself is dynamic, or if it has to be set as a default for all sub-classes+ * of a sub-class, there's a fixShardCount(N) available, which is identical to+ * {@literal @}ShardsFixed(num = N) for all tests without annotations in that class+ * hierarchy. Ideally this function should be retired in favour of better annotations..+ ** @since solr 1.5*/public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {@@ -174,16 +195,19 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {"[ff01::213]:33332" + context};}- protected int shardCount = 4; // the actual number of solr cores that will be created in the cluster+ private final static int DEFAULT_MAX_SHARD_COUNT = 3;- /**- * Sub classes can set this flag in their constructor to true if they- * want to fix the number of shards to 'shardCount'- *- * The default is false which means that test will be executed with- * 1, 2, 3, ....shardCount number of shards repeatedly- */- protected boolean fixShardCount = false;+ private int shardCount = -1; // the actual number of solr cores that will be created in the cluster+ public int getShardCount() {+ return shardCount;+ }++ private boolean isShardCountFixed = false;++ public void fixShardCount(int count) {+ isShardCountFixed = true;+ shardCount = count;+ }protected JettySolrRunner controlJetty;protected List<SolrClient> clients = new ArrayList<>();@@ -245,13 +269,6 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {public static RandVal rdate = new RandDate();- /**- * Perform the actual tests here- *- * @throws Exception on error- */- public abstract void doTest() throws Exception;-public static String[] fieldNames = new String[]{"n_ti1", "n_f1", "n_tf1", "n_d1", "n_td1", "n_l1", "n_tl1", "n_dt1", "n_tdt1"};public static RandVal[] randVals = new RandVal[]{rint, rfloat, rfloat, rdouble, rdouble, rlong, rlong, rdate, rdate};@@ -270,20 +287,20 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {public String getSolrHome() {return SolrTestCaseJ4.TEST_HOME();}-- @Override- public void setUp() throws Exception {++ private boolean distribSetUpCalled = false;+ public void distribSetUp() throws Exception {+ distribSetUpCalled = true;SolrTestCaseJ4.resetExceptionIgnores(); // ignore anything with ignore_exception in it- super.setUp();System.setProperty("solr.test.sys.prop1", "propone");System.setProperty("solr.test.sys.prop2", "proptwo");testDir = createTempDir().toFile();}- @Override- public void tearDown() throws Exception {+ private boolean distribTearDownCalled = false;+ public void distribTearDown() throws Exception {+ distribTearDownCalled = true;destroyServers();- super.tearDown();}protected JettySolrRunner createControlJetty() throws Exception {@@ -870,23 +887,107 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {compareSolrResponses(a, b);}- @Test- public void testDistribSearch() throws Exception {- if (fixShardCount) {- createServers(shardCount);- RandVal.uniqueValues = new HashSet(); //reset random values- doTest();- destroyServers();- } else {- for (int nServers = 1; nServers < shardCount; nServers++) {- createServers(nServers);+ @Retention(RetentionPolicy.RUNTIME)+ @Target(ElementType.METHOD)+ public @interface ShardsRepeat {+ public abstract int min() default 1;+ public abstract int max() default DEFAULT_MAX_SHARD_COUNT;+ }++ @Retention(RetentionPolicy.RUNTIME)+ @Target(ElementType.METHOD)+ public @interface ShardsFixed {+ public abstract int num();+ }++ public class ShardsRepeatRule implements TestRule {++ private abstract class ShardsStatement extends Statement {+ abstract protected void callStatement() throws Throwable;++ @Override+ public void evaluate() throws Throwable {+ distribSetUp();+ if (! distribSetUpCalled) {+ Assert.fail("One of the overrides of distribSetUp does not propagate the call.");+ }+ try {+ callStatement();+ } finally {+ distribTearDown();+ if (! distribTearDownCalled) {+ Assert.fail("One of the overrides of distribTearDown does not propagate the call.");+ }+ }+ }+ }++ private class ShardsFixedStatement extends ShardsStatement {++ private final int numShards;+ private final Statement statement;++ private ShardsFixedStatement(int numShards, Statement statement) {+ this.numShards = numShards;+ this.statement = statement;+ }++ @Override+ public void callStatement() throws Throwable {+ fixShardCount(numShards);+ createServers(numShards);RandVal.uniqueValues = new HashSet(); //reset random values- doTest();+ statement.evaluate();destroyServers();}}++ private class ShardsRepeatStatement extends ShardsStatement {++ private final int min;+ private final int max;+ private final Statement statement;++ private ShardsRepeatStatement(int min, int max, Statement statement) {+ this.min = min;+ this.max = max;+ this.statement = statement;+ }++ @Override+ public void callStatement() throws Throwable {+ for (shardCount = min; shardCount <= max; shardCount++) {+ createServers(shardCount);+ RandVal.uniqueValues = new HashSet(); //reset random values+ statement.evaluate();+ destroyServers();+ }+ }+ }++ @Override+ public Statement apply(Statement statement, Description description) {+ ShardsFixed fixed = description.getAnnotation(ShardsFixed.class);+ ShardsRepeat repeat = description.getAnnotation(ShardsRepeat.class);+ if (fixed != null && repeat != null) {+ throw new RuntimeException("ShardsFixed and ShardsRepeat annotations can't coexist");+ }+ else if (fixed != null) {+ return new ShardsFixedStatement(fixed.num(), statement);+ }+ else if (repeat != null) {+ return new ShardsRepeatStatement(repeat.min(), repeat.max(), statement);+ }+ else {+ return (isShardCountFixed ? new ShardsFixedStatement(shardCount, statement) :+ new ShardsRepeatStatement(1, DEFAULT_MAX_SHARD_COUNT, statement));+ }+ }}+ @Rule+ public ShardsRepeatRule repeatRule = new ShardsRepeatRule();+public static Object[] getRandFields(String[] fields, RandVal[] randVals) {Object[] o = new Object[fields.length * 2];for (int i = 0; i < fields.length; i++) {diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.javaindex 1098ca5a62c..a7c33f04d65 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java@@ -33,8 +33,6 @@ import org.apache.solr.core.Diagnostics;import org.apache.solr.core.MockDirectoryFactory;import org.apache.solr.servlet.SolrDispatchFilter;import org.apache.zookeeper.KeeperException;-import org.junit.After;-import org.junit.Before;import org.junit.BeforeClass;public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTestCase {@@ -54,11 +52,9 @@ public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTes//useFactory(null);}-- @Before@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();String zkDir = testDir.getAbsolutePath() + File.separator+ "zookeeper/server1/data";@@ -212,8 +208,7 @@ public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTes}@Override- @After- public void tearDown() throws Exception {+ public void distribTearDown() throws Exception {if (DEBUG) {printLayout();}@@ -228,7 +223,7 @@ public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTesSystem.clearProperty(MockDirectoryFactory.SOLR_TESTS_ALLOW_READING_FILES_STILL_OPEN_FOR_WRITE);resetExceptionIgnores();- super.tearDown();+ super.distribTearDown();zkServer.shutdown();}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 19bc627cad4..93ae02b6316 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@@ -55,9 +55,7 @@ import org.apache.solr.core.SolrResourceLoader;import org.apache.solr.servlet.SolrDispatchFilter;import org.apache.solr.update.DirectUpdateHandler2;import org.apache.zookeeper.CreateMode;-import org.junit.After;import org.junit.AfterClass;-import org.junit.Before;import org.junit.BeforeClass;import org.noggit.CharArr;import org.noggit.JSONWriter;@@ -95,18 +93,18 @@ import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;@Slowpublic abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTestBase {static Logger log = LoggerFactory.getLogger(AbstractFullDistribZkTestBase.class);-+@BeforeClasspublic static void beforeFullSolrCloudTest() {// shorten the log output more for this test typeif (formatter != null) formatter.setShorterFormat();}-+public static final String SHARD1 = "shard1";public static final String SHARD2 = "shard2";-+protected boolean printLayoutOnTearDown = false;-+String t1 = "a_t";String i1 = "a_i1";String tlong = "other_tl1";@@ -122,14 +120,14 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesprotected Map<String,List<CloudJettyRunner>> shardToJetty = new HashMap<>();private AtomicInteger jettyIntCntr = new AtomicInteger(0);protected ChaosMonkey chaosMonkey;-+protected Map<String,CloudJettyRunner> shardToLeaderJetty = new HashMap<>();private boolean cloudInit;protected boolean checkCreatedVsState;protected boolean useJettyDataDir = true;protected Map<URI,SocketProxy> proxies = new HashMap<URI,SocketProxy>();-+public static class CloudJettyRunner {public JettySolrRunner jetty;public String nodeName;@@ -160,19 +158,19 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesreturn "CloudJettyRunner [url=" + url + "]";}}-+static class CloudSolrServerClient {SolrClient solrClient;String shardName;int port;public ZkNodeProps info;-+public CloudSolrServerClient() {}public CloudSolrServerClient(SolrClient client) {this.solrClient = client;}-+@Overridepublic int hashCode() {final int prime = 31;@@ -180,7 +178,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesresult = prime * result + ((solrClient == null) ? 0 : solrClient.hashCode());return result;}-+@Overridepublic boolean equals(Object obj) {if (this == obj) return true;@@ -192,69 +190,67 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes} else if (!solrClient.equals(other.solrClient)) return false;return true;}-+}-- @Before+@Override- public void setUp() throws Exception {- super.setUp();+ public void distribSetUp() throws Exception {+ super.distribSetUp();// ignoreException(".*");if (sliceCount > 0) {System.setProperty("numShards", Integer.toString(sliceCount));} else {System.clearProperty("numShards");}-+if (isSSLMode()) {System.clearProperty("urlScheme");ZkStateReader zkStateReader = new ZkStateReader(zkServer.getZkAddress(),AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT);try {zkStateReader.getZkClient().create(ZkStateReader.CLUSTER_PROPS,- ZkStateReader.toJSON(Collections.singletonMap("urlScheme","https")),+ ZkStateReader.toJSON(Collections.singletonMap("urlScheme","https")),CreateMode.PERSISTENT, true);} finally {zkStateReader.close();}}}-+@BeforeClasspublic static void beforeClass() {System.setProperty("solrcloud.update.delay", "0");}-+@AfterClasspublic static void afterClass() throws Exception {System.clearProperty("solrcloud.update.delay");System.clearProperty("genericCoreNodeNames");}-+public AbstractFullDistribZkTestBase() {- fixShardCount = true;-- shardCount = 4;sliceCount = 2;+ fixShardCount(4);+// TODO: for now, turn off stress because it uses regular clients, and we// need the cloud client because we kill serversstress = 0;-+useExplicitNodeNames = random().nextBoolean();}-+protected String getDataDir(String dataDir) throws IOException {return dataDir;}-+protected void initCloud() throws Exception {assert(cloudInit == false);cloudInit = true;cloudClient = createCloudClient(DEFAULT_COLLECTION);cloudClient.connect();-+ZkStateReader zkStateReader = cloudClient.getZkStateReader();-+chaosMonkey = new ChaosMonkey(zkServer, zkStateReader, DEFAULT_COLLECTION,shardToJetty, shardToLeaderJetty);}@@ -269,18 +265,18 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes.setParameter(CoreConnectionPNames.SO_TIMEOUT, 60000);return client;}-+@Overrideprotected void createServers(int numServers) throws Exception {-+System.setProperty("collection", "control_collection");// we want hashes by default for the control, so set to 1 shard as opposed to leaving unsetString oldNumShards = System.getProperty(ZkStateReader.NUM_SHARDS_PROP);System.setProperty(ZkStateReader.NUM_SHARDS_PROP, "1");-+try {-+File controlJettyDir = createTempDir("control").toFile();setupJettySolrHome(controlJettyDir);@@ -305,7 +301,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes// cloudClientreturn;}-+} finally {System.clearProperty("collection");if (oldNumShards != null) {@@ -317,9 +313,9 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesinitCloud();-+createJettys(numServers, checkCreatedVsState).size();-+int cnt = getTotalReplicas(DEFAULT_COLLECTION);if (cnt > 0) {waitForCollection(cloudClient.getZkStateReader(), DEFAULT_COLLECTION, sliceCount);@@ -348,7 +344,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesThread.sleep(500);}}-+protected List<JettySolrRunner> createJettys(int numJettys) throws Exception {return createJettys(numJettys, false);}@@ -402,22 +398,22 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesSolrClient client = createNewSolrClient(j.getLocalPort());clients.add(client);}-+this.jettys.addAll(jettys);this.clients.addAll(clients);-+int numShards = getTotalReplicas(DEFAULT_COLLECTION);if (checkCreatedVsState) {// now wait until we see that the number of shards in the cluster state// matches what we expectint retries = 0;- while (numShards != shardCount) {+ while (numShards != getShardCount()) {numShards = getTotalReplicas(DEFAULT_COLLECTION);- if (numShards == shardCount) break;+ if (numShards == getShardCount()) break;if (retries++ == 60) {printLayoutOnTearDown = true;fail("Shards in the state does not match what we set:" + numShards- + " vs " + shardCount);+ + " vs " + getShardCount());}Thread.sleep(500);}@@ -432,7 +428,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesif (numShards > 0) {updateMappingsFromZk(this.jettys, this.clients);}-+// build the shard stringfor (int i = 1; i <= numJettys / 2; i++) {JettySolrRunner j = this.jettys.get(i);@@ -442,7 +438,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTessb.append("|").append(buildUrl(j2.getLocalPort()));}shards = sb.toString();-+return jettys;}@@ -494,30 +490,30 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes}return cnt;}-+public JettySolrRunner createJetty(String dataDir, String ulogDir, String shardList,String solrConfigOverride) throws Exception {-+JettySolrRunner jetty = new JettySolrRunner(getSolrHome(), context, 0,solrConfigOverride, null, false, getExtraServlets(), sslConfig, getExtraRequestFilters());jetty.setShards(shardList);jetty.setDataDir(getDataDir(dataDir));jetty.start();-+return jetty;}-+public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride) throws Exception {// randomly test a relative solr.home pathif (random().nextBoolean()) {solrHome = getRelativeSolrHomePath(solrHome);}-+JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), context, 0, solrConfigOverride, schemaOverride, false, getExtraServlets(), sslConfig, getExtraRequestFilters());jetty.setShards(shardList);jetty.setDataDir(getDataDir(dataDir));jetty.start();-+return jetty;}@@ -598,7 +594,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesprivate File getRelativeSolrHomePath(File solrHome) {String path = SolrResourceLoader.normalizeDir(new File(".").getAbsolutePath());String base = new File(solrHome.getPath()).getAbsolutePath();-+if (base.startsWith(".")) {base = base.replaceFirst("\\.", new File(".").getName());}@@ -606,14 +602,14 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesif (path.endsWith(File.separator + ".")) {path = path.substring(0, path.length() - 2);}-+int splits = path.split("\\" + File.separator).length;-+StringBuilder p = new StringBuilder();for (int i = 0; i < splits - 2; i++) {p.append("..").append(File.separator);- }-+ }+String prefix = FilenameUtils.getPrefix(path);if (base.startsWith(prefix)) {base = base.substring(prefix.length());@@ -632,7 +628,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTeszkStateReader.updateClusterState(true);cloudJettys.clear();shardToJetty.clear();-+ClusterState clusterState = zkStateReader.getClusterState();DocCollection coll = clusterState.getCollection(DEFAULT_COLLECTION);@@ -645,28 +641,28 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesfor (Replica replica : slice.getReplicas()) {int port = new URI(((HttpSolrClient) client).getBaseURL()).getPort();-+if (replica.getStr(ZkStateReader.BASE_URL_PROP).contains(":" + port)) {CloudSolrServerClient csc = new CloudSolrServerClient();csc.solrClient = client;csc.port = port;csc.shardName = replica.getStr(ZkStateReader.NODE_NAME_PROP);csc.info = replica;-+theClients .add(csc);-+break nextClient;}}}}-+for (JettySolrRunner jetty : jettys) {int port = jetty.getLocalPort();if (port == -1) {throw new RuntimeException("Cannot find the port for jetty");}-+nextJetty:for (Slice slice : coll.getSlices()) {Set<Entry<String,Replica>> entries = slice.getReplicasMap().entrySet();@@ -696,7 +692,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes}}}-+// # of jetties may not match replicas in shard here, because we don't map// jetties that are not running - every shard should have at least one// running jetty though@@ -706,13 +702,13 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesif (!allowOverSharding) {assertNotNull("Test setup problem: We found no jetties for shard: "+ slice.getName() + " just:" + shardToJetty.keySet(), jetties);-+assertEquals("slice:" + slice.getName(), slice.getReplicas().size(),jetties.size());}}}-+private CloudSolrServerClient findClientByPort(int port, List<CloudSolrServerClient> theClients) {for (CloudSolrServerClient client : theClients) {if (client.port == port) {@@ -724,7 +720,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes@Overrideprotected void setDistributedParams(ModifiableSolrParams params) {-+if (r.nextBoolean()) {// don't set shards, let that be figured out from the cloud state} else {@@ -737,19 +733,19 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesparams.set("shards", sb.toString());}}-+@Overrideprotected void indexDoc(SolrInputDocument doc) throws IOException,SolrServerException {-+UpdateRequest req = new UpdateRequest();req.add(doc);req.setParam("CONTROL", "TRUE");req.process(controlClient);-+// if we wanted to randomly pick a client - but sometimes they may be// down...-+// boolean pick = random.nextBoolean();//// int which = (doc.getField(id).toString().hashCode() & 0x7fffffff) %@@ -762,13 +758,13 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes//// HttpSolrServer client = (HttpSolrServer)// clients.get(which);-+UpdateRequest ureq = new UpdateRequest();ureq.add(doc);// ureq.setParam(UpdateParams.UPDATE_CHAIN, DISTRIB_UPDATE_CHAIN);ureq.process(cloudClient);}-+@Overrideprotected void index_specific(int serverNumber, Object... fields)throws Exception {@@ -780,7 +776,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesHttpSolrClient client = (HttpSolrClient) clients.get(serverNumber);-+UpdateRequest ureq = new UpdateRequest();ureq.add(doc);// ureq.setParam("update.chain", DISTRIB_UPDATE_CHAIN);@@ -793,16 +789,16 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesfor (int i = 0; i < fields.length; i += 2) {doc.addField((String) (fields[i]), fields[i + 1]);}-+UpdateRequest ureq = new UpdateRequest();ureq.add(doc);// ureq.setParam("update.chain", DISTRIB_UPDATE_CHAIN);ureq.process(client);-+// add to control second in case adding to shards failscontrolClient.add(doc);}-+@Overrideprotected void del(String q) throws Exception {controlClient.deleteByQuery(q);@@ -816,25 +812,25 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes}***/}// serial commit...-+protected void waitForRecoveriesToFinish(boolean verbose)throws Exception {ZkStateReader zkStateReader = cloudClient.getZkStateReader();super.waitForRecoveriesToFinish(DEFAULT_COLLECTION, zkStateReader, verbose);}-+protected void waitForRecoveriesToFinish(String collection, boolean verbose)throws Exception {ZkStateReader zkStateReader = cloudClient.getZkStateReader();super.waitForRecoveriesToFinish(collection, zkStateReader, verbose);}-+protected void waitForRecoveriesToFinish(boolean verbose, int timeoutSeconds)throws Exception {ZkStateReader zkStateReader = cloudClient.getZkStateReader();super.waitForRecoveriesToFinish(DEFAULT_COLLECTION, zkStateReader, verbose, true, timeoutSeconds);}-+protected void checkQueries() throws Exception {handle.put("_version_", SKIPVAL);@@ -858,7 +854,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesquery("q", "*:*", "sort", f + " desc");query("q", "*:*", "sort", f + " asc");}-+// these queries should be exactly ordered and scores should exactly matchquery("q", "*:*", "sort", i1 + " desc");query("q", "*:*", "sort", i1 + " asc");@@ -875,30 +871,30 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTeshandle.remove("maxScore");query("q", "{!func}" + i1, "fl", "*,score"); // even scores should match// exactly here-+handle.put("highlighting", UNORDERED);handle.put("response", UNORDERED);-+handle.put("maxScore", SKIPVAL);query("q", "quick");query("q", "all", "fl", "id", "start", "0");query("q", "all", "fl", "foofoofoo", "start", "0"); // no fields in returned// docsquery("q", "all", "fl", "id", "start", "100");-+handle.put("score", SKIPVAL);query("q", "quick", "fl", "*,score");query("q", "all", "fl", "*,score", "start", "1");query("q", "all", "fl", "*,score", "start", "100");-+query("q", "now their fox sat had put", "fl", "*,score", "hl", "true","hl.fl", t1);-+query("q", "now their fox sat had put", "fl", "foofoofoo", "hl", "true","hl.fl", t1);-+query("q", "matchesnothing", "fl", "*,score");-+query("q", "*:*", "rows", 100, "facet", "true", "facet.field", t1);query("q", "*:*", "rows", 100, "facet", "true", "facet.field", t1,"facet.limit", -1, "facet.sort", "count");@@ -916,11 +912,11 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes"facet.offset", 1);query("q", "*:*", "rows", 100, "facet", "true", "facet.field", t1,"facet.mincount", 2);-+// test faceting multiple things at oncequery("q", "*:*", "rows", 100, "facet", "true", "facet.query", "quick","facet.query", "all", "facet.query", "*:*", "facet.field", t1);-+// test filter tagging, facet exclusion, and naming (multi-select facet// support)query("q", "*:*", "rows", 100, "facet", "true", "facet.query",@@ -933,16 +929,16 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes"{!ex=t1}SubjectTerms_mfacet", "fq","{!tag=t1}SubjectTerms_mfacet:(test 1)", "facet.limit", "10","facet.mincount", "1");-+// test field that is valid in schema but missing in all shardsquery("q", "*:*", "rows", 100, "facet", "true", "facet.field",missingField, "facet.mincount", 2);// test field that is valid in schema and missing in some shardsquery("q", "*:*", "rows", 100, "facet", "true", "facet.field", oddField,"facet.mincount", 2);-+query("q", "*:*", "sort", i1 + " desc", "stats", "true", "stats.field", i1);-+// Try to get better coverage for refinement queries by turning off over// requesting.// This makes it much more likely that we may not get the top facet values@@ -956,15 +952,15 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes"{!key='a b/c \\' \\} foo'}" + t1, "facet.limit", 5,"facet.shard.limit", 5);handle.remove("facet_fields");-+query("q", "*:*", "sort", "n_tl1 desc");-+// index the same document to two shards and make sure things// don't blow up.// assumes first n clients are first n shardsif (clients.size() >= 2) {index(id, 100, i1, 107, t1, "oh no, a duplicate!");- for (int i = 0; i < shardCount; i++) {+ for (int i = 0; i < getShardCount(); i++) {index_specific(i, id, 100, i1, 107, t1, "oh no, a duplicate!");}commit();@@ -973,7 +969,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesquery("q", "*:*", "rows", 100);}}-+protected void indexAbunchOfDocs() throws Exception {indexr(id, 2, i1, 50, t1, "to come to the aid of their country.");indexr(id, 3, i1, 2, t1, "how now brown cow");@@ -993,7 +989,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes"Great works are performed, not by strength, but by perseverance.");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","mathematical analysis"});indexr(id, 15, "SubjectTerms_mfacet", new String[] {"test 1", "test 2",@@ -1005,19 +1001,19 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesvals[i] = "test " + i;}indexr(id, 17, "SubjectTerms_mfacet", vals);-+for (int i = 100; i < 150; i++) {indexr(id, i);}}-+/**- * Executes a query against each live and active replica of the specified shard+ * Executes a query against each live and active replica of the specified shard* and aserts that the results are identical.** @see #queryAndCompare*/- public QueryResponse queryAndCompareReplicas(SolrParams params, String shard)+ public QueryResponse queryAndCompareReplicas(SolrParams params, String shard)throws Exception {ArrayList<SolrClient> shardClients = new ArrayList<>(7);@@ -1042,9 +1038,9 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes/*** For each Shard, executes a query against each live and active replica of that shard- * and asserts that the results are identical for each replica of the same shard.- * Because results are not compared between replicas of different shards, this method- * should be safe for comparing the results of any query, even if it contains+ * and asserts that the results are identical for each replica of the same shard.+ * Because results are not compared between replicas of different shards, this method+ * should be safe for comparing the results of any query, even if it contains* "distrib=false", because the replicas should all be identical.** @see AbstractFullDistribZkTestBase#queryAndCompareReplicas(SolrParams, String)@@ -1058,25 +1054,25 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes}}- /**- * Returns a non-null string if replicas within the same shard do not have a- * consistent number of documents.+ /**+ * Returns a non-null string if replicas within the same shard do not have a+ * consistent number of documents.*/protected void checkShardConsistency(String shard) throws Exception {checkShardConsistency(shard, false, false);}- /**- * Returns a non-null string if replicas within the same shard do not have a+ /**+ * Returns a non-null string if replicas within the same shard do not have a* consistent number of documents.- * If expectFailure==false, the exact differences found will be logged since+ * If expectFailure==false, the exact differences found will be logged since* this would be an unexpected failure.- * verbose causes extra debugging into to be displayed, even if everything is+ * verbose causes extra debugging into to be displayed, even if everything is* consistent.*/protected String checkShardConsistency(String shard, boolean expectFailure, boolean verbose)throws Exception {-+List<CloudJettyRunner> solrJetties = shardToJetty.get(shard);if (solrJetties == null) {throw new RuntimeException("shard not found:" + shard + " keys:"@@ -1112,7 +1108,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes+ e.getMessage() + "\n");continue;}-+boolean live = false;String nodeName = props.getStr(ZkStateReader.NODE_NAME_PROP);if (zkStateReader.getClusterState().liveNodesContain(nodeName)) {@@ -1149,19 +1145,19 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes}}return failMessage;-+}-+public void showCounts() {Set<String> theShards = shardToJetty.keySet();-+for (String shard : theShards) {List<CloudJettyRunner> solrJetties = shardToJetty.get(shard);-+for (CloudJettyRunner cjetty : solrJetties) {ZkNodeProps props = cjetty.info;System.err.println("PROPS:" + props);-+try {SolrParams query = params("q", "*:*", "rows", "0", "distrib","false", "tests", "checkShardConsistency"); // "tests" is just a@@ -1187,11 +1183,11 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTeslive = true;}System.err.println(" live:" + live);-+}}}-+protected void randomlyEnableAutoSoftCommit() {if (r.nextBoolean()) {enableAutoSoftCommit(1000);@@ -1199,7 +1195,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTeslog.info("Not turning on auto soft commit");}}-+protected void enableAutoSoftCommit(int time) {log.info("Turning on auto soft commit: " + time);for (List<CloudJettyRunner> jettyList : shardToJetty.values()) {@@ -1228,7 +1224,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesthrows Exception {checkShardConsistency(checkVsControl, verbose, null, null);}-+/* Checks shard consistency and optionally checks against the control shard.* The test will be failed if differences are found.*/@@ -1236,7 +1232,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesthrows Exception {updateMappingsFromZk(jettys, clients, true);-+Set<String> theShards = shardToJetty.keySet();String failMessage = null;for (String shard : theShards) {@@ -1245,7 +1241,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesfailMessage = shardFailMessage;}}-+if (failMessage != null) {fail(failMessage);}@@ -1260,7 +1256,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesSolrDocumentList cloudDocList = cloudClient.query(q).getResults();long cloudClientDocs = cloudDocList.getNumFound();-+// now check that the right # are on each shardtheShards = shardToJetty.keySet();int cnt = 0;@@ -1314,7 +1310,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes}return null;}-+protected void assertDocCounts(boolean verbose) throws Exception {// TODO: as we create the clients, we should build a map from shard to// node/client@@ -1324,7 +1320,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes+ "\n\n");long controlCount = controlClient.query(new SolrQuery("*:*")).getResults().getNumFound();-+// do some really inefficient mapping...ZkStateReader zk = new ZkStateReader(zkServer.getZkAddress(), 10000,AbstractZkTestCase.TIMEOUT);@@ -1337,12 +1333,12 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes} finally {zk.close();}-+if (slices == null) {throw new RuntimeException("Could not find collection "+ DEFAULT_COLLECTION + " in " + clusterState.getCollections());}-+for (CloudJettyRunner cjetty : cloudJettys) {CloudSolrServerClient client = cjetty.client;for (Map.Entry<String,Slice> slice : slices.entrySet()) {@@ -1368,7 +1364,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesquery.set("distrib", false);count = client.solrClient.query(query).getResults().getNumFound();}-+if (verbose) System.err.println("client docs:" + count + "\n\n");}if (verbose) System.err.println("control docs:"@@ -1378,39 +1374,39 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesassertEquals("Doc Counts do not add up", controlCount,cloudClient.query(query).getResults().getNumFound());}-+@Overrideprotected QueryResponse queryServer(ModifiableSolrParams params)throws SolrServerException {-+if (r.nextBoolean()) params.set("collection", DEFAULT_COLLECTION);-+QueryResponse rsp = cloudClient.query(params);return rsp;}-+static abstract class StopableThread extends Thread {public StopableThread(String name) {super(name);}public abstract void safeStop();}-+class StopableSearchThread extends StopableThread {private volatile boolean stop = false;protected final AtomicInteger queryFails = new AtomicInteger();private String[] QUERIES = new String[] {"to come","their country","aid","co*"};-+public StopableSearchThread() {super("StopableSearchThread");setDaemon(true);}-+@Overridepublic void run() {Random random = random();int numSearches = 0;-+while (true && !stop) {numSearches++;try {@@ -1431,43 +1427,43 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesThread.currentThread().interrupt();}}-+System.err.println("num searches done:" + numSearches + " with " + queryFails + " fails");}-+@Overridepublic void safeStop() {stop = true;}-+public int getFails() {return queryFails.get();}-+};-+public void waitForThingsToLevelOut(int waitForRecTimeSeconds) throws Exception {log.info("Wait for recoveries to finish - wait " + waitForRecTimeSeconds + " for each attempt");int cnt = 0;boolean retry = false;do {waitForRecoveriesToFinish(VERBOSE, waitForRecTimeSeconds);-+try {commit();} catch (Throwable t) {t.printStackTrace();// we don't care if this commit fails on some nodes}-+updateMappingsFromZk(jettys, clients);-+Set<String> theShards = shardToJetty.keySet();String failMessage = null;for (String shard : theShards) {failMessage = checkShardConsistency(shard, true, false);}-+if (failMessage != null) {log.info("shard inconsistency - waiting ...");retry = true;@@ -1479,8 +1475,8 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesThread.sleep(2000);} while (retry);}--++public void waitForNoShardInconsistency() throws Exception {log.info("Wait for no shard inconsistency");int cnt = 0;@@ -1492,9 +1488,9 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTest.printStackTrace();// we don't care if this commit fails on some nodes}-+updateMappingsFromZk(jettys, clients);-+Set<String> theShards = shardToJetty.keySet();String failMessage = null;for (String shard : theShards) {@@ -1505,7 +1501,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesfailMessage="hit exception:" + e.getMessage();}}-+if (failMessage != null) {log.info("shard inconsistency - waiting ...");retry = true;@@ -1531,8 +1527,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes}@Override- @After- public void tearDown() throws Exception {+ public void distribTearDown() throws Exception {if (VERBOSE || printLayoutOnTearDown) {super.printLayout();}@@ -1548,25 +1543,25 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesif (controlClientCloud != null) {controlClientCloud.shutdown();}- super.tearDown();-+ super.distribTearDown();+System.clearProperty("zkHost");System.clearProperty("numShards");- // close socket proxies after super.tearDown+ // close socket proxies after super.distribTearDownif (!proxies.isEmpty()) {for (SocketProxy proxy : proxies.values()) {proxy.close();}}}-+@Overrideprotected void commit() throws Exception {controlClient.commit();cloudClient.commit();}-+@Overrideprotected void destroyServers() throws Exception {if (controlJetty != null) {@@ -1581,7 +1576,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes}super.destroyServers();}-+protected CollectionAdminResponse createCollection(String collectionName, int numShards, int replicationFactor, int maxShardsPerNode) throws SolrServerException, IOException {return createCollection(null, collectionName, numShards, replicationFactor, maxShardsPerNode, null, null);}@@ -1653,7 +1648,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesMAX_SHARDS_PER_NODE, maxShardsPerNode),client);}-+protected CollectionAdminResponse createCollection(Map<String, List<Integer>> collectionInfos,String collectionName, int numShards, int replicationFactor, int maxShardsPerNode, SolrClient client, String createNodeSetStr, String configName) throws SolrServerException, IOException {@@ -1702,7 +1697,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes0, client.getBaseURL().length()- DEFAULT_COLLECTION.length() - 1);}-+protected SolrInputDocument getDoc(Object... fields) throws Exception {SolrInputDocument doc = new SolrInputDocument();addFields(doc, fields);@@ -1716,7 +1711,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes// The Math.min thing is here, because we expect replication-factor to be reduced to if there are not enough live nodes to spread all shards of a collection over different nodesint expectedShardsPerSlice = numShardsNumReplicaList.get(1);int expectedTotalShards = expectedSlices * expectedShardsPerSlice;-+// Map<String,DocCollection> collections = clusterState// .getCollectionStates();if (clusterState.hasCollection(collectionName)) {@@ -1735,14 +1730,14 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTestotalShards += slices.get(sliceName).getReplicas().size();}if (totalShards != expectedTotalShards) {- return "Found new collection " + collectionName + " with correct number of slices, but mismatch on number of shards. Expected: " + expectedTotalShards + ", actual: " + totalShards;+ return "Found new collection " + collectionName + " with correct number of slices, but mismatch on number of shards. Expected: " + expectedTotalShards + ", actual: " + totalShards;}return null;} else {return "Could not find new collection " + collectionName;}}-+protected void checkForCollection(String collectionName,List<Integer> numShardsNumReplicaList,List<String> nodesAllowedToRunShards) throws Exception {@@ -1780,7 +1775,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes}return commondCloudSolrClient;}-+public static String getUrlFromZk(ClusterState clusterState, String collection) {Map<String,Slice> slices = clusterState.getCollection(collection).getSlicesMap();@@ -1889,9 +1884,9 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesprotected List<Replica> ensureAllReplicasAreActive(String testCollectionName, String shardId, int shards, int rf, int maxWaitSecs) throws Exception {long startMs = System.currentTimeMillis();-+Map<String,Replica> notLeaders = new HashMap<String,Replica>();-+ZkStateReader zkr = cloudClient.getZkStateReader();zkr.updateClusterState(true); // force the state to be fresh@@ -1906,7 +1901,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes// refresh state every 2 secsif (waitMs % 2000 == 0)cloudClient.getZkStateReader().updateClusterState(true);-+cs = cloudClient.getZkStateReader().getClusterState();assertNotNull(cs);Slice shard = cs.getSlice(testCollectionName, shardId);@@ -1919,7 +1914,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesassertNotNull(leader);log.info("Found "+replicas.size()+" replicas and leader on "+leader.getNodeName()+" for "+shardId+" in "+testCollectionName);-+// ensure all replicas are "active" and identify the non-leader replicafor (Replica replica : replicas) {String replicaState = replica.getStr(ZkStateReader.STATE_PROP);@@ -1927,11 +1922,11 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTeslog.info("Replica " + replica.getName() + " is currently " + replicaState);allReplicasUp = false;}-- if (!leader.equals(replica))++ if (!leader.equals(replica))notLeaders.put(replica.getName(), replica);}-+if (!allReplicasUp) {try {Thread.sleep(500L);@@ -1939,22 +1934,22 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTeswaitMs += 500L;}} // end while-- if (!allReplicasUp)++ if (!allReplicasUp)fail("Didn't see all replicas for shard "+shardId+" in "+testCollectionName+" come up within " + maxWaitMs + " ms! ClusterState: " + printClusterStateInfo());-- if (notLeaders.isEmpty())++ if (notLeaders.isEmpty())fail("Didn't isolate any replicas that are not the leader! ClusterState: " + printClusterStateInfo());-+long diffMs = (System.currentTimeMillis() - startMs);log.info("Took " + diffMs + " ms to see all replicas become active.");-+List<Replica> replicas = new ArrayList<Replica>();replicas.addAll(notLeaders.values());return replicas;- }-+ }+protected String printClusterStateInfo() throws Exception {return printClusterStateInfo(null);}diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java b/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.javaindex 645a8fbfff4..63c4299ea47 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java@@ -424,7 +424,7 @@ public class ZkTestServer {public void run() throws InterruptedException {log.info("STARTING ZK TEST SERVER");- // we don't call super.setUp+ // we don't call super.distribSetUpzooThread = new Thread() {@Override