use of io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList in project nosqlbench by nosqlbench.
the class ActivityTypeLoader method getDriverAdapter.
private Optional<ActivityType> getDriverAdapter(String activityTypeName, ActivityDef activityDef) {
Optional<DriverAdapter> oda = DRIVERADAPTER_SPI_FINDER.getOptionally(activityTypeName);
if (oda.isPresent()) {
DriverAdapter<?, ?> driverAdapter = oda.get();
activityDef.getParams().remove("driver");
if (driverAdapter instanceof NBConfigurable) {
NBConfigModel cfgModel = ((NBConfigurable) driverAdapter).getConfigModel();
Optional<String> op_yaml_loc = activityDef.getParams().getOptionalString("yaml", "workload");
if (op_yaml_loc.isPresent()) {
Map<String, Object> disposable = new LinkedHashMap<>(activityDef.getParams());
StmtsDocList workload = StatementsLoader.loadPath(logger, op_yaml_loc.get(), disposable, "activities");
cfgModel = cfgModel.add(workload.getConfigModel());
}
NBConfiguration cfg = cfgModel.apply(activityDef.getParams());
((NBConfigurable) driverAdapter).applyConfig(cfg);
}
ActivityType activityType = new StandardActivityType<>(driverAdapter, activityDef);
return Optional.of(activityType);
} else {
return Optional.empty();
}
}
use of io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList 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.StmtsDocList 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.StmtsDocList 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.StmtsDocList 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"));
}
Aggregations