SOLR-9110: removing static members from tests.

This commit is contained in:
Mikhail Khludnev 2016-05-27 23:59:47 +03:00
parent 50658dd93d
commit 2391b5b81d
2 changed files with 11 additions and 16 deletions

View File

@ -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);
}

View File

@ -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());
}
}