Skip to content

Apache Lucene open-source search software

SOLR-9110: removing static members from tests.

Mikhail Khludnev2391b5b81dfa
diff --git a/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java b/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java
index d8e1b153d59..ae17ca98c51 100644
--- a/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java
@@ -64,9 +64,6 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase{
private static Integer toDocId;
- private static CloudSolrClient cloudClient;
-
-
@BeforeClass
public static void setupCluster() throws Exception {
final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
@@ -90,11 +87,9 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase{
configName,
collectionProperties));
-
// get the set of nodes where replicas for the "to" collection exist
Set<String> nodeSet = new HashSet<>();
- cloudClient = cluster.getSolrClient();
- ZkStateReader zkStateReader = cloudClient.getZkStateReader();
+ ZkStateReader zkStateReader = cluster.getSolrClient().getZkStateReader();
ClusterState cs = zkStateReader.getClusterState();
for (Slice slice : cs.getCollection(toColl).getActiveSlices())
for (Replica replica : slice.getReplicas())
@@ -138,7 +133,7 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase{
for (String c : new String[]{ toColl, fromColl }) {
try {
CollectionAdminRequest.Delete req = CollectionAdminRequest.deleteCollection(c);
- req.process(cloudClient);
+ req.process(cluster.getSolrClient());
} catch (Exception e) {
// don't fail the test
log.warn("Could not delete collection {} after test completed due to: " + e, c);
@@ -152,12 +147,13 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase{
throws SolrServerException, IOException {
// verify the join with fromIndex works
final String fromQ = "match_s:c match_s:not_1_0_score_after_weight_normalization";
+ CloudSolrClient client = cluster.getSolrClient();
{
final String joinQ = "{!join " + anyScoreMode(isScoresTest)
+ "from=join_s fromIndex=" + fromColl +
" to=join_s}" + fromQ;
QueryRequest qr = new QueryRequest(params("collection", toColl, "q", joinQ, "fl", "id,get_s,score"));
- QueryResponse rsp = new QueryResponse(cloudClient.request(qr), cloudClient);
+ QueryResponse rsp = new QueryResponse(client.request(qr), client);
SolrDocumentList hits = rsp.getResults();
assertTrue("Expected 1 doc, got "+hits, hits.getNumFound() == 1);
SolrDocument doc = hits.get(0);
@@ -172,13 +168,13 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase{
// create an alias for the fromIndex and then query through the alias
String alias = fromColl+"Alias";
CollectionAdminRequest.CreateAlias request = CollectionAdminRequest.createAlias(alias,fromColl);
- request.process(cloudClient);
+ request.process(client);
{
final String joinQ = "{!join " + anyScoreMode(isScoresTest)
+ "from=join_s fromIndex=" + alias + " to=join_s}"+fromQ;
final QueryRequest qr = new QueryRequest(params("collection", toColl, "q", joinQ, "fl", "id,get_s,score"));
- final QueryResponse rsp = new QueryResponse(cloudClient.request(qr), cloudClient);
+ final QueryResponse rsp = new QueryResponse(client.request(qr), client);
final SolrDocumentList hits = rsp.getResults();
assertTrue("Expected 1 doc", hits.getNumFound() == 1);
SolrDocument doc = hits.get(0);
@@ -195,7 +191,7 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase{
final String joinQ = "{!join " + (anyScoreMode(isScoresTest))
+ "from=join_s fromIndex=" + fromColl + " to=join_s}match_s:d";
final QueryRequest qr = new QueryRequest(params("collection", toColl, "q", joinQ, "fl", "id,get_s,score"));
- final QueryResponse rsp = new QueryResponse(cloudClient.request(qr), cloudClient);
+ final QueryResponse rsp = new QueryResponse(client.request(qr), client);
final SolrDocumentList hits = rsp.getResults();
assertTrue("Expected no hits", hits.getNumFound() == 0);
}
diff --git a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java
index 631c82e140e..0273a852bca 100644
--- a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java
+++ b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java
@@ -46,7 +46,6 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
final static String people = "people";
final static String depts = "departments";
- private static CloudSolrClient client;
@BeforeClass
public static void setupCluster() throws Exception {
@@ -72,7 +71,7 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
assertNotNull(cluster.createCollection(depts, shards, replicas,
configName, collectionProperties));
- client = cluster.getSolrClient();
+ CloudSolrClient client = cluster.getSolrClient();
client.setDefaultCollection(people);
ZkStateReader zkStateReader = client.getZkStateReader();
@@ -105,7 +104,7 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
"depts.rows",""+(deptMultiplier*2),
"depts.logParamsList","q,fl,rows,row.dept_ss_dv"}));
final QueryResponse rsp = new QueryResponse();
- rsp.setResponse(client.request(qr, people));
+ rsp.setResponse(cluster.getSolrClient().request(qr, people));
final SolrDocumentList hits = rsp.getResults();
assertEquals(peopleMultiplier, hits.getNumFound());
@@ -197,7 +196,7 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
if (rarely()) {
upd.append(commit("softCommit", "true"));
}
- if (!rarely() || !iterator.hasNext()) {
+ if (rarely() || !iterator.hasNext()) {
if (!iterator.hasNext()) {
upd.append(commit("softCommit", "false"));
}
@@ -206,7 +205,7 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update");
req.addContentStream(new ContentStreamBase.StringStream(upd.toString(),"text/xml"));
- client.request(req, collection);
+ cluster.getSolrClient().request(req, collection);
upd.setLength("<update>".length());
}
}