Search in sources :

Example 1 with OpTemplate

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");
}
Also used : OpTemplate(io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate) StmtsDocList(io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList) Test(org.junit.jupiter.api.Test)

Example 2 with OpTemplate

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");
}
Also used : OpTemplate(io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate) StmtsDocList(io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList) Test(org.junit.jupiter.api.Test)

Example 3 with OpTemplate

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);
}
Also used : OpTemplate(io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) StmtsDocList(io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList) Test(org.junit.jupiter.api.Test)

Example 4 with OpTemplate

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"));
}
Also used : StmtsDoc(io.nosqlbench.engine.api.activityconfig.yaml.StmtsDoc) OpTemplate(io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate) StmtsBlock(io.nosqlbench.engine.api.activityconfig.yaml.StmtsBlock) StmtsDocList(io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList) Test(org.junit.jupiter.api.Test)

Example 5 with OpTemplate

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"));
}
Also used : StmtsDoc(io.nosqlbench.engine.api.activityconfig.yaml.StmtsDoc) OpTemplate(io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate) StmtsDocList(io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList) Test(org.junit.jupiter.api.Test)

Aggregations

OpTemplate (io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate)23 StmtsDocList (io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList)20 Test (org.junit.jupiter.api.Test)18 StmtsDoc (io.nosqlbench.engine.api.activityconfig.yaml.StmtsDoc)5 ParsedTemplate (io.nosqlbench.virtdata.core.templates.ParsedTemplate)5 SequencePlanner (io.nosqlbench.engine.api.activityapi.planning.SequencePlanner)4 SequencerType (io.nosqlbench.engine.api.activityapi.planning.SequencerType)4 StmtsBlock (io.nosqlbench.engine.api.activityconfig.yaml.StmtsBlock)4 BindPoint (io.nosqlbench.virtdata.core.templates.BindPoint)3 Bson (org.bson.conversions.Bson)3 Histogram (com.codahale.metrics.Histogram)1 Timer (com.codahale.metrics.Timer)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 JsonElement (com.google.gson.JsonElement)1 JsonParser (com.google.gson.JsonParser)1 ConnectionString (com.mongodb.ConnectionString)1 TemplateFormat (io.nosqlbench.adapters.stdout.TemplateFormat)1 ActivityDefObserver (io.nosqlbench.engine.api.activityapi.core.ActivityDefObserver)1 OpSequence (io.nosqlbench.engine.api.activityapi.planning.OpSequence)1