mirror of https://github.com/apache/lucene.git
SOLR-9110: removing static members from tests.
This commit is contained in:
parent
6d530e0857
commit
9863eea256
|
@ -64,9 +64,6 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase{
|
||||||
|
|
||||||
private static Integer toDocId;
|
private static Integer toDocId;
|
||||||
|
|
||||||
private static CloudSolrClient cloudClient;
|
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setupCluster() throws Exception {
|
public static void setupCluster() throws Exception {
|
||||||
final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
|
final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
|
||||||
|
@ -90,11 +87,9 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase{
|
||||||
configName,
|
configName,
|
||||||
collectionProperties));
|
collectionProperties));
|
||||||
|
|
||||||
|
|
||||||
// get the set of nodes where replicas for the "to" collection exist
|
// get the set of nodes where replicas for the "to" collection exist
|
||||||
Set<String> nodeSet = new HashSet<>();
|
Set<String> nodeSet = new HashSet<>();
|
||||||
cloudClient = cluster.getSolrClient();
|
ZkStateReader zkStateReader = cluster.getSolrClient().getZkStateReader();
|
||||||
ZkStateReader zkStateReader = cloudClient.getZkStateReader();
|
|
||||||
ClusterState cs = zkStateReader.getClusterState();
|
ClusterState cs = zkStateReader.getClusterState();
|
||||||
for (Slice slice : cs.getCollection(toColl).getActiveSlices())
|
for (Slice slice : cs.getCollection(toColl).getActiveSlices())
|
||||||
for (Replica replica : slice.getReplicas())
|
for (Replica replica : slice.getReplicas())
|
||||||
|
@ -138,7 +133,7 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase{
|
||||||
for (String c : new String[]{ toColl, fromColl }) {
|
for (String c : new String[]{ toColl, fromColl }) {
|
||||||
try {
|
try {
|
||||||
CollectionAdminRequest.Delete req = CollectionAdminRequest.deleteCollection(c);
|
CollectionAdminRequest.Delete req = CollectionAdminRequest.deleteCollection(c);
|
||||||
req.process(cloudClient);
|
req.process(cluster.getSolrClient());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// don't fail the test
|
// don't fail the test
|
||||||
log.warn("Could not delete collection {} after test completed due to: " + e, c);
|
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 {
|
throws SolrServerException, IOException {
|
||||||
// verify the join with fromIndex works
|
// verify the join with fromIndex works
|
||||||
final String fromQ = "match_s:c match_s:not_1_0_score_after_weight_normalization";
|
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)
|
final String joinQ = "{!join " + anyScoreMode(isScoresTest)
|
||||||
+ "from=join_s fromIndex=" + fromColl +
|
+ "from=join_s fromIndex=" + fromColl +
|
||||||
" to=join_s}" + fromQ;
|
" to=join_s}" + fromQ;
|
||||||
QueryRequest qr = new QueryRequest(params("collection", toColl, "q", joinQ, "fl", "id,get_s,score"));
|
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();
|
SolrDocumentList hits = rsp.getResults();
|
||||||
assertTrue("Expected 1 doc, got "+hits, hits.getNumFound() == 1);
|
assertTrue("Expected 1 doc, got "+hits, hits.getNumFound() == 1);
|
||||||
SolrDocument doc = hits.get(0);
|
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
|
// create an alias for the fromIndex and then query through the alias
|
||||||
String alias = fromColl+"Alias";
|
String alias = fromColl+"Alias";
|
||||||
CollectionAdminRequest.CreateAlias request = CollectionAdminRequest.createAlias(alias,fromColl);
|
CollectionAdminRequest.CreateAlias request = CollectionAdminRequest.createAlias(alias,fromColl);
|
||||||
request.process(cloudClient);
|
request.process(client);
|
||||||
|
|
||||||
{
|
{
|
||||||
final String joinQ = "{!join " + anyScoreMode(isScoresTest)
|
final String joinQ = "{!join " + anyScoreMode(isScoresTest)
|
||||||
+ "from=join_s fromIndex=" + alias + " to=join_s}"+fromQ;
|
+ "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 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();
|
final SolrDocumentList hits = rsp.getResults();
|
||||||
assertTrue("Expected 1 doc", hits.getNumFound() == 1);
|
assertTrue("Expected 1 doc", hits.getNumFound() == 1);
|
||||||
SolrDocument doc = hits.get(0);
|
SolrDocument doc = hits.get(0);
|
||||||
|
@ -195,7 +191,7 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase{
|
||||||
final String joinQ = "{!join " + (anyScoreMode(isScoresTest))
|
final String joinQ = "{!join " + (anyScoreMode(isScoresTest))
|
||||||
+ "from=join_s fromIndex=" + fromColl + " to=join_s}match_s:d";
|
+ "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 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();
|
final SolrDocumentList hits = rsp.getResults();
|
||||||
assertTrue("Expected no hits", hits.getNumFound() == 0);
|
assertTrue("Expected no hits", hits.getNumFound() == 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,6 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
|
||||||
|
|
||||||
final static String people = "people";
|
final static String people = "people";
|
||||||
final static String depts = "departments";
|
final static String depts = "departments";
|
||||||
private static CloudSolrClient client;
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setupCluster() throws Exception {
|
public static void setupCluster() throws Exception {
|
||||||
|
@ -72,7 +71,7 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
|
||||||
assertNotNull(cluster.createCollection(depts, shards, replicas,
|
assertNotNull(cluster.createCollection(depts, shards, replicas,
|
||||||
configName, collectionProperties));
|
configName, collectionProperties));
|
||||||
|
|
||||||
client = cluster.getSolrClient();
|
CloudSolrClient client = cluster.getSolrClient();
|
||||||
client.setDefaultCollection(people);
|
client.setDefaultCollection(people);
|
||||||
|
|
||||||
ZkStateReader zkStateReader = client.getZkStateReader();
|
ZkStateReader zkStateReader = client.getZkStateReader();
|
||||||
|
@ -105,7 +104,7 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
|
||||||
"depts.rows",""+(deptMultiplier*2),
|
"depts.rows",""+(deptMultiplier*2),
|
||||||
"depts.logParamsList","q,fl,rows,row.dept_ss_dv"}));
|
"depts.logParamsList","q,fl,rows,row.dept_ss_dv"}));
|
||||||
final QueryResponse rsp = new QueryResponse();
|
final QueryResponse rsp = new QueryResponse();
|
||||||
rsp.setResponse(client.request(qr, people));
|
rsp.setResponse(cluster.getSolrClient().request(qr, people));
|
||||||
final SolrDocumentList hits = rsp.getResults();
|
final SolrDocumentList hits = rsp.getResults();
|
||||||
|
|
||||||
assertEquals(peopleMultiplier, hits.getNumFound());
|
assertEquals(peopleMultiplier, hits.getNumFound());
|
||||||
|
@ -197,7 +196,7 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
|
||||||
if (rarely()) {
|
if (rarely()) {
|
||||||
upd.append(commit("softCommit", "true"));
|
upd.append(commit("softCommit", "true"));
|
||||||
}
|
}
|
||||||
if (!rarely() || !iterator.hasNext()) {
|
if (rarely() || !iterator.hasNext()) {
|
||||||
if (!iterator.hasNext()) {
|
if (!iterator.hasNext()) {
|
||||||
upd.append(commit("softCommit", "false"));
|
upd.append(commit("softCommit", "false"));
|
||||||
}
|
}
|
||||||
|
@ -206,7 +205,7 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
|
||||||
ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update");
|
ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update");
|
||||||
req.addContentStream(new ContentStreamBase.StringStream(upd.toString(),"text/xml"));
|
req.addContentStream(new ContentStreamBase.StringStream(upd.toString(),"text/xml"));
|
||||||
|
|
||||||
client.request(req, collection);
|
cluster.getSolrClient().request(req, collection);
|
||||||
upd.setLength("<update>".length());
|
upd.setLength("<update>".length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue