lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [06/50] [abbrv] lucene-solr:jira/solr-11779: SOLR-12181: Improve test stability.
Date Tue, 22 May 2018 19:58:43 GMT
SOLR-12181: Improve test stability.


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

Branch: refs/heads/jira/solr-11779
Commit: b809d633ce6744b210e39d3c7ca72c4f8bfe8f4e
Parents: b3894d7
Author: Andrzej Bialecki <ab@apache.org>
Authored: Wed May 16 13:58:52 2018 +0200
Committer: Andrzej Bialecki <ab@apache.org>
Committed: Wed May 16 13:59:55 2018 +0200

----------------------------------------------------------------------
 .../org/apache/solr/cloud/CloudTestUtils.java   | 14 ++++-
 .../cloud/autoscaling/IndexSizeTriggerTest.java | 55 ++++++++++++++------
 2 files changed, 51 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b809d633/solr/core/src/test/org/apache/solr/cloud/CloudTestUtils.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/CloudTestUtils.java b/solr/core/src/test/org/apache/solr/cloud/CloudTestUtils.java
index 768cd91..5a05d4b 100644
--- a/solr/core/src/test/org/apache/solr/cloud/CloudTestUtils.java
+++ b/solr/core/src/test/org/apache/solr/cloud/CloudTestUtils.java
@@ -113,12 +113,24 @@ public class CloudTestUtils {
 
   /**
    * Return a {@link CollectionStatePredicate} that returns true if a collection has the
expected
-   * number of shards and replicas
+   * number of active shards and replicas
+   * @param expectedShards expected number of active shards
+   * @param expectedReplicas expected number of active replicas
    */
   public static CollectionStatePredicate clusterShape(int expectedShards, int expectedReplicas)
{
     return clusterShape(expectedShards, expectedReplicas, false);
   }
 
+  /**
+   * Return a {@link CollectionStatePredicate} that returns true if a collection has the
expected
+   * number of shards and replicas.
+   * <p>Note: for shards marked as inactive the current Solr behavior is that replicas
remain active.
+   * {@link org.apache.solr.cloud.autoscaling.sim.SimCloudManager} follows this behavior.</p>
+   * @param expectedShards expected number of shards
+   * @param expectedReplicas expected number of active replicas
+   * @param withInactive if true then count also inactive shards
+   * @return
+   */
   public static CollectionStatePredicate clusterShape(int expectedShards, int expectedReplicas,
boolean withInactive) {
     return (liveNodes, collectionState) -> {
       if (collectionState == null) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b809d633/solr/core/src/test/org/apache/solr/cloud/autoscaling/IndexSizeTriggerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/IndexSizeTriggerTest.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/IndexSizeTriggerTest.java
index 265a6c6..6acc1de 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/IndexSizeTriggerTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/IndexSizeTriggerTest.java
@@ -146,7 +146,7 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
 
     long waitForSeconds = 3 + random().nextInt(5);
     Map<String, Object> props = createTriggerProps(waitForSeconds);
-    try (IndexSizeTrigger trigger = new IndexSizeTrigger("index_size_trigger")) {
+    try (IndexSizeTrigger trigger = new IndexSizeTrigger("index_size_trigger1")) {
       trigger.configure(loader, cloudManager, props);
       trigger.init();
       trigger.setProcessor(noFirstRunProcessor);
@@ -242,14 +242,15 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
         CloudTestUtils.clusterShape(2, 2));
 
     long waitForSeconds = 3 + random().nextInt(5);
+    // add disabled trigger
     String setTriggerCommand = "{" +
         "'set-trigger' : {" +
-        "'name' : 'index_size_trigger'," +
+        "'name' : 'index_size_trigger2'," +
         "'event' : 'indexSize'," +
         "'waitFor' : '" + waitForSeconds + "s'," +
         "'aboveDocs' : 10," +
         "'belowDocs' : 4," +
-        "'enabled' : true," +
+        "'enabled' : false," +
         "'actions' : [{'name' : 'compute_plan', 'class' : 'solr.ComputePlanAction'}," +
         "{'name' : 'execute_plan', 'class' : '" + ExecutePlanAction.class.getName() + "'}]"
+
         "}}";
@@ -261,7 +262,7 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
         "'set-listener' : " +
         "{" +
         "'name' : 'capturing'," +
-        "'trigger' : 'index_size_trigger'," +
+        "'trigger' : 'index_size_trigger2'," +
         "'stage' : ['STARTED','ABORTED','SUCCEEDED','FAILED']," +
         "'beforeAction' : ['compute_plan','execute_plan']," +
         "'afterAction' : ['compute_plan','execute_plan']," +
@@ -276,7 +277,7 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
         "'set-listener' : " +
         "{" +
         "'name' : 'finished'," +
-        "'trigger' : 'index_size_trigger'," +
+        "'trigger' : 'index_size_trigger2'," +
         "'stage' : ['SUCCEEDED']," +
         "'class' : '" + FinishedProcessingListener.class.getName() + "'" +
         "}" +
@@ -286,17 +287,27 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
     assertEquals(response.get("result").toString(), "success");
 
 
-    for (int i = 0; i < 25; i++) {
+    for (int i = 0; i < 50; i++) {
       SolrInputDocument doc = new SolrInputDocument("id", "id-" + i);
       solrClient.add(collectionName, doc);
     }
     solrClient.commit(collectionName);
 
+    // enable the trigger
+    String resumeTriggerCommand = "{" +
+        "'resume-trigger' : {" +
+        "'name' : 'index_size_trigger2'" +
+        "}" +
+        "}";
+    req = createAutoScalingRequest(SolrRequest.METHOD.POST, resumeTriggerCommand);
+    response = solrClient.request(req);
+    assertEquals(response.get("result").toString(), "success");
+
     timeSource.sleep(TimeUnit.MILLISECONDS.convert(waitForSeconds + 1, TimeUnit.SECONDS));
 
     boolean await = finished.await(60000 / SPEED, TimeUnit.MILLISECONDS);
     assertTrue("did not finish processing in time", await);
-    CloudTestUtils.waitForState(cloudManager, collectionName, 10, TimeUnit.SECONDS, CloudTestUtils.clusterShape(4,
2));
+    CloudTestUtils.waitForState(cloudManager, collectionName, 20, TimeUnit.SECONDS, CloudTestUtils.clusterShape(6,
2, true));
     assertEquals(1, listenerEvents.size());
     List<CapturedEvent> events = listenerEvents.get("capturing");
     assertNotNull("'capturing' events not found", events);
@@ -351,12 +362,12 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
     long waitForSeconds = 3 + random().nextInt(5);
     String setTriggerCommand = "{" +
         "'set-trigger' : {" +
-        "'name' : 'index_size_trigger'," +
+        "'name' : 'index_size_trigger3'," +
         "'event' : 'indexSize'," +
         "'waitFor' : '" + waitForSeconds + "s'," +
         "'aboveDocs' : 40," +
         "'belowDocs' : 4," +
-        "'enabled' : true," +
+        "'enabled' : false," +
         "'actions' : [{'name' : 'compute_plan', 'class' : 'solr.ComputePlanAction'}," +
         "{'name' : 'execute_plan', 'class' : '" + ExecutePlanAction.class.getName() + "'}]"
+
         "}}";
@@ -368,7 +379,7 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
         "'set-listener' : " +
         "{" +
         "'name' : 'capturing'," +
-        "'trigger' : 'index_size_trigger'," +
+        "'trigger' : 'index_size_trigger3'," +
         "'stage' : ['STARTED','ABORTED','SUCCEEDED','FAILED']," +
         "'beforeAction' : ['compute_plan','execute_plan']," +
         "'afterAction' : ['compute_plan','execute_plan']," +
@@ -383,7 +394,7 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
         "'set-listener' : " +
         "{" +
         "'name' : 'finished'," +
-        "'trigger' : 'index_size_trigger'," +
+        "'trigger' : 'index_size_trigger3'," +
         "'stage' : ['SUCCEEDED']," +
         "'class' : '" + FinishedProcessingListener.class.getName() + "'" +
         "}" +
@@ -398,9 +409,19 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
     }
     solrClient.commit(collectionName);
 
+    // enable the trigger
+    String resumeTriggerCommand = "{" +
+        "'resume-trigger' : {" +
+        "'name' : 'index_size_trigger3'" +
+        "}" +
+        "}";
+    req = createAutoScalingRequest(SolrRequest.METHOD.POST, resumeTriggerCommand);
+    response = solrClient.request(req);
+    assertEquals(response.get("result").toString(), "success");
+
     timeSource.sleep(TimeUnit.MILLISECONDS.convert(waitForSeconds + 1, TimeUnit.SECONDS));
 
-    boolean await = finished.await(60000 / SPEED, TimeUnit.MILLISECONDS);
+    boolean await = finished.await(90000 / SPEED, TimeUnit.MILLISECONDS);
     assertTrue("did not finish processing in time", await);
     assertEquals(1, listenerEvents.size());
     List<CapturedEvent> events = listenerEvents.get("capturing");
@@ -483,7 +504,7 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
     // and have them capture all events once the trigger is enabled
     String setTriggerCommand = "{" +
         "'set-trigger' : {" +
-        "'name' : 'index_size_trigger'," +
+        "'name' : 'index_size_trigger4'," +
         "'event' : 'indexSize'," +
         "'waitFor' : '" + waitForSeconds + "s'," +
         // don't hit this limit when indexing
@@ -506,7 +527,7 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
         "'set-listener' : " +
         "{" +
         "'name' : 'capturing'," +
-        "'trigger' : 'index_size_trigger'," +
+        "'trigger' : 'index_size_trigger4'," +
         "'stage' : ['STARTED','ABORTED','SUCCEEDED','FAILED']," +
         "'beforeAction' : ['compute_plan','execute_plan']," +
         "'afterAction' : ['compute_plan','execute_plan']," +
@@ -521,7 +542,7 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
         "'set-listener' : " +
         "{" +
         "'name' : 'finished'," +
-        "'trigger' : 'index_size_trigger'," +
+        "'trigger' : 'index_size_trigger4'," +
         "'stage' : ['SUCCEEDED']," +
         "'class' : '" + FinishedProcessingListener.class.getName() + "'" +
         "}" +
@@ -533,7 +554,7 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
     // now enable the trigger
     String resumeTriggerCommand = "{" +
         "'resume-trigger' : {" +
-        "'name' : 'index_size_trigger'" +
+        "'name' : 'index_size_trigger4'" +
         "}" +
         "}";
     req = createAutoScalingRequest(SolrRequest.METHOD.POST, resumeTriggerCommand);
@@ -590,7 +611,7 @@ public class IndexSizeTriggerTest extends SolrCloudTestCase {
     // suspend the trigger first so that we can safely delete all docs
     String suspendTriggerCommand = "{" +
         "'suspend-trigger' : {" +
-        "'name' : 'index_size_trigger'" +
+        "'name' : 'index_size_trigger4'" +
         "}" +
         "}";
     req = createAutoScalingRequest(SolrRequest.METHOD.POST, suspendTriggerCommand);


Mime
View raw message