From 7ff0920a4b48d4a735632164ffaf005224a53ae5 Mon Sep 17 00:00:00 2001 From: Jonathan Shook Date: Wed, 19 Jan 2022 12:46:49 -0600 Subject: [PATCH] test that multiple occurrences of template var resolve consistently --- .../NBCLIScenarioParserTemplateVarTest.java | 27 +++++++++++++++++++ .../local/example-scenarios-templatevars.yaml | 10 +++++++ 2 files changed, 37 insertions(+) create mode 100644 engine-cli/src/test/java/io/nosqlbench/engine/cli/NBCLIScenarioParserTemplateVarTest.java create mode 100644 engine-cli/src/test/resources/local/example-scenarios-templatevars.yaml diff --git a/engine-cli/src/test/java/io/nosqlbench/engine/cli/NBCLIScenarioParserTemplateVarTest.java b/engine-cli/src/test/java/io/nosqlbench/engine/cli/NBCLIScenarioParserTemplateVarTest.java new file mode 100644 index 000000000..e3e99f573 --- /dev/null +++ b/engine-cli/src/test/java/io/nosqlbench/engine/cli/NBCLIScenarioParserTemplateVarTest.java @@ -0,0 +1,27 @@ +package io.nosqlbench.engine.cli; + +import io.nosqlbench.engine.api.activityconfig.StatementsLoader; +import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate; +import io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class NBCLIScenarioParserTemplateVarTest { + + @Test + public void providePathForScenario() { + NBCLIOptions opts = new NBCLIOptions(new String[]{ "local/example-scenarios-templatevars" }); + List cmds = opts.getCommands(); + cmds.forEach(System.out::println); + + StmtsDocList workload1 = StatementsLoader.loadPath(null, cmds.get(0).getArg("workload"),cmds.get(0).getParams()); + OpTemplate optpl = workload1.getStmts().get(0); + assertThat(optpl.getStmt()).contains("cycle {cycle} replaced replaced\n"); + System.out.println("op:"+optpl); + + } + +} diff --git a/engine-cli/src/test/resources/local/example-scenarios-templatevars.yaml b/engine-cli/src/test/resources/local/example-scenarios-templatevars.yaml new file mode 100644 index 000000000..f8bbaf3d9 --- /dev/null +++ b/engine-cli/src/test/resources/local/example-scenarios-templatevars.yaml @@ -0,0 +1,10 @@ +# example-scenarios.yaml +scenarios: + default: + - run cycles=3 alias=A driver=stdout tvar1=replaced + - run cycles=5 alias=B driver=stdout +bindings: + cycle: Identity() + name: NumberNameToCycle() +statements: + - cycle: "cycle {cycle} TEMPLATE(tvar1,def1) TEMPLATE(tvar1)\n"