support for param=UNDEF in named scenario templates

This commit is contained in:
Jonathan Shook 2020-04-06 12:06:10 -05:00
parent 034c8a9417
commit becab83c2c
9 changed files with 87 additions and 48 deletions

View File

@ -1,7 +1,7 @@
# nb -v run driver=cql yaml=cql-iot tags=phase:schema host=dsehost
scenarios:
default:
- run driver=cql tags==phase:schema threads==1
- run driver=cql tags==phase:schema threads==1 cycles==UNDEF
- run driver=cql tags==phase:rampup cycles===TEMPLATE(rampup-cycles,10000000) threads=auto
- run driver=cql tags==phase:main cycles===TEMPLATE(main-cycles,10000000) threads=auto
bindings:

View File

@ -1,7 +1,7 @@
# nb -v run driver=cql yaml=cql-iot tags=phase:schema host=dsehost
scenarios:
default:
- run driver=cql tags==phase:schema threads==1
- run driver=cql tags==phase:schema threads==1 cycles==UNDEF
- run driver=cql tags==phase:rampup cycles===TEMPLATE(rampup-cycles,10000000) threads=auto
- run driver=cql tags==phase:main cycles===TEMPLATE(main-cycles,10000000) threads=auto
params:

View File

@ -1,7 +1,7 @@
# nb -v run driver=cql yaml=cql-keyvalue tags=phase:schema host=dsehost
scenarios:
default:
- run driver=cql tags==phase:schema threads==1
- run driver=cql tags==phase:schema threads==1 cycles==UNDEF
- run driver=cql tags==phase:rampup cycles===TEMPLATE(rampup-cycles,10000000) threads=auto
- run driver=cql tags==phase:main cycles===TEMPLATE(main-cycles,10000000) threads=auto
bindings:

View File

@ -1,7 +1,7 @@
# nb -v cql-tabular rampup-cycles=1E6 main-cycles=1E9
scenarios:
default:
- run driver=cql tags==phase:schema threads==1
- run driver=cql tags==phase:schema threads==1 cycles==UNDEF
- run driver=cql tags==phase:rampup cycles===TEMPLATE(rampup-cycles,10000000) threads=auto
- run driver=cql tags==phase:main cycles===TEMPLATE(main-cycles,10000000) threads=auto
bindings:

View File

@ -93,8 +93,13 @@ public class NBCLI {
System.exit(0);
}
if (options.wantsWorkloadsList()) {
printWorkloads(false);
System.exit(0);
}
if (options.wantsScenariosList()) {
printWorkloads();
printWorkloads(true);
System.exit(0);
}
@ -258,28 +263,33 @@ public class NBCLI {
}
}
public void printWorkloads() {
public void printWorkloads(boolean includeScenarios) {
List<WorkloadDesc> workloads = NBCLIScenarioParser.getWorkloadsWithScenarioScripts();
for (WorkloadDesc workload : workloads) {
System.out.println("\n# from: "+ workload.getYamlPath());
System.out.println(workload.getYamlPath());
if (includeScenarios) {
System.out.println(" # scenarios:");
List<String> scenarioList = workload.getScenarioNames();
String workloadName = workload.getYamlPath().replaceAll("\\.yaml", "");
Set<String> templates = workload.getTemplates();
for (String scenario : scenarioList) {
if (scenario.equals("default")) {
scenario = scenario + "\n # same as running ./nb " + workloadName ;
}
System.out.println(" ./nb " + workloadName + " " + scenario);
System.out.println(" nb " + workloadName + " " + scenario);
}
Set<String> templates = workload.getTemplates();
if (templates.size() > 0) {
System.out.println("# with the following optional parameters and defaults: ");
System.out.println(" # defaults");
templates.stream()
.map(x -> x.replaceAll(",", "="))
.map(x -> x.replaceAll(":", "="))
.map(x -> " # "+x)
.map(x -> " " + x)
.forEach(System.out::println);
}
System.out.println();
}
}
}

View File

@ -112,6 +112,7 @@ public class NBCLIOptions {
private boolean dockerMetrics = false;
private boolean wantsScenariosList = false;
private String wantsToCopyWorkload = null;
private boolean wantsWorkloadsList = false;
public NBCLIOptions(String[] args) {
parse(args);
@ -308,10 +309,13 @@ public class NBCLIOptions {
consoleLoggingPattern = readWordOrThrow(arglist, "logging pattern");
break;
case LIST_SCENARIOS:
case LIST_WORKLOADS:
arglist.removeFirst();
wantsScenariosList = true;
break;
case LIST_WORKLOADS:
arglist.removeFirst();
wantsWorkloadsList =true;
break;
case COPY_WORKLOAD:
arglist.removeFirst();
wantsToCopyWorkload = readWordOrThrow(arglist, "workload to copy");
@ -578,6 +582,10 @@ public class NBCLIOptions {
return wantsToCopyWorkload;
}
public boolean wantsWorkloadsList() {
return wantsWorkloadsList;
}
public static enum CmdType {
start,
run,

View File

@ -111,6 +111,14 @@ public class NBCLIScenarioParser {
builtcmd.put("workload", "workload=" + workloadPath.toString());
}
// Undefine any keys with a value of 'undef'
List<String> undefKeys = builtcmd.entrySet()
.stream()
.filter(e -> e.getValue().toLowerCase().endsWith("=undef"))
.map(Map.Entry::getKey)
.collect(Collectors.toList());
undefKeys.forEach(builtcmd::remove);
logger.debug("Named scenario built command: " + String.join(" ", builtcmd.values()));
buildCmdBuffer.addAll(builtcmd.values());
}

View File

@ -84,5 +84,18 @@ public class NBCLIScenarioParserTest {
assertThat(cmds.get(0).getCmdSpec()).isEqualTo("driver=stdout;cycles=20;cycles-test=20;workload=activities/scenario-test.yaml;");
}
@Test
public void testThatUndefValuesAreUndefined() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "scenario-test", "schema-only", "cycles-test=20"});
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
assertThat(cmds.size()).isEqualTo(1);
assertThat(cmds.get(0).getCmdSpec()).isEqualTo("driver=stdout;workload=scenario-test;tags=phase:schema;cycles-test=20;");
NBCLIOptions opts1 = new NBCLIOptions(new String[]{ "scenario-test", "schema-only", "doundef=20"});
List<NBCLIOptions.Cmd> cmds1 = opts1.getCommands();
assertThat(cmds1.size()).isEqualTo(1);
assertThat(cmds1.get(0).getCmdSpec()).isEqualTo("driver=stdout;workload=scenario-test;tags=phase:schema;");
}
}

View File

@ -5,7 +5,7 @@ scenarios:
- run driver=stdout yaml===scenario-test tags=phase:rampup cycles=TEMPLATE(cycles1,10)
- run driver=stdout yaml===scenario-test tags=phase:main cycles=TEMPLATE(cycles2,10)
schema-only:
- "run driver=stdout yaml=scenario-test tags=phase:schema"
- "run driver=stdout yaml=scenario-test tags=phase:schema doundef==undef"
template-test:
with-template: run driver=stdout cycles=TEMPLATE(cycles-test,10)
blocks: