mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
add test for and fix named scenario parameter overrides in template vars
This commit is contained in:
parent
7ff0920a4b
commit
b16620d021
@ -60,7 +60,7 @@ public class NBCLIScenarioParser {
|
|||||||
// Optional<Path> workloadPathSearch = NBPaths.findOptionalPath(workloadName, "yaml", false, "activities");
|
// Optional<Path> workloadPathSearch = NBPaths.findOptionalPath(workloadName, "yaml", false, "activities");
|
||||||
// Path workloadPath = workloadPathSearch.orElseThrow();
|
// Path workloadPath = workloadPathSearch.orElseThrow();
|
||||||
|
|
||||||
// Buffer in CLI word from user, but only until the next command
|
// Buffer in scenario names from CLI, only counting non-options non-parameters and non-reserved words
|
||||||
List<String> scenarioNames = new ArrayList<>();
|
List<String> scenarioNames = new ArrayList<>();
|
||||||
while (arglist.size() > 0
|
while (arglist.size() > 0
|
||||||
&& !arglist.peekFirst().contains("=")
|
&& !arglist.peekFirst().contains("=")
|
||||||
@ -100,7 +100,7 @@ public class NBCLIScenarioParser {
|
|||||||
.extension(RawStmtsLoader.YAML_EXTENSIONS)
|
.extension(RawStmtsLoader.YAML_EXTENSIONS)
|
||||||
.first().orElseThrow();
|
.first().orElseThrow();
|
||||||
// TODO: The yaml needs to be parsed with arguments from each command independently to support template vars
|
// TODO: The yaml needs to be parsed with arguments from each command independently to support template vars
|
||||||
StmtsDocList scenariosYaml = StatementsLoader.loadContent(logger, yamlWithNamedScenarios, userProvidedParams);
|
StmtsDocList scenariosYaml = StatementsLoader.loadContent(logger, yamlWithNamedScenarios, new LinkedHashMap<>(userProvidedParams));
|
||||||
Scenarios scenarios = scenariosYaml.getDocScenarios();
|
Scenarios scenarios = scenariosYaml.getDocScenarios();
|
||||||
|
|
||||||
Map<String, String> namedSteps = scenarios.getNamedScenario(scenarioName);
|
Map<String, String> namedSteps = scenarios.getNamedScenario(scenarioName);
|
||||||
|
@ -12,15 +12,33 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
public class NBCLIScenarioParserTemplateVarTest {
|
public class NBCLIScenarioParserTemplateVarTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void providePathForScenario() {
|
public void testMultipleOccurencesOfSameTemplateVar() {
|
||||||
NBCLIOptions opts = new NBCLIOptions(new String[]{ "local/example-scenarios-templatevars" });
|
NBCLIOptions opts = new NBCLIOptions(new String[]{ "local/example-scenarios-templatevars" });
|
||||||
List<Cmd> cmds = opts.getCommands();
|
List<Cmd> cmds = opts.getCommands();
|
||||||
cmds.forEach(System.out::println);
|
cmds.forEach(System.out::println);
|
||||||
|
|
||||||
StmtsDocList workload1 = StatementsLoader.loadPath(null, cmds.get(0).getArg("workload"),cmds.get(0).getParams());
|
StmtsDocList workload1 = StatementsLoader.loadPath(null, cmds.get(0).getArg("workload"),cmds.get(0).getParams());
|
||||||
OpTemplate optpl = workload1.getStmts().get(0);
|
OpTemplate optpl1 = workload1.getStmts().get(0);
|
||||||
assertThat(optpl.getStmt()).contains("cycle {cycle} replaced replaced\n");
|
System.out.println("op from cmd1:"+optpl1);
|
||||||
System.out.println("op:"+optpl);
|
assertThat(optpl1.getStmt()).contains("cycle {cycle} replaced replaced\n");
|
||||||
|
|
||||||
|
StmtsDocList workload2 = StatementsLoader.loadPath(null, cmds.get(1).getArg("workload"),cmds.get(1).getParams());
|
||||||
|
OpTemplate optpl2 = workload2.getStmts().get(0);
|
||||||
|
System.out.println("op from cmd2:"+optpl2);
|
||||||
|
assertThat(optpl2.getStmt()).contains("cycle {cycle} def1 def1\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testThatCLIOverridesWorkForTemplateVars() {
|
||||||
|
NBCLIOptions opts = new NBCLIOptions(new String[]{ "local/example-scenarios-templatevars", "tvar1=overridden" });
|
||||||
|
List<Cmd> cmds = opts.getCommands();
|
||||||
|
cmds.forEach(System.out::println);
|
||||||
|
|
||||||
|
StmtsDocList workload1 = StatementsLoader.loadPath(null, cmds.get(0).getArg("workload"),cmds.get(0).getParams());
|
||||||
|
OpTemplate optpl1 = workload1.getStmts().get(0);
|
||||||
|
System.out.println("op from cmd1:"+optpl1);
|
||||||
|
assertThat(optpl1.getStmt()).contains("cycle {cycle} overridden overridden\n");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user