lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [lucene-solr] branch master updated: SOLR-13831: Context property _loop_iter_ should be a string in order to support variable expansion.
Date Thu, 05 Dec 2019 17:28:10 GMT
This is an automated email from the ASF dual-hosted git repository.

ab pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/master by this push:
     new d2b01ef  SOLR-13831: Context property _loop_iter_ should be a string in order to
support variable expansion.
d2b01ef is described below

commit d2b01ef28f918e2f3575081c206203be49889501
Author: Andrzej Bialecki <ab@apache.org>
AuthorDate: Thu Dec 5 18:25:49 2019 +0100

    SOLR-13831: Context property _loop_iter_ should be a string in order to support
    variable expansion.
---
 .../java/org/apache/solr/cloud/autoscaling/sim/SimScenario.java    | 2 +-
 .../org/apache/solr/cloud/autoscaling/sim/TestSimScenario.java     | 7 +++++--
 .../src/solrcloud-autoscaling-policy-preferences.adoc              | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/cloud/autoscaling/sim/SimScenario.java b/solr/core/src/java/org/apache/solr/cloud/autoscaling/sim/SimScenario.java
index 7914df7..187c66a 100644
--- a/solr/core/src/java/org/apache/solr/cloud/autoscaling/sim/SimScenario.java
+++ b/solr/core/src/java/org/apache/solr/cloud/autoscaling/sim/SimScenario.java
@@ -301,7 +301,7 @@ public class SimScenario implements AutoCloseable {
           log.info("        -- abortLoop requested, aborting after " + i + " iterations.");
           return;
         }
-        scenario.context.put(LOOP_ITER_PROP, i);
+        scenario.context.put(LOOP_ITER_PROP, String.valueOf(i));
         log.info("   * iter " + (i + 1) + ":");
         for (SimOp op : ops) {
           op.prepareCurrentParams(scenario);
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimScenario.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimScenario.java
index 24f7b86..6f00151 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimScenario.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimScenario.java
@@ -77,12 +77,15 @@ public class TestSimScenario extends SimSolrCloudTestCase {
       "loop_end\n" +
       "loop_start iterations=${justCalc}\n" +
       "  calculate_suggestions\n" +
+      "  save_snapshot path=${snapshotPath}/${_loop_iter_}\n" +
       "loop_end\n" +
       "dump redact=true";
 
   @Test
   public void testSuggestions() throws Exception {
+    String snapshotPath = createTempDir() + "/snapshot";
     try (SimScenario scenario = SimScenario.load(testSuggestionsScenario)) {
+      scenario.context.put("snapshotPath", snapshotPath);
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       PrintStream ps = new PrintStream(baos, true, Charset.forName("UTF-8"));
       scenario.console = ps;
@@ -101,14 +104,14 @@ public class TestSimScenario extends SimSolrCloudTestCase {
       List<Map<String, Object>> snapSuggestions = (List<Map<String, Object>>)autoscalingState.get("suggestions");
       assertEquals(snapSuggestions.toString(), 1, snapSuggestions.size());
       // _loop_iter_ should be present and 0 (first iteration)
-      assertEquals(0, scenario.context.get(SimScenario.LOOP_ITER_PROP));
+      assertEquals("0", scenario.context.get(SimScenario.LOOP_ITER_PROP));
     }
     // try looping more times
     try (SimScenario scenario = SimScenario.load(testSuggestionsScenario)) {
       scenario.context.put("iterative", "10");
       scenario.context.put("justCalc", "0");
       scenario.run();
-      assertEquals(9, scenario.context.get(SimScenario.LOOP_ITER_PROP));
+      assertEquals("9", scenario.context.get(SimScenario.LOOP_ITER_PROP));
     }
 
   }
diff --git a/solr/solr-ref-guide/src/solrcloud-autoscaling-policy-preferences.adoc b/solr/solr-ref-guide/src/solrcloud-autoscaling-policy-preferences.adoc
index cc3373c..d776092 100644
--- a/solr/solr-ref-guide/src/solrcloud-autoscaling-policy-preferences.adoc
+++ b/solr/solr-ref-guide/src/solrcloud-autoscaling-policy-preferences.adoc
@@ -530,7 +530,7 @@ updated to contain the current values for the following properties:
 * `_collections_` - a list of existing collections, or absent if there are no collections
(or no live nodes)
 * `_suggestions_` - a list of autoscaling suggestions generated using CREATE_SUGGESTIONS
command.
 * `_responses_` - a list of SolrResponse-s resulting from SOLR_REQUEST commands.
-* `_loop_iter_` - current loop iteration, or absent outside of loop.
+* `_loop_iter_` - current loop iteration (as a string), or absent outside of loop.
 * `_trigger_event_<triggerName>` - last trigger event captured by WAIT_EVENT
 
 Command parameters support variable expansion using string values from the current context
(non-string values, including numeric, are ignored)


Mime
View raw message