mirror of https://github.com/apache/lucene.git
SOLR-13831: Context property _loop_iter_ should be a string in order to support
variable expansion.
This commit is contained in:
parent
e6728cdf64
commit
5865893e64
|
@ -300,7 +300,7 @@ public class SimScenario implements AutoCloseable {
|
||||||
log.info(" -- abortLoop requested, aborting after " + i + " iterations.");
|
log.info(" -- abortLoop requested, aborting after " + i + " iterations.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scenario.context.put(LOOP_ITER_PROP, i);
|
scenario.context.put(LOOP_ITER_PROP, String.valueOf(i));
|
||||||
log.info(" * iter " + (i + 1) + ":");
|
log.info(" * iter " + (i + 1) + ":");
|
||||||
for (SimOp op : ops) {
|
for (SimOp op : ops) {
|
||||||
op.prepareCurrentParams(scenario);
|
op.prepareCurrentParams(scenario);
|
||||||
|
|
|
@ -76,12 +76,15 @@ public class TestSimScenario extends SimSolrCloudTestCase {
|
||||||
"loop_end\n" +
|
"loop_end\n" +
|
||||||
"loop_start iterations=${justCalc}\n" +
|
"loop_start iterations=${justCalc}\n" +
|
||||||
" calculate_suggestions\n" +
|
" calculate_suggestions\n" +
|
||||||
|
" save_snapshot path=${snapshotPath}/${_loop_iter_}\n" +
|
||||||
"loop_end\n" +
|
"loop_end\n" +
|
||||||
"dump redact=true";
|
"dump redact=true";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuggestions() throws Exception {
|
public void testSuggestions() throws Exception {
|
||||||
|
String snapshotPath = createTempDir() + "/snapshot";
|
||||||
try (SimScenario scenario = SimScenario.load(testSuggestionsScenario)) {
|
try (SimScenario scenario = SimScenario.load(testSuggestionsScenario)) {
|
||||||
|
scenario.context.put("snapshotPath", snapshotPath);
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
PrintStream ps = new PrintStream(baos, true, "UTF-8");
|
PrintStream ps = new PrintStream(baos, true, "UTF-8");
|
||||||
scenario.console = ps;
|
scenario.console = ps;
|
||||||
|
@ -100,14 +103,14 @@ public class TestSimScenario extends SimSolrCloudTestCase {
|
||||||
List<Map<String, Object>> snapSuggestions = (List<Map<String, Object>>)autoscalingState.get("suggestions");
|
List<Map<String, Object>> snapSuggestions = (List<Map<String, Object>>)autoscalingState.get("suggestions");
|
||||||
assertEquals(snapSuggestions.toString(), 1, snapSuggestions.size());
|
assertEquals(snapSuggestions.toString(), 1, snapSuggestions.size());
|
||||||
// _loop_iter_ should be present and 0 (first iteration)
|
// _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 looping more times
|
||||||
try (SimScenario scenario = SimScenario.load(testSuggestionsScenario)) {
|
try (SimScenario scenario = SimScenario.load(testSuggestionsScenario)) {
|
||||||
scenario.context.put("iterative", "10");
|
scenario.context.put("iterative", "10");
|
||||||
scenario.context.put("justCalc", "0");
|
scenario.context.put("justCalc", "0");
|
||||||
scenario.run();
|
scenario.run();
|
||||||
assertEquals(9, scenario.context.get(SimScenario.LOOP_ITER_PROP));
|
assertEquals("9", scenario.context.get(SimScenario.LOOP_ITER_PROP));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
* `_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.
|
* `_suggestions_` - a list of autoscaling suggestions generated using CREATE_SUGGESTIONS command.
|
||||||
* `_responses_` - a list of SolrResponse-s resulting from SOLR_REQUEST commands.
|
* `_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
|
* `_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)
|
Command parameters support variable expansion using string values from the current context (non-string values, including numeric, are ignored)
|
||||||
|
|
Loading…
Reference in New Issue