You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2018/02/28 12:23:27 UTC

[1/2] lucene-solr:branch_7x: SOLR-11407: Use all details of the query response in the handler response. More consistency in debug info from the test.

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 9b7e35e69 -> 84b635205


SOLR-11407: Use all details of the query response in the handler response.
More consistency in debug info from the test.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a5dc9442
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a5dc9442
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a5dc9442

Branch: refs/heads/branch_7x
Commit: a5dc944246e93ec09d5482421a8ec9ce22147289
Parents: 9b7e35e
Author: Andrzej Bialecki <ab...@apache.org>
Authored: Mon Feb 26 13:56:55 2018 +0100
Committer: Andrzej Bialecki <ab...@apache.org>
Committed: Wed Feb 28 13:22:21 2018 +0100

----------------------------------------------------------------------
 .../admin/AutoscalingHistoryHandler.java        |  6 ++-
 .../admin/AutoscalingHistoryHandlerTest.java    | 44 +++++++-------------
 2 files changed, 20 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a5dc9442/solr/core/src/java/org/apache/solr/handler/admin/AutoscalingHistoryHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/AutoscalingHistoryHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/AutoscalingHistoryHandler.java
index 1c568d6..f21bd2c 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/AutoscalingHistoryHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/AutoscalingHistoryHandler.java
@@ -125,11 +125,13 @@ public class AutoscalingHistoryHandler extends RequestHandlerBase implements Per
         .withHttpClient(coreContainer.getUpdateShardHandler().getHttpClient())
         .build()) {
       QueryResponse qr = cloudSolrClient.query(collection, params);
-      rsp.getValues().add("response", qr.getResults());
+      rsp.setAllValues(qr.getResponse());
     } catch (Exception e) {
       if ((e instanceof SolrException) && e.getMessage().contains("Collection not found")) {
         // 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 {
         throw e;
       }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a5dc9442/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java
index 43ad281..d927597 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java
@@ -23,6 +23,7 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 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.cloud.autoscaling.TriggerEventProcessorStage;
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
@@ -261,15 +262,7 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase {
 
     query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH,
       AutoscalingHistoryHandler.TRIGGER_PARAM, PREFIX + "_node_added_trigger");
-    QueryResponse rsp = solrClient.query(query);
-    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());
+    docs = queryAndAssertDocs(query, solrClient, 8);
 
     query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH,
         AutoscalingHistoryHandler.STAGE_PARAM, "STARTED");
@@ -279,8 +272,7 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase {
 
     query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH,
         AutoscalingHistoryHandler.NODE_PARAM, nodeAddedName);
-    docs = solrClient.query(query).getResults();
-    assertEquals(8, docs.size());
+    docs = queryAndAssertDocs(query, solrClient, 8);
     for (SolrDocument doc : docs) {
       assertTrue(doc.getFieldValues("event.property.nodeNames_ss").contains(nodeAddedName));
     }
@@ -301,15 +293,7 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase {
 
     query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH,
         AutoscalingHistoryHandler.COLLECTION_PARAM, COLL_NAME);
-    rsp = solrClient.query(query);
-    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());
+    docs = queryAndAssertDocs(query, solrClient, 5);
     assertEquals("AFTER_ACTION", docs.get(0).getFieldValue("stage_s"));
     assertEquals("compute_plan", docs.get(0).getFieldValue("action_s"));
 
@@ -357,16 +341,20 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase {
     query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH,
         AutoscalingHistoryHandler.TRIGGER_PARAM, PREFIX + "_node_lost_trigger",
         AutoscalingHistoryHandler.COLLECTION_PARAM, COLL_NAME);
-    rsp = solrClient.query(query);
-    docs = rsp.getResults();
-    if (docs.size() != 5) {
-      log.info("Cluster state: " + solrClient.getZkStateReader().getClusterState());
+    docs = queryAndAssertDocs(query, solrClient, 5);
+  }
+
+  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("Wrong response: ", rsp);
-      log.info("Full response: " + solrClient.query(query));
+      log.info("Full response: " + client.query(query));
     }
-
-    assertEquals(5, docs.size());
+    assertEquals("Wrong number of documents", expected, docs.size());
+    return docs;
   }
 
   private void waitForRecovery(String collection) throws Exception {


[2/2] lucene-solr:branch_7x: SOLR-11407: Wait for collections to recover before starting the test.

Posted by ab...@apache.org.
SOLR-11407: Wait for collections to recover before starting the test.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/84b63520
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/84b63520
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/84b63520

Branch: refs/heads/branch_7x
Commit: 84b6352057257463d19e67e1c8e544bd57d6b4db
Parents: a5dc944
Author: Andrzej Bialecki <ab...@apache.org>
Authored: Wed Feb 28 13:12:51 2018 +0100
Committer: Andrzej Bialecki <ab...@apache.org>
Committed: Wed Feb 28 13:23:07 2018 +0100

----------------------------------------------------------------------
 .../solr/handler/admin/AutoscalingHistoryHandlerTest.java   | 9 ++++++---
 .../src/java/org/apache/solr/cloud/SolrCloudTestCase.java   | 4 ++--
 2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84b63520/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java
index d927597..9860070 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java
@@ -93,6 +93,8 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase {
         .setCreateNodeSet(String.join(",", otherNodes))
         .setMaxShardsPerNode(3)
         .process(solrClient);
+    waitForRecovery(CollectionAdminParams.SYSTEM_COLL);
+    waitForRecovery(COLL_NAME);
   }
 
   public static class TesterListener extends TriggerListenerBase {
@@ -350,14 +352,15 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase {
     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));
+      ModifiableSolrParams fullQuery = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH);
+      log.info("Full response: " + client.query(fullQuery));
     }
     assertEquals("Wrong number of documents", expected, docs.size());
     return docs;
   }
 
-  private void waitForRecovery(String collection) throws Exception {
+  private static void waitForRecovery(String collection) throws Exception {
+    log.info("Waiting for recovery of " + collection);
     boolean recovered = false;
     for (int i = 0; i < 300; i++) {
       ClusterState state = solrClient.getZkStateReader().getClusterState();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84b63520/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java
index 42c4577..b8bf1f4 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java
@@ -243,7 +243,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
   /**
    * Get the collection state for a particular collection
    */
-  protected DocCollection getCollectionState(String collectionName) {
+  protected static DocCollection getCollectionState(String collectionName) {
     return cluster.getSolrClient().getZkStateReader().getClusterState().getCollection(collectionName);
   }
 
@@ -256,7 +256,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
    * @param collection  the collection to watch
    * @param predicate   a predicate to match against the collection state
    */
-  protected void waitForState(String message, String collection, CollectionStatePredicate predicate) {
+  protected static void waitForState(String message, String collection, CollectionStatePredicate predicate) {
     AtomicReference<DocCollection> state = new AtomicReference<>();
     AtomicReference<Set<String>> liveNodesLastSeen = new AtomicReference<>();
     try {