Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions solr/core/src/test/org/apache/solr/TestDistributedSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.solr.client.solrj.RemoteSolrException;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.SolrQuery;
import org.apache.solr.client.solrj.response.FacetField;
import org.apache.solr.client.solrj.response.FieldStatsInfo;
Expand Down Expand Up @@ -615,18 +616,13 @@ public void test() throws Exception {

// basic spellcheck testing
query(
"q",
"toyata",
"fl",
"id,lowerfilt",
"spellcheck",
true,
"spellcheck.q",
"toyata",
"qt",
"/spellCheckCompRH_Direct",
"shards.qt",
"/spellCheckCompRH_Direct");
params(
"q", "toyata",
"fl", "id,lowerfilt",
"spellcheck", "true",
"spellcheck.q", "toyata",
"shards.qt", "/spellCheckCompRH_Direct"));

stress = 0; // turn off stress... we want to tex max combos in min time
for (int i = 0; i < 25 * RANDOM_MULTIPLIER; i++) {
Expand Down Expand Up @@ -1592,6 +1588,7 @@ public void test() throws Exception {
Thread.sleep(100);

queryPartialResults(
"/select",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think I even like better this bit of verbose ness!

upShards,
upClients,
"q",
Expand All @@ -1610,6 +1607,7 @@ public void test() throws Exception {
"true");

queryPartialResults(
"/select",
upShards,
upClients,
"q",
Expand All @@ -1627,6 +1625,7 @@ public void test() throws Exception {

// test group query
queryPartialResults(
"/select",
upShards,
upClients,
"q",
Expand All @@ -1651,6 +1650,7 @@ public void test() throws Exception {
"true");

queryPartialResults(
"/select",
upShards,
upClients,
"q",
Expand All @@ -1665,6 +1665,7 @@ public void test() throws Exception {
"true");

queryPartialResults(
"/spellCheckCompRH_Direct",
upShards,
upClients,
"q",
Expand All @@ -1673,8 +1674,6 @@ public void test() throws Exception {
"true",
"spellcheck.q",
"toyata",
"qt",
"/spellCheckCompRH_Direct",
"shards.qt",
"/spellCheckCompRH_Direct",
ShardParams.SHARDS_INFO,
Expand Down Expand Up @@ -1907,7 +1906,11 @@ protected void checkMinCountsRange(List<RangeFacet.Count> counts, Object[] pairs
}

protected void queryPartialResults(
final List<String> upShards, final List<SolrClient> upClients, Object... q) throws Exception {
String requestHandler,
final List<String> upShards,
final List<SolrClient> upClients,
Object... q)
throws Exception {

final ModifiableSolrParams params = new ModifiableSolrParams();

Expand All @@ -1916,7 +1919,8 @@ protected void queryPartialResults(
}
// TODO: look into why passing true causes fails
params.set("distrib", "false");
final QueryResponse controlRsp = controlClient.query(params);
final QueryResponse controlRsp =
new QueryRequest(requestHandler, params).process(controlClient);
// if time.allowed is specified then even a control response can return a partialResults header
if (params.get(CommonParams.TIME_ALLOWED) == null) {
validateControlData(controlRsp);
Expand All @@ -1928,7 +1932,7 @@ protected void queryPartialResults(
if (upClients.size() == 0) {
return;
}
QueryResponse rsp = queryRandomUpServer(params, upClients);
QueryResponse rsp = queryRandomUpServer(requestHandler, params, upClients);

comparePartialResponses(rsp, upShards);

Expand All @@ -1948,7 +1952,9 @@ public Object call() {
int which = r.nextInt(upClients.size());
SolrClient client = upClients.get(which);
try {
QueryResponse rsp = client.query(new ModifiableSolrParams(params));
QueryResponse rsp =
new QueryRequest(requestHandler, new ModifiableSolrParams(params))
.process(client);
if (verifyStress) {
comparePartialResponses(rsp, upShards);
}
Expand All @@ -1971,7 +1977,7 @@ public Object call() {
}

protected QueryResponse queryRandomUpServer(
ModifiableSolrParams params, List<SolrClient> upClients)
String requestHandler, ModifiableSolrParams params, List<SolrClient> upClients)
throws SolrServerException, IOException {
// query a random "up" server
SolrClient client;
Expand All @@ -1982,7 +1988,7 @@ protected QueryResponse queryRandomUpServer(
client = upClients.get(which);
}

return client.query(params);
return new QueryRequest(requestHandler, params).process(client);
}

protected void comparePartialResponses(QueryResponse rsp, List<String> upShards) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ private void doOptimisticLockingAndUpdating() throws Exception {
expected.add(val);
}

QueryRequest qr = new QueryRequest(params("qt", "/get", "id", "1000"));
QueryRequest qr = new QueryRequest("/get", params("id", "1000"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so much nicer!

for (SolrClient client : clients) {
val += 10;
NamedList<?> rsp = client.request(qr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.request.LukeRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
Expand Down Expand Up @@ -883,11 +884,12 @@ public SentinelIntSet assertFullWalkNoDups(int maxSize, SolrParams params) throw
public void assertFullWalkNoDups(SolrParams params, Consumer<SolrDocument> consumer)
throws Exception {

final String requestHandler = params.get(CommonParams.QT, "/select");
String cursorMark = CURSOR_MARK_START;
int docsOnThisPage = Integer.MAX_VALUE;
while (0 < docsOnThisPage) {
final SolrParams p = p(params, CURSOR_MARK_PARAM, cursorMark);
QueryResponse rsp = cloudClient.query(p);
QueryResponse rsp = new QueryRequest(requestHandler, p).process(cloudClient);
String nextCursorMark = assertHashNextCursorMark(rsp);
SolrDocumentList docs = extractDocList(rsp);
docsOnThisPage = docs.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,7 @@ protected void sendDoc(int docId) throws Exception {
*/
protected Long assertDocExists(SolrClient solr, String docId, Long expVers) throws Exception {
QueryRequest qr =
new QueryRequest(
params("qt", "/get", "id", docId, "distrib", "false", "fl", "id,_version_"));
new QueryRequest("/get", params("id", docId, "distrib", "false", "fl", "id,_version_"));
NamedList<?> rsp = solr.request(qr);
SolrDocument doc = (SolrDocument) rsp.get("doc");
String match = JSONTestUtil.matchObj("/id", doc, docId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ protected void assertDocExists(SolrClient solr, String docId) throws Exception {

private NamedList<Object> realTimeGetDocId(SolrClient solr, String docId)
throws SolrServerException, IOException {
QueryRequest qr = new QueryRequest(params("qt", "/get", "id", docId, "distrib", "false"));
QueryRequest qr = new QueryRequest("/get", params("id", docId, "distrib", "false"));
return solr.request(qr);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
Expand Down Expand Up @@ -130,7 +131,8 @@ public void doRootShardRoutingTest() throws Exception {

// assert RTG request respects _route_ param
QueryResponse routeRsp =
getRandomSolrClient().query(params("qt", "/get", "id", "2", "_route_", "1"));
new QueryRequest("/get", params("id", "2", "_route_", "1"))
.process(getRandomSolrClient());
SolrDocument results = (SolrDocument) routeRsp.getResponse().get("doc");
assertNotNull(
"RTG should find doc because _route_ was set to the root documents' ID", results);
Expand All @@ -142,7 +144,8 @@ public void doRootShardRoutingTest() throws Exception {

// assert all docs are indexed inside the same block
QueryResponse rsp =
getRandomSolrClient().query(params("qt", "/get", "id", "1", "fl", "*, [child]"));
new QueryRequest("/get", params("id", "1", "fl", "*, [child]"))
.process(getRandomSolrClient());
SolrDocument val = (SolrDocument) rsp.getResponse().get("doc");
assertEquals("1", val.getFieldValue("id"));
@SuppressWarnings({"unchecked"})
Expand Down Expand Up @@ -234,7 +237,8 @@ public void doNestedInplaceUpdateTest() throws Exception {
if (random().nextBoolean()) {
// assert RTG request respects _route_ param
QueryResponse routeRsp =
getRandomSolrClient().query(params("qt", "/get", "id", "2", "_route_", "1"));
new QueryRequest("/get", params("id", "2", "_route_", "1"))
.process(getRandomSolrClient());
SolrDocument results = (SolrDocument) routeRsp.getResponse().get("doc");
assertNotNull(
"RTG should find doc because _route_ was set to the root documents' ID", results);
Expand All @@ -249,7 +253,8 @@ public void doNestedInplaceUpdateTest() throws Exception {
if (random().nextBoolean()) {
// assert all docs are indexed inside the same block
QueryResponse rsp =
getRandomSolrClient().query(params("qt", "/get", "id", "1", "fl", "*, [child]"));
new QueryRequest("/get", params("id", "1", "fl", "*, [child]"))
.process(getRandomSolrClient());
SolrDocument val = (SolrDocument) rsp.getResponse().get("doc");
assertEquals("1", val.getFieldValue("id"));
assertInplaceCounter(id1InPlaceCounter, val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Map;
import java.util.SequencedMap;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ShardParams;
Expand Down Expand Up @@ -325,7 +326,7 @@ public void doAtomicUpdate() throws Exception {
client.add(sdoc("id", "b!doc", "foo_i", map("inc", 1)));
expectedVal++;

QueryResponse rsp = client.query(params("qt", "/get", "id", "b!doc"));
QueryResponse rsp = new QueryRequest("/get", params("id", "b!doc")).process(client);
Object val = ((Map) rsp.getResponse().get("doc")).get("foo_i");
assertEquals((Integer) expectedVal, val);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Map;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
Expand Down Expand Up @@ -336,9 +337,9 @@ void doRTG(String ids, String versions) throws Exception {
expectedIds.put(strs.get(i), Long.valueOf(verS.get(i)));
}

solrClient.query(params("qt", "/get", "ids", ids));
new QueryRequest("/get", params("ids", ids)).process(solrClient);

QueryResponse rsp = cloudClient.query(params("qt", "/get", "ids", ids));
QueryResponse rsp = new QueryRequest("/get", params("ids", ids)).process(cloudClient);
Map<String, Object> obtainedIds = new HashMap<>();
for (SolrDocument doc : rsp.getResults()) {
obtainedIds.put((String) doc.get("id"), doc.get(vfield));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ private void assertRTG(final SolrInputDocument[] knownDocs, final int[] docIds)

// NOTE: not using SolrClient.getById or getByIds because we want to force choice of "id" vs
// "ids" params
final ModifiableSolrParams params = params("qt", "/get");
final ModifiableSolrParams params = params();

// random fq -- nothing fancy, secondary concern for our test
final Integer FQ_MAX = usually() ? null : random().nextInt();
Expand Down Expand Up @@ -481,7 +481,7 @@ private void assertRTG(final SolrInputDocument[] knownDocs, final int[] docIds)

final Object rsp; // only here for an assertion message

var qr = new QueryRequest(params);
var qr = new QueryRequest("/get", params);
final SolrDocumentList docs =
switch (wt) {
case "javabin" -> { // the most common case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.solr.client.solrj.io.stream.SolrStream;
import org.apache.solr.client.solrj.io.stream.TupleStream;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.cloud.MiniSolrCloudCluster;
import org.apache.solr.common.params.SolrParams;
Expand Down Expand Up @@ -261,11 +262,12 @@ private void createDaemon(String daemonDef, String errMsg)
throws IOException, SolrServerException {
SolrClient client = cluster.getSolrClient();
// create a daemon
QueryResponse resp = client.query(CHECKPOINT_COLL, params("expr", daemonDef, "qt", "/stream"));
QueryResponse resp =
new QueryRequest("/stream", params("expr", daemonDef)).process(client, CHECKPOINT_COLL);
assertEquals(errMsg, 0, resp.getStatus());

// This should close and replace the current daemon and NOT leak threads.
resp = client.query(CHECKPOINT_COLL, params("expr", daemonDef, "qt", "/stream"));
resp = new QueryRequest("/stream", params("expr", daemonDef)).process(client, CHECKPOINT_COLL);
assertEquals(errMsg, 0, resp.getStatus());
}

Expand Down
Loading
Loading