kotman12 commented on code in PR #4149:
URL: https://github.com/apache/solr/pull/4149#discussion_r3025624341


##########
solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerDistribTest.java:
##########
@@ -0,0 +1,522 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.handler.admin;
+
+import java.util.Map;
+import org.apache.solr.BaseDistributedSearchTestCase;
+import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.client.solrj.response.InputStreamResponseParser;
+import org.apache.solr.client.solrj.response.LukeResponse;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.request.SolrQueryRequestBase;
+import org.apache.solr.update.AddUpdateCommand;
+import org.apache.solr.update.CommitUpdateCommand;
+import org.apache.solr.util.BaseTestHarness;
+import org.junit.Test;
+
+public class LukeRequestHandlerDistribTest extends 
BaseDistributedSearchTestCase {
+
+  private static final Long NUM_DOCS = 20L;
+
+  public LukeRequestHandlerDistribTest() {
+    fixShardCount(2);
+  }
+
+  private LukeResponse requestLuke() throws Exception {
+    return requestLuke(new ModifiableSolrParams());
+  }
+
+  private LukeResponse requestLuke(ModifiableSolrParams extra) throws 
Exception {
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    params.set("qt", "/admin/luke");
+    params.set("numTerms", "0");
+    params.add(extra);
+
+    // query() sends to control and a random shard with shards param, compares 
responses
+    handle.put("QTime", SKIPVAL);
+    handle.put("index", SKIP);
+    handle.put("shards", SKIP);
+    // Detailed per-field stats (distinct, topTerms, histogram) are kept 
per-shard in
+    // distributed mode and intentionally excluded from the aggregated 
top-level fields.
+    // Local mode includes them inline, so skip them in the comparison.
+    handle.put("distinct", SKIP);
+    handle.put("topTerms", SKIP);
+    handle.put("histogram", SKIP);
+    QueryResponse qr = query(params);
+    LukeResponse rsp = new LukeResponse();
+    rsp.setResponse(qr.getResponse());
+
+    return rsp;
+  }
+
+  private void assertLukeXPath(ModifiableSolrParams extra, String... xpaths) 
throws Exception {
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    params.set("qt", "/admin/luke");
+    params.set("numTerms", "0");
+    params.set("wt", "xml");
+    params.set("shards", shards);
+    params.add(extra);
+    QueryRequest req = new QueryRequest(params);
+    req.setResponseParser(new InputStreamResponseParser("xml"));
+    NamedList<Object> raw = controlClient.request(req);
+    String xml = InputStreamResponseParser.consumeResponseToString(raw);
+    String failedXpath = BaseTestHarness.validateXPath(xml, xpaths);
+    assertNull("XPath validation failed: " + failedXpath + "\nResponse:\n" + 
xml, failedXpath);
+  }
+
+  private void indexTestData() throws Exception {
+    for (int i = 0; i < NUM_DOCS; i++) {
+      index("id", String.valueOf(i), "name", "name_" + i, "subject", "subject 
value " + (i % 5));
+    }
+    commit();
+  }
+
+  @Test
+  @ShardsFixed(num = 2)
+  public void testDistributedAggregate() throws Exception {
+    indexTestData();
+
+    LukeResponse rsp = requestLuke();
+
+    assertEquals("aggregated numDocs should equal total docs", NUM_DOCS, 
rsp.getNumDocs());
+    assertTrue("aggregated maxDoc should be > 0", rsp.getMaxDoc() > 0);
+    assertNotNull("deletedDocs should be present", rsp.getDeletedDocs());
+
+    Map<String, LukeResponse> shardResponses = rsp.getShardResponses();

Review Comment:
   This includes index information that comes with the default luke response 
(as well as with show=index). I didn't want to just omit all those fields that 
couldn't be easily merged in the distributed mode (version, indexCommit, 
isCurrent, segmentsFile, directory, ...). I suppose you could but it didn't 
feel intuitive and that info could be seen as useful.
   
   I think the initial motivation for SHARDS_INFO is a little different. I'm 
not opposed to it but also don't see a big benefit of adding another flag to 
the already many flags in luke. This part of the response is cheap anyway.
   
   OTOH one could argue that you may want this info for all _replicas_ not just 
from a single replica from each shard, although this would be more custom so 
perhaps not worth the effort. Something like that could be behind a flag...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to