SOLR-11407: Use all details of the query response in the handler response.

More consistency in debug info from the test.
This commit is contained in:
Andrzej Bialecki 2018-02-26 13:56:55 +01:00
parent 86be873915
commit a2eb7f3880
2 changed files with 21 additions and 31 deletions

View File

@ -128,11 +128,13 @@ public class AutoscalingHistoryHandler extends RequestHandlerBase implements Per
.withHttpClient(coreContainer.getUpdateShardHandler().getHttpClient()) .withHttpClient(coreContainer.getUpdateShardHandler().getHttpClient())
.build()) { .build()) {
QueryResponse qr = cloudSolrClient.query(collection, params); QueryResponse qr = cloudSolrClient.query(collection, params);
rsp.getValues().add("response", qr.getResults()); rsp.setAllValues(qr.getResponse());
} catch (Exception e) { } catch (Exception e) {
if ((e instanceof SolrException) && e.getMessage().contains("Collection not found")) { if ((e instanceof SolrException) && e.getMessage().contains("Collection not found")) {
// relatively benign // relatively benign
LOG.info("Collection " + collection + " does not exist."); String msg = "Collection " + collection + " does not exist.";
LOG.info(msg);
rsp.getValues().add("error", msg);
} else { } else {
throw e; throw e;
} }

View File

@ -23,6 +23,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.cloud.autoscaling.TriggerEventProcessorStage; import org.apache.solr.client.solrj.cloud.autoscaling.TriggerEventProcessorStage;
import org.apache.solr.client.solrj.embedded.JettySolrRunner; import org.apache.solr.client.solrj.embedded.JettySolrRunner;
@ -262,15 +263,7 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase {
query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH, query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH,
AutoscalingHistoryHandler.TRIGGER_PARAM, PREFIX + "_node_added_trigger"); AutoscalingHistoryHandler.TRIGGER_PARAM, PREFIX + "_node_added_trigger");
QueryResponse rsp = solrClient.query(query); docs = queryAndAssertDocs(query, solrClient, 8);
docs = rsp.getResults();
if (docs.size() != 8) {
log.info("Cluster state: " + solrClient.getZkStateReader().getClusterState());
query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH);
log.info("Wrong response: ", rsp);
log.info("Full response: " + solrClient.query(query));
}
assertEquals(8, docs.size());
query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH, query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH,
AutoscalingHistoryHandler.STAGE_PARAM, "STARTED"); AutoscalingHistoryHandler.STAGE_PARAM, "STARTED");
@ -280,8 +273,7 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase {
query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH, query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH,
AutoscalingHistoryHandler.NODE_PARAM, nodeAddedName); AutoscalingHistoryHandler.NODE_PARAM, nodeAddedName);
docs = solrClient.query(query).getResults(); docs = queryAndAssertDocs(query, solrClient, 8);
assertEquals(8, docs.size());
for (SolrDocument doc : docs) { for (SolrDocument doc : docs) {
assertTrue(doc.getFieldValues("event.property.nodeNames_ss").contains(nodeAddedName)); assertTrue(doc.getFieldValues("event.property.nodeNames_ss").contains(nodeAddedName));
} }
@ -302,15 +294,7 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase {
query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH, query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH,
AutoscalingHistoryHandler.COLLECTION_PARAM, COLL_NAME); AutoscalingHistoryHandler.COLLECTION_PARAM, COLL_NAME);
rsp = solrClient.query(query); docs = queryAndAssertDocs(query, solrClient, 5);
docs = rsp.getResults();
if (docs.size() != 5) {
log.info("Cluster state: " + solrClient.getZkStateReader().getClusterState());
query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH);
log.info("Wrong response: ", rsp);
log.info("Full response: " + solrClient.query(query));
}
assertEquals(5, docs.size());
assertEquals("AFTER_ACTION", docs.get(0).getFieldValue("stage_s")); assertEquals("AFTER_ACTION", docs.get(0).getFieldValue("stage_s"));
assertEquals("compute_plan", docs.get(0).getFieldValue("action_s")); assertEquals("compute_plan", docs.get(0).getFieldValue("action_s"));
@ -359,16 +343,20 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase {
query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH, query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH,
AutoscalingHistoryHandler.TRIGGER_PARAM, PREFIX + "_node_lost_trigger", AutoscalingHistoryHandler.TRIGGER_PARAM, PREFIX + "_node_lost_trigger",
AutoscalingHistoryHandler.COLLECTION_PARAM, COLL_NAME); AutoscalingHistoryHandler.COLLECTION_PARAM, COLL_NAME);
rsp = solrClient.query(query); docs = queryAndAssertDocs(query, solrClient, 5);
docs = rsp.getResults(); }
if (docs.size() != 5) {
log.info("Cluster state: " + solrClient.getZkStateReader().getClusterState());
query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH);
log.info("Wrong response: ", rsp);
log.info("Full response: " + solrClient.query(query));
}
assertEquals(5, docs.size()); private SolrDocumentList queryAndAssertDocs(ModifiableSolrParams query, SolrClient client, int expected) throws Exception {
QueryResponse rsp = client.query(query);
SolrDocumentList docs = rsp.getResults();
if (docs.size() != expected) {
log.info("History query: " + query);
log.info("Wrong response: " + rsp);
query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH);
log.info("Full response: " + client.query(query));
}
assertEquals("Wrong number of documents", expected, docs.size());
return docs;
} }
private void waitForRecovery(String collection) throws Exception { private void waitForRecovery(String collection) throws Exception {