Skip to content

Apache Lucene open-source search software

SOLR-7599: Inline startCloudJetty method into ShardRoutingCustomTest

Shalin Shekhar Mangar8ea0d522ed0a
diff --git a/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java b/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java
index ae418fd4051..f060c55a4b3 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java
@@ -17,6 +17,10 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
+import java.io.File;
+
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -51,7 +55,31 @@ public class ShardRoutingCustomTest extends AbstractFullDistribZkTestBase {
private void doCustomSharding() throws Exception {
printLayout();
- startCloudJetty(collection, "shardA");
+ int totalReplicas = getTotalReplicas(collection);
+
+ File jettyDir = createTempDir("jetty").toFile();
+ jettyDir.mkdirs();
+ setupJettySolrHome(jettyDir);
+ JettySolrRunner j = createJetty(jettyDir, createTempDir().toFile().getAbsolutePath(), "shardA", "solrconfig.xml", null);
+ jettys.add(j);
+ SolrClient client = createNewSolrClient(j.getLocalPort());
+ clients.add(client);
+
+ int retries = 60;
+ while (--retries >= 0) {
+ // total replicas changed.. assume it was us
+ if (getTotalReplicas(collection) != totalReplicas) {
+ break;
+ }
+ Thread.sleep(500);
+ }
+
+ if (retries <= 0) {
+ fail("Timeout waiting for " + j + " to appear in clusterstate");
+ printLayout();
+ }
+
+ updateMappingsFromZk(this.jettys, this.clients);
printLayout();
}
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.java
index 060d0638a83..9d947d4688a 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
@@ -419,42 +419,6 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
}
- protected SolrClient startCloudJetty(String collection, String shard) throws Exception {
- // TODO: use the collection string!!!!
- collection = DEFAULT_COLLECTION;
-
- int totalReplicas = getTotalReplicas(collection);
-
-
- int cnt = this.jettyIntCntr.incrementAndGet();
-
- File jettyDir = createTempDir("jetty").toFile();
- jettyDir.mkdirs();
- setupJettySolrHome(jettyDir);
- JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty" + cnt, shard, "solrconfig.xml", null);
- jettys.add(j);
- SolrClient client = createNewSolrClient(j.getLocalPort());
- clients.add(client);
-
- int retries = 60;
- while (--retries >= 0) {
- // total replicas changed.. assume it was us
- if (getTotalReplicas(collection) != totalReplicas) {
- break;
- }
- Thread.sleep(500);
- }
-
- if (retries <= 0) {
- fail("Timeout waiting for " + j + " to appear in clusterstate");
- printLayout();
- }
-
- updateMappingsFromZk(this.jettys, this.clients);
- return client;
- }
-
-
/* Total number of replicas (number of cores serving an index to the collection) shown by the cluster state */
protected int getTotalReplicas(String collection) {
ZkStateReader zkStateReader = cloudClient.getZkStateReader();