use of io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate in project nosqlbench by nosqlbench.
the class NBCLIScenarioParserTemplateVarTest method testThatCLIOverridesWorkForTemplateVars.
@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");
}
use of io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate in project nosqlbench by nosqlbench.
the class NBCLIScenarioParserTemplateVarTest method testMultipleOccurencesOfSameTemplateVar.
@Test
public void testMultipleOccurencesOfSameTemplateVar() {
NBCLIOptions opts = new NBCLIOptions(new String[] { "local/example-scenarios-templatevars" });
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} 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");
}
use of io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate in project nosqlbench by nosqlbench.
the class CommandTemplateTest method testCommandTemplateFormat.
@Test
public void testCommandTemplateFormat() {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
StmtsDocList stmtsDocs = StatementsLoader.loadString("" + "statements:\n" + " - s1: test1=foo test2={bar}\n" + " bindings:\n" + " bar: NumberNameToString();\n", Map.of());
OpTemplate optpl = stmtsDocs.getStmts().get(0);
CommandTemplate ct = new CommandTemplate(optpl);
String format = gson.toJson(ct);
System.out.println(format);
}
use of io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate in project nosqlbench by nosqlbench.
the class OpDefTest method testListOfNamedMap.
@Test
public void testListOfNamedMap() {
StmtsDocList all = StatementsLoader.loadPath(logger, "testdocs/statement_variants.yaml");
List<StmtsDoc> docs = all.getStmtDocs();
StmtsDoc doc2 = docs.get(2);
assertThat(doc2.getName()).isEqualTo("list-of-named-map");
assertThat(doc2.getBlocks()).hasSize(1);
StmtsBlock block1 = doc2.getBlocks().get(0);
assertThat(block1.getOps()).hasSize(1);
OpTemplate op0 = block1.getOps().get(0);
System.out.println(op0.getParams());
assertThat(op0.getName()).isEqualTo("list-of-named-map--block1--s1");
assertThat(op0.getOp()).contains(Map.of("p1", "v1", "p2", "v2"));
// System.out.println("here");
// TODO: This needs to be clarified and the logic made less ambiguous
// assertThat(op0.getParams()).hasSize(1);
// assertThat(op0.getParams()).containsExactlyEntriesOf(Map.of("p1", "v2", "p2", "v2", "p3", "v3"));
}
use of io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate in project nosqlbench by nosqlbench.
the class OpDefTest method testConsumableMapState.
@Test
public void testConsumableMapState() {
StmtsDocList all = StatementsLoader.loadPath(logger, "testdocs/docs_blocks_stmts.yaml");
List<StmtsDoc> docs = all.getStmtDocs();
StmtsDoc block1 = docs.get(1);
List<OpTemplate> stmts = block1.getStmts();
OpTemplate stmt0 = stmts.get(0);
OpTemplate stmt1 = stmts.get(1);
assertThat(stmt0.getParams()).containsAllEntriesOf(Map.of("timeout", 23423, "foobar", "baz"));
assertThat(stmt1.getParams()).containsAllEntriesOf(Map.of("timeout", 23423, "foobar", "baz"));
stmt0.removeParamOrDefault("timeout", 23423);
assertThat(stmt0.getParams()).containsAllEntriesOf(Map.of("foobar", "baz"));
assertThat(stmt1.getParams()).containsAllEntriesOf(Map.of("timeout", 23423, "foobar", "baz"));
}
Aggregations