refactor command parsing for consistency and clarity

This commit is contained in:
Jonathan Shook
2020-04-20 07:54:09 -05:00
parent ec9b760470
commit 760861230a
13 changed files with 476 additions and 384 deletions

View File

@@ -93,6 +93,7 @@ blocks:
name: select-read
params:
instrument: TEMPLATE(instrument-reads,TEMPLATE(instrument,false))
- tags:
phase: main
type: write

View File

@@ -0,0 +1,54 @@
scenarios:
default:
schema: run driver=cql tags==phase:schema cycles==UNDEF threads==1
rampup: run driver=cql tags==phase:rampup cycles=TEMPLATE(rampup-cycles100K) threads=auto
bindings:
userid: Template('user-{}',ToString()); SaveString('userid');
interest: Template('interest-{}',ToString());
blocks:
- name: schema
tags:
phase: schema
statements:
- create-keyspace: |
create KEYSPACE if not exists TEMPLATE(keyspace,examples)
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}
AND durable_writes = 'true';
- create-users-table: |
create table if not exists TEMPLATE(keyspace,examples).users (
userid text PRIMARY KEY
);
- create-interests-table: |
create table if not exists TEMPLATE(keyspace,examples).interests (
userid text,
interest text,
primary key (interest, userid)
);
- name: rampup
tags:
phase: rampup
statements:
- insert-users: |
insert into TEMPLATE(keyspace,examples).users (userid) VALUES ({userid});
tags:
entity: users
- insert-interests: |
insert into TEMPLATE(keyspace,examples).interests(
interest, userid
) VALUES (
{interest}, {userid}
);
tags:
entity: interests
- name: main
tags:
phase: main
statements:
- read-user: |
select * from TEMPLATE(keyspace,examples).users
where userid={userid};
- read interests: |
select * from TEMPLATE(keyspace,examples).interests
where interest={interest};

View File

@@ -346,4 +346,11 @@ public class ParameterMap extends ConcurrentHashMap<String,Object> implements Bi
}
}
public static String toJSON(Map<?,?> map) {
StringBuilder sb = new StringBuilder();
List<String> l = new ArrayList<>();
map.forEach((k,v) -> l.add("'" + k + "': '" + v + "'"));
return "params={"+String.join(",\n ",l)+"};\n";
}
}

View File

@@ -0,0 +1,74 @@
package io.nosqlbench.engine.cli;
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class BasicScriptBuffer implements ScriptBuffer {
private final StringBuilder sb = new StringBuilder();
private final Map<String, String> scriptParams = new HashMap<>();
@Override
public ScriptBuffer add(Cmd cmd) {
Map<String, String> params = cmd.getParams();
if (!cmd.getParams().isEmpty()) {
sb.append(toJSONParams("params", cmd.getParams()));
}
switch (cmd.getCmdType()) {
case script:
String scriptData = NBCLIScriptAssembly.loadScript(cmd);
sb.append(scriptData);
break;
case fragment:
sb.append(cmd.getArg("script_fragment"));
if (!cmd.getArg("script_fragment").endsWith("\n")) {
sb.append("\n");
}
break;
case start: // start activity
case run: // run activity
// Sanity check that this can parse before using it
sb.append("scenario.").append(cmd.toString()).append("(")
.append(toJSONBlock(cmd.getParams()))
.append(");\n");
break;
case await: // await activity
sb.append("scenario.awaitActivity(\"").append(cmd.getArg("alias_name")).append("\");\n");
break;
case stop: // stop activity
sb.append("scenario.stop(\"").append(cmd.getArg("alias_name")).append("\");\n");
break;
case waitmillis:
long millis_to_wait = Long.parseLong(cmd.getArg("millis_to_wait"));
sb.append("scenario.waitMillis(").append(millis_to_wait).append(");\n");
break;
}
return this;
}
@Override
public String getParsedScript() {
return sb.toString();
}
public static String toJSONBlock(Map<?,?> map) {
StringBuilder sb = new StringBuilder();
List<String> l = new ArrayList<>();
map.forEach((k, v) -> l.add("'" + k + "': '" + v + "'"));
return "{" + String.join(",\n ", l) + "};\n";
}
public static String toJSONParams(String varname, Map<?, ?> map) {
return "// params.size==" + map.size() + "\n" + varname + "="+toJSONBlock(map);
}
}

View File

@@ -0,0 +1,129 @@
package io.nosqlbench.engine.cli;
import io.nosqlbench.nb.api.content.Content;
import io.nosqlbench.nb.api.content.NBIO;
import io.nosqlbench.nb.api.errors.BasicError;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.security.InvalidParameterException;
import java.util.*;
import java.util.stream.Collectors;
/**
* Encapsulate Command parsing and structure for the NoSQLBench command line.
* Commands always have a name, sometimes have a list of positional arguments,
* and sometimes have a map of named parameters.
* An example of a command tha thas both would look like {@code script test.js p1=v1}
*/
public class Cmd {
private final static Logger logger = LoggerFactory.getLogger(Cmd.class);
public enum CmdType {
script("script_path"),
fragment("script_fragment"),
start(),
run(),
await("alias_name"),
stop("alias_name"),
waitmillis("millis_to_wait");
private final String[] positional;
CmdType(String... positional) {
this.positional = positional;
}
public String[] getPositionalArgs() {
return positional;
}
}
private Map<String, String> cmdArgs;
public String getArg(String paramName) {
return this.cmdArgs.get(paramName);
}
private final CmdType cmdType;
public Cmd(CmdType cmdType, Map<String,String> cmdArgs) {
this.cmdArgs = cmdArgs;
this.cmdType = cmdType;
}
public CmdType getCmdType() {
return cmdType;
}
public Map<String, String> getParams() {
return cmdArgs;
}
public String toString() {
return "type:" + cmdType + ((cmdArgs != null) ? ";cmdArgs=" + cmdArgs.toString() : "");
}
public static Cmd parseArg(LinkedList<String> arglist, NBCLIOptions options) {
String cmdName = arglist.removeFirst();
CmdType cmdType = CmdType.valueOf(cmdName);
Map<String,String> params = new LinkedHashMap<>();
for (String paramName : cmdType.getPositionalArgs()) {
String arg = arglist.peekFirst();
if (arg==null) {
throw new InvalidParameterException("command '" + cmdName + " requires a value for " + paramName
+ ", but there were no remaining arguments after it.");
}
if (arg.contains("=")) {
throw new InvalidParameterException("command '" + cmdName + "' requires a value for " + paramName + "" +
", but a named parameter was found instead: " + arg);
}
if (NBCLIOptions.RESERVED_WORDS.contains(arg)) {
throw new InvalidParameterException("command '" + cmdName + "' requires a value for " + paramName
+ ", but a reserved word was found instead: " + arg);
}
logger.debug("cmd name:" + cmdName +", positional " + paramName + ": " + arg);
params.put(paramName,arglist.removeFirst());
}
while (arglist.size() > 0 &&
!NBCLIOptions.RESERVED_WORDS.contains(arglist.peekFirst())
&& arglist.peekFirst().contains("=")) {
String arg = arglist.removeFirst();
String[] assigned = arg.split("=", 2);
String pname = assigned[0];
String pval = assigned[1];
if (pname.equals("yaml")||pname.equals("workload")) {
String yaml = pval;
Optional<Content<?>> found = NBIO.local().prefix("activities")
.prefix(options.wantsIncludes())
.name(yaml)
.first();
if (found.isPresent()) {
if (!found.get().asPath().toString().equals(yaml)) {
logger.info("rewrote path for " + yaml + " as " + found.get().asPath().toString());
pval=found.get().asPath().toString();
} else {
logger.debug("kept path for " + yaml + " as " + found.get().asPath().toString());
}
} else {
logger.debug("unable to find " + yaml + " for path qualification");
}
}
if (params.containsKey(pname)) {
throw new InvalidParameterException("parameter '" + pname + "' is already set for " + cmdType);
}
params.put(pname,pval);
}
return new Cmd(cmdType, params);
}
}

View File

@@ -244,10 +244,10 @@ public class NBCLI {
ScenariosExecutor executor = new ScenariosExecutor("executor-" + sessionName, 1);
Scenario scenario = new Scenario(sessionName, options.getProgressSpec());
NBCLIScriptAssembly.ScriptData scriptData = NBCLIScriptAssembly.assembleScript(options);
String scriptData = NBCLIScriptAssembly.assemble(options);
if (options.wantsShowScript()) {
System.out.println("// Rendered Script");
System.out.println(scriptData.getScriptParamsAndText());
System.out.println(scriptData);
System.exit(0);
}
@@ -258,8 +258,10 @@ public class NBCLI {
logger.info("Charting disabled");
}
scenario.addScenarioScriptParams(scriptData.getScriptParams());
scenario.addScriptText(scriptData.getScriptTextIgnoringParams());
// Execute Scenario!
scenario.addScriptText(scriptData);
ScenarioLogger sl = new ScenarioLogger(scenario)
.setLogDir(options.getLogsDirectory())
.setMaxLogs(options.getLogsMax())

View File

@@ -19,54 +19,57 @@ import java.util.stream.Collectors;
*/
public class NBCLIOptions {
public static final String docoptFileName = "commandline.md";
private final static Logger logger = LoggerFactory.getLogger(NBCLIOptions.class);
// Options which may contextualize other CLI options or commands.
// These must be parsed first
private static final String INCLUDE = "--include";
private static final String METRICS_PREFIX = "--metrics-prefix";
// Discovery
private static final String HELP = "--help";
private static final String METRICS = "--list-metrics";
private static final String DRIVER_TYPES = "--list-drivers";
private static final String ACTIVITY_TYPES = "--list-activity-types";
private static final String LIST_METRICS = "--list-metrics";
private static final String LIST_DRIVERS = "--list-drivers";
private static final String LIST_ACTIVITY_TYPES = "--list-activity-types";
private static final String LIST_WORKLOADS = "--list-workloads";
private static final String LIST_SCENARIOS = "--list-scenarios";
private static final String WANTS_INPUT_TYPES = "--list-input-types";
private static final String WANTS_OUTPUT_TYPES = "--list-output-types";
private static final String WANTS_VERSION_COORDS = "--version-coords";
private static final String WANTS_VERSION_SHORT = "--version";
private static final String LIST_INPUT_TYPES = "--list-input-types";
private static final String LIST_OUTPUT_TYPES = "--list-output-types";
private static final String VERSION_COORDS = "--version-coords";
private static final String VERSION = "--version";
private static final String SHOW_SCRIPT = "--show-script";
private static final String COPY_WORKLOAD = "--copy";
private static final String INCLUDE = "--include";
private static final String COPY = "--copy";
// Execution
private static final String SCRIPT = "script";
private static final String ACTIVITY = "activity";
private static final String SCENARIO = "scenario";
private static final String RUN_ACTIVITY = "run";
private static final String START_ACTIVITY = "start";
private static final String SCRIPT_FRAGMENT = "fragment";
private static final String STOP_ACTIVITY = "stop";
private static final String AWAIT_ACTIVITY = "await";
private static final String RUN = "run";
private static final String START = "start";
private static final String FRAGMENT = "fragment";
private static final String STOP = "stop";
private static final String AWAIT = "await";
private static final String WAIT_MILLIS = "waitmillis";
private static final String DUMP_CYCLELOG = "--export-cycle-log";
private static final String IMPORT_CYCLELOG = "--import-cycle-log";
private static final String EXPORT_CYCLE_LOG = "--export-cycle-log";
private static final String IMPORT_CYCLE_LOG = "--import-cycle-log";
// Execution Options
private static final String SESSION_NAME = "--session-name";
private static final String LOGS_DIR = "--logs-dir";
private static final String LOGS_MAX = "--logs-max";
private static final String LOGS_LEVEL = "--logs-level";
private static final String WANTS_INFO_CONSOLE_LOGGING = "-v";
private static final String WANTS_DEBUG_CONSOLE_LOGGING = "-vv";
private static final String WANTS_TRACE_CONSOLE_LOGGING = "-vvv";
private static final String DASH_V_INFO = "-v";
private static final String DASH_VV_DEBUG = "-vv";
private static final String DASH_VVV_TRACE = "-vvv";
private static final String REPORT_INTERVAL = "--report-interval";
private static final String REPORT_GRAPHITE_TO = "--report-graphite-to";
private static final String REPORT_CSV_TO = "--report-csv-to";
private static final String METRICS_PREFIX = "--metrics-prefix";
private static final String PROGRESS_INDICATOR = "--progress";
private static final String PROGRESS = "--progress";
private static final String WITH_LOGGING_PATTERN = "--with-logging-pattern";
private static final String LOG_HISTO = "--log-histograms";
private static final String LOG_STATS = "--log-histostats";
private static final String CLASSIC_HISTOS = "--classic-histograms";
private static final String LOG_HISTOGRAMS = "--log-histograms";
private static final String LOG_HISTOSTATS = "--log-histostats";
private static final String CLASSIC_HISTOGRAMS = "--classic-histograms";
private final static String LOG_LEVEL_OVERRIDE = "--log-level-override";
private final static String ENABLE_CHART = "--enable-chart";
private final static String DOCKER_METRICS = "--docker-metrics";
@@ -74,15 +77,15 @@ public class NBCLIOptions {
public static final Set<String> RESERVED_WORDS = new HashSet<>() {{
addAll(
Arrays.asList(
SCRIPT, ACTIVITY, SCENARIO, RUN_ACTIVITY, START_ACTIVITY,
SCRIPT_FRAGMENT, STOP_ACTIVITY, AWAIT_ACTIVITY, WAIT_MILLIS, ACTIVITY_TYPES, HELP
SCRIPT, ACTIVITY, SCENARIO, RUN, START,
FRAGMENT, STOP, AWAIT, WAIT_MILLIS, LIST_ACTIVITY_TYPES, HELP
)
);
}};
private static final String DEFAULT_CONSOLE_LOGGING_PATTERN = "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n";
private LinkedList<Cmd> cmdList = new LinkedList<>();
private final LinkedList<Cmd> cmdList = new LinkedList<>();
private int logsMax = 0;
private boolean wantsVersionShort = false;
private boolean wantsVersionCoords = false;
@@ -98,9 +101,9 @@ public class NBCLIOptions {
private String sessionName = "";
private boolean showScript = false;
private Level consoleLevel = Level.WARN;
private List<String> histoLoggerConfigs = new ArrayList<>();
private List<String> statsLoggerConfigs = new ArrayList<>();
private List<String> classicHistoConfigs = new ArrayList<>();
private final List<String> histoLoggerConfigs = new ArrayList<>();
private final List<String> statsLoggerConfigs = new ArrayList<>();
private final List<String> classicHistoConfigs = new ArrayList<>();
private String progressSpec = "console:1m";
private String logsDirectory = "logs";
private boolean wantsInputTypes = false;
@@ -115,7 +118,7 @@ public class NBCLIOptions {
private boolean wantsScenariosList = false;
private String wantsToCopyWorkload = null;
private boolean wantsWorkloadsList = false;
private List<String> wantsToIncludePaths = new ArrayList<String>();
private final List<String> wantsToIncludePaths = new ArrayList<>();
public NBCLIOptions(String[] args) {
parse(args);
@@ -144,20 +147,21 @@ public class NBCLIOptions {
continue;
}
switch (word) {
case INCLUDE:
arglist.removeFirst();
String include = readWordOrThrow(arglist, "path to include");
wantsToIncludePaths.add(include);
break;
default:
nonincludes.addLast(arglist.removeFirst());
if (INCLUDE.equals(word)) {
arglist.removeFirst();
String include = readWordOrThrow(arglist, "path to include");
wantsToIncludePaths.add(include);
} else if (METRICS_PREFIX.equals(word)) {
arglist.removeFirst();
metricsPrefix = arglist.removeFirst();
} else {
nonincludes.addLast(arglist.removeFirst());
}
}
arglist=nonincludes;
nonincludes= new LinkedList<>();
arglist = nonincludes;
nonincludes = new LinkedList<>();
while (arglist.peekFirst()!= null) {
while (arglist.peekFirst() != null) {
String word = arglist.peekFirst();
if (word.startsWith("--") && word.contains("=")) {
String wordToSplit = arglist.removeFirst();
@@ -172,11 +176,11 @@ public class NBCLIOptions {
arglist.removeFirst();
showScript = true;
break;
case METRICS:
case LIST_METRICS:
arglist.removeFirst();
arglist.addFirst("start");
Cmd introspectActivity = parseActivityCmd(arglist);
wantsMetricsForActivity = introspectActivity.cmdSpec;
Cmd cmd = Cmd.parseArg(arglist,this);
wantsMetricsForActivity = cmd.getArg("driver");
break;
case SESSION_NAME:
arglist.removeFirst();
@@ -188,7 +192,7 @@ public class NBCLIOptions {
break;
case LOGS_MAX:
arglist.removeFirst();
logsMax = Integer.valueOf(readWordOrThrow(arglist, "max logfiles to keep"));
logsMax = Integer.parseInt(readWordOrThrow(arglist, "max logfiles to keep"));
break;
case LOGS_LEVEL:
arglist.removeFirst();
@@ -198,15 +202,15 @@ public class NBCLIOptions {
arglist.removeFirst();
logLevelsOverrides = parseLogLevelOverrides(readWordOrThrow(arglist, "log levels in name:LEVEL,... format"));
break;
case PROGRESS_INDICATOR:
case PROGRESS:
arglist.removeFirst();
progressSpec = readWordOrThrow(arglist, "a progress indicator, like 'log:1m' or 'screen:10s', or just 'log' or 'screen'");
break;
case WANTS_VERSION_SHORT:
case VERSION:
arglist.removeFirst();
wantsVersionShort = true;
break;
case WANTS_VERSION_COORDS:
case VERSION_COORDS:
arglist.removeFirst();
wantsVersionCoords = true;
break;
@@ -230,32 +234,32 @@ public class NBCLIOptions {
wantsActivityHelpFor = readWordOrThrow(arglist, "topic");
}
break;
case DUMP_CYCLELOG:
case EXPORT_CYCLE_LOG:
arglist.removeFirst();
rleDumpOptions = readAllWords(arglist);
break;
case IMPORT_CYCLELOG:
case IMPORT_CYCLE_LOG:
arglist.removeFirst();
cyclelogImportOptions = readAllWords(arglist);
break;
case LOG_HISTO:
case LOG_HISTOGRAMS:
arglist.removeFirst();
String logto = arglist.removeFirst();
histoLoggerConfigs.add(logto);
break;
case LOG_STATS:
case LOG_HISTOSTATS:
arglist.removeFirst();
String logStatsTo = arglist.removeFirst();
statsLoggerConfigs.add(logStatsTo);
break;
case CLASSIC_HISTOS:
case CLASSIC_HISTOGRAMS:
arglist.removeFirst();
String classicHistos = arglist.removeFirst();
classicHistoConfigs.add(classicHistos);
break;
case REPORT_INTERVAL:
arglist.removeFirst();
reportInterval = Integer.valueOf(readWordOrThrow(arglist, "report interval"));
reportInterval = Integer.parseInt(readWordOrThrow(arglist, "report interval"));
break;
case REPORT_CSV_TO:
arglist.removeFirst();
@@ -265,32 +269,28 @@ public class NBCLIOptions {
arglist.removeFirst();
reportGraphiteTo = arglist.removeFirst();
break;
case METRICS_PREFIX:
arglist.removeFirst();
metricsPrefix = arglist.removeFirst();
break;
case DRIVER_TYPES:
case ACTIVITY_TYPES:
case LIST_DRIVERS:
case LIST_ACTIVITY_TYPES:
arglist.removeFirst();
wantsActivityTypes = true;
break;
case WANTS_INPUT_TYPES:
case LIST_INPUT_TYPES:
arglist.removeFirst();
wantsInputTypes = true;
break;
case WANTS_OUTPUT_TYPES:
case LIST_OUTPUT_TYPES:
arglist.removeFirst();
wantsMarkerTypes = true;
break;
case WANTS_DEBUG_CONSOLE_LOGGING:
case DASH_VV_DEBUG:
consoleLevel = Level.DEBUG;
arglist.removeFirst();
break;
case WANTS_INFO_CONSOLE_LOGGING:
case DASH_V_INFO:
consoleLevel = Level.INFO;
arglist.removeFirst();
break;
case WANTS_TRACE_CONSOLE_LOGGING:
case DASH_VVV_TRACE:
consoleLevel = Level.TRACE;
arglist.removeFirst();
break;
@@ -306,7 +306,7 @@ public class NBCLIOptions {
arglist.removeFirst();
wantsWorkloadsList = true;
break;
case COPY_WORKLOAD:
case COPY:
arglist.removeFirst();
wantsToCopyWorkload = readWordOrThrow(arglist, "workload to copy");
break;
@@ -315,7 +315,6 @@ public class NBCLIOptions {
}
}
arglist = nonincludes;
nonincludes=new LinkedList<>();
while (arglist.peekFirst() != null) {
String word = arglist.peekFirst();
@@ -326,46 +325,38 @@ public class NBCLIOptions {
arglist.offerFirst(split[0]);
continue;
}
Cmd cmd=null;
switch (word) {
case SCRIPT_FRAGMENT:
Cmd fragment = parseFragmentCmd(arglist);
cmdList.add(fragment);
break;
case ACTIVITY:
arglist.removeFirst();
arglist.addFirst("run");
case START_ACTIVITY:
case RUN_ACTIVITY:
Cmd activity = parseActivityCmd(arglist);
cmdList.add(activity);
break;
case AWAIT_ACTIVITY:
String awaitCmdType = arglist.removeFirst();
String activityToAwait = readWordOrThrow(arglist, "activity alias to await");
assertNotParameter(activityToAwait);
assertNotReserved(activityToAwait);
Cmd awaitActivityCmd = new Cmd(CmdType.valueOf(awaitCmdType), activityToAwait);
cmdList.add(awaitActivityCmd);
break;
case STOP_ACTIVITY:
String stopCmdType = readWordOrThrow(arglist, "stop command");
String activityToStop = readWordOrThrow(arglist, "activity alias to await");
assertNotParameter(activityToStop);
assertNotReserved(activityToStop);
Cmd stopActivityCmd = new Cmd(CmdType.valueOf(stopCmdType), activityToStop);
cmdList.add(stopActivityCmd);
break;
case WAIT_MILLIS:
String waitMillisCmdType = readWordOrThrow(arglist, "wait millis");
String millisCount = readWordOrThrow(arglist, "millis count");
Long.parseLong(millisCount); // sanity check
Cmd awaitMillisCmd = new Cmd(CmdType.valueOf(waitMillisCmdType), millisCount);
cmdList.add(awaitMillisCmd);
break;
case FRAGMENT:
case SCRIPT:
Cmd cmd = parseScriptCmd(arglist);
case START:
case RUN:
case AWAIT:
case STOP:
case WAIT_MILLIS:
cmd = Cmd.parseArg(arglist,this);
cmdList.add(cmd);
break;
// cmd = Cmd.parseArg(arglist, this, "alias_to_await");
// String cmdName = arglist.removeFirst();
// String cmdParam = readWordOrThrow(arglist, "activity alias to await");
// assertNotParameter(cmdParam);
// assertNotReserved(cmdParam);
// cmdList.add(cmd);
// break;
// String stopCmdType = readWordOrThrow(arglist, "stop command");
// String activityToStop = readWordOrThrow(arglist, "activity alias to await");
// assertNotParameter(activityToStop);
// assertNotReserved(activityToStop);
// Cmd stopActivityCmd = Cmd.parseArg(arglist,this,"activity alias to stop");
// cmdList.add(stopActivityCmd);
// break;
// String waitMillisCmdType = readWordOrThrow(arglist, "wait millis");
// String millisCount = readWordOrThrow(arglist, "millis count");
// Long.parseLong(millisCount); // sanity check
// Cmd awaitMillisCmd = Cmd.parseArg(arglist,this,"milliseconds to wait");
// cmdList.add(awaitMillisCmd);
// break;
default:
Optional<Content<?>> scriptfile = NBIO.local()
.prefix("scripts/auto")
@@ -378,9 +369,8 @@ public class NBCLIOptions {
arglist.removeFirst();
arglist.addFirst("scripts/auto/" + word);
arglist.addFirst("script");
Cmd script = parseScriptCmd(arglist);
cmdList.add(script);
//Scripted yaml
cmd = Cmd.parseArg(arglist,this);
cmdList.add(cmd);
} else if (
NBCLIScenarioParser.isFoundWorkload(word, wantsIncludes())
) {
@@ -412,19 +402,19 @@ public class NBCLIOptions {
public List<LoggerConfig> getHistoLoggerConfigs() {
List<LoggerConfig> configs = histoLoggerConfigs.stream().map(LoggerConfig::new).collect(Collectors.toList());
checkLoggerConfigs(configs, LOG_HISTO);
checkLoggerConfigs(configs, LOG_HISTOGRAMS);
return configs;
}
public List<LoggerConfig> getStatsLoggerConfigs() {
List<LoggerConfig> configs = statsLoggerConfigs.stream().map(LoggerConfig::new).collect(Collectors.toList());
checkLoggerConfigs(configs, LOG_STATS);
checkLoggerConfigs(configs, LOG_HISTOSTATS);
return configs;
}
public List<LoggerConfig> getClassicHistoConfigs() {
List<LoggerConfig> configs = classicHistoConfigs.stream().map(LoggerConfig::new).collect(Collectors.toList());
checkLoggerConfigs(configs, CLASSIC_HISTOS);
checkLoggerConfigs(configs, CLASSIC_HISTOGRAMS);
return configs;
}
@@ -504,10 +494,6 @@ public class NBCLIOptions {
}
}
private String readOptionally(LinkedList<String> argList) {
return argList.pollFirst();
}
private String readWordOrThrow(LinkedList<String> arglist, String required) {
if (arglist.peekFirst() == null) {
throw new InvalidParameterException(required + " not found");
@@ -521,64 +507,20 @@ public class NBCLIOptions {
return args;
}
private Cmd parseScriptCmd(LinkedList<String> arglist) {
String cmdType = arglist.removeFirst();
String scriptName = readWordOrThrow(arglist, "script name");
assertNotReserved(scriptName);
assertNotParameter(scriptName);
Map<String, String> scriptParams = new LinkedHashMap<>();
while (arglist.size() > 0 && !RESERVED_WORDS.contains(arglist.peekFirst())
&& arglist.peekFirst().contains("=")) {
String[] split = arglist.removeFirst().split("=", 2);
scriptParams.put(split[0], split[1]);
}
return new Cmd(CmdType.script, scriptName, scriptParams);
}
// private Cmd parseScriptCmd(LinkedList<String> arglist) {
// String cmdType = arglist.removeFirst();
// String scriptName = readWordOrThrow(arglist, "script name");
// assertNotReserved(scriptName);
// assertNotParameter(scriptName);
// Map<String, String> scriptParams = new LinkedHashMap<>();
// while (arglist.size() > 0 && !RESERVED_WORDS.contains(arglist.peekFirst())
// && arglist.peekFirst().contains("=")) {
// String[] split = arglist.removeFirst().split("=", 2);
// scriptParams.put(split[0], split[1]);
// }
// return new Cmd(CmdType.script, scriptName, scriptParams);
// }
private Cmd parseFragmentCmd(LinkedList<String> arglist) {
String cmdType = arglist.removeFirst();
String scriptFragment = arglist.removeFirst();
return new Cmd(CmdType.valueOf(cmdType), scriptFragment);
}
private Cmd parseActivityCmd(LinkedList<String> arglist) {
String cmdType = arglist.removeFirst();
List<String> activitydef = new ArrayList<String>();
while (arglist.size() > 0 &&
!RESERVED_WORDS.contains(arglist.peekFirst())
&& arglist.peekFirst().contains("=")) {
String arg = arglist.removeFirst();
String yaml = "";
if (arg.startsWith("yaml=")) {
yaml = arg.substring("yaml=".length());
} else if (arg.startsWith("workload=")) {
yaml = arg.substring("workload=".length());
}
if (!yaml.isEmpty()) {
Optional<Content<?>> found = NBIO.local().prefix("activities")
.prefix(wantsMetricsPrefix())
.name(yaml)
.first();
if (found.isPresent()) {
if (!found.get().asPath().toString().equals(yaml)) {
logger.info("rewrote path for " + yaml + " as " + found.get().asPath().toString());
activitydef.add("workload=" + found.get().asPath().toString());
} else {
logger.debug("kept path for " + yaml + " as " + found.get().asPath().toString());
activitydef.add("workload=" + yaml);
}
} else {
logger.debug("unable to find " + yaml + " for pathqualification");
activitydef.add("workload=" + yaml);
}
} else {
activitydef.add(arg);
}
}
return new Cmd(CmdType.valueOf(cmdType), activitydef.stream().map(s -> s + ";").collect(Collectors.joining()));
}
public String getProgressSpec() {
ProgressSpec spec = parseProgressSpec(this.progressSpec);// sanity check
@@ -670,62 +612,8 @@ public class NBCLIOptions {
return wantsWorkloadsList;
}
public static enum CmdType {
start,
run,
stop,
await,
script,
fragment,
waitmillis,
}
public static class Cmd {
private CmdType cmdType;
private String cmdSpec;
private Map<String, String> cmdArgs;
public Cmd(CmdType cmdType, String cmdSpec) {
this.cmdSpec = cmdSpec;
this.cmdType = cmdType;
}
public Cmd(CmdType cmdType, String cmdSpec, Map<String, String> cmdArgs) {
this(cmdType, cmdSpec);
this.cmdArgs = cmdArgs;
}
public String getCmdSpec() {
if (cmdSpec.startsWith("'") && cmdSpec.endsWith("'")) {
return cmdSpec.substring(1, cmdSpec.length() - 1);
}
if (cmdSpec.startsWith("\"") && cmdSpec.endsWith("\"")) {
return cmdSpec.substring(1, cmdSpec.length() - 1);
}
return cmdSpec;
}
public CmdType getCmdType() {
return cmdType;
}
public void setCmdType(CmdType cmdType) {
this.cmdType = cmdType;
}
public Map<String, String> getCmdArgs() {
return cmdArgs;
}
public String toString() {
return "type:" + cmdType + ";spec=" + cmdSpec
+ ((cmdArgs != null) ? ";cmdArgs=" + cmdArgs.toString() : "");
}
}
public static class LoggerConfig {
public String file = "";
public String file;
public String pattern = ".*";
public String interval = "30 seconds";
@@ -744,7 +632,7 @@ public class NBCLIOptions {
break;
default:
throw new RuntimeException(
LOG_HISTO +
LOG_HISTOGRAMS +
" options must be in either 'regex:filename:interval' or 'regex:filename' or 'filename' format"
);
}

View File

@@ -1,119 +1,52 @@
package io.nosqlbench.engine.cli;
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
import io.nosqlbench.engine.api.templating.StrInterpolator;
import io.nosqlbench.nb.api.content.Content;
import io.nosqlbench.nb.api.content.NBIO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class NBCLIScriptAssembly {
private final static Logger logger = LoggerFactory.getLogger(NBCLIScriptAssembly.class);
public static ScriptData assembleScript(NBCLIOptions options) {
StringBuilder sb = new StringBuilder();
Map<String,String> params = new HashMap<>();
for (NBCLIOptions.Cmd cmd : options.getCommands()) {
String cmdSpec = cmd.getCmdSpec();
NBCLIOptions.CmdType cmdType = cmd.getCmdType();
ActivityDef activityDef;
switch (cmd.getCmdType()) {
case script:
sb.append("// from CLI as ").append(cmd).append("\n");
ScriptData scriptData = loadScript(cmd);
if (options.getCommands().size()==1) {
sb.append(scriptData.getScriptTextIgnoringParams());
params = scriptData.getScriptParams();
} else {
sb.append(scriptData.getScriptParamsAndText());
}
break;
case fragment:
sb.append("// from CLI as ").append(cmd).append("\n");
sb.append(cmd.getCmdSpec());
if (!cmdSpec.endsWith("\n")) {
sb.append("\n");
}
break;
case start: // start activity
case run: // run activity
// Sanity check that this can parse before using it
activityDef = ActivityDef.parseActivityDef(cmdSpec);
sb.append("// from CLI as ").append(cmd).append("\n")
.append("scenario.").append(cmdType.toString()).append("(\"")
.append(cmdSpec)
.append("\");\n");
sb.append("// from CLI as ").append(cmd).append("\n");
// work-around for perf issue
if (!cmdSpec.endsWith("\n")) {
sb.append("\n");
}
break;
case await: // await activity
sb.append("// from CLI as ").append(cmd).append("\n");
sb.append("scenario.awaitActivity(\"").append(cmdSpec).append("\");\n");
break;
case stop: // stop activity
sb.append("// from CLI as ").append(cmd).append("\n");
sb.append("scenario.stop(\"").append(cmdSpec).append("\");\n");
break;
case waitmillis:
sb.append("// from CLI as ").append(cmd).append("\n");
sb.append("scenario.waitMillis(").append(cmdSpec).append(");\n");
break;
}
}
// public static ScriptData assembleScript(NBCLIOptions options) {
//
// ScriptBuffer script = new BasicScriptBuffer();
//// Map<String,String> params = new HashMap<>();
//
// for (Cmd cmd : options.getCommands()) {
// script.add(cmd);
// }
// return script.getParsedScript();
// }
return new ScriptData(sb.toString(), params);
public static String assemble(NBCLIOptions options) {
ScriptBuffer script = new BasicScriptBuffer();
for (Cmd command : options.getCommands()) {
script.add(command);
}
return script.getParsedScript();
}
private static ScriptData loadScript(NBCLIOptions.Cmd cmd) {
public static String loadScript(Cmd cmd) {
String scriptData;
String script_path = cmd.getArg("script_path");
try {
logger.debug("Looking for " + new File(".").getCanonicalPath() + File.separator + cmd.getCmdSpec());
} catch (IOException ignored) {
}
logger.debug("Looking for " + script_path);
Content<?> one = NBIO.all().prefix("scripts").name(cmd.getCmdSpec()).extension("js").one();
Content<?> one = NBIO.all().prefix("scripts").name(script_path).extension("js").one();
scriptData = one.asString();
StrInterpolator interpolator = new StrInterpolator(cmd.getCmdArgs());
StrInterpolator interpolator = new StrInterpolator(cmd.getParams());
scriptData = interpolator.apply(scriptData);
return new ScriptData(scriptData,cmd.getCmdArgs());
return scriptData;
}
public static class ScriptData {
private final String scriptText;
private final Map<String, String> scriptParams;
public ScriptData(String scriptText, Map<String,String> scriptParams) {
this.scriptText = scriptText;
this.scriptParams = scriptParams;
}
public String getScriptTextIgnoringParams() {
return scriptText;
}
public Map<String, String> getScriptParams() {
return scriptParams;
}
public String getScriptParamsAndText() {
return "// params:\n" + toJSON(scriptParams) + "\n// script:\n" + scriptText;
}
}
private static String toJSON(Map<?,?> map) {
public static String toJSON(Map<?,?> map) {
StringBuilder sb = new StringBuilder();
List<String> l = new ArrayList<>();
map.forEach((k,v) -> l.add("'" + k + "': '" + v + "'"));

View File

@@ -0,0 +1,9 @@
package io.nosqlbench.engine.cli;
/**
* Add cmd
*/
public interface ScriptBuffer {
ScriptBuffer add(Cmd cmd);
String getParsedScript();
}

View File

@@ -12,49 +12,46 @@ public class NBCLIScenarioParserTest {
@Test
public void providePathForScenario() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "local/example-scenarios" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
List<Cmd> cmds = opts.getCommands();
}
@Test
public void defaultScenario() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "scenario-test" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
List<Cmd> cmds = opts.getCommands();
}
@Test
public void defaultScenarioWithParams() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "scenario-test", "cycles=100"});
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getCmdSpec()).containsOnlyOnce("cycles=100");
assertThat(cmds.get(0).getCmdSpec()).containsOnlyOnce("cycles=");
List<Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getArg("cycles")).isEqualTo("100");
}
@Test
public void namedScenario() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "scenario-test", "schema-only"});
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
List<Cmd> cmds = opts.getCommands();
}
@Test
public void namedScenarioWithParams() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "scenario-test", "schema-only", "cycles=100"});
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getCmdSpec()).containsOnlyOnce("cycles=100");
assertThat(cmds.get(0).getCmdSpec()).containsOnlyOnce("cycles=");
List<Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getArg("cycles")).containsOnlyOnce("100");
}
@Test
public void testThatSilentFinalParametersPersist() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "scenario-test", "type=foo"});
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getCmdSpec()).containsOnlyOnce("driver=stdout");
assertThat(cmds.get(1).getCmdSpec()).containsOnlyOnce("driver=foo");
List<Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getArg("driver")).isEqualTo("stdout");
}
@Test(expected = BasicError.class)
public void testThatVerboseFinalParameterThrowsError() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "scenario-test", "yaml=canttouchthis"});
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
List<Cmd> cmds = opts.getCommands();
}
@Test(expected = BasicError.class)
@@ -65,7 +62,7 @@ public class NBCLIScenarioParserTest {
@Test
public void testThatMultipleScenariosConcatenate() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "scenario-test", "default", "default"});
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
List<Cmd> cmds = opts.getCommands();
assertThat(cmds.size()).isEqualTo(6);
}
@@ -90,13 +87,13 @@ public class NBCLIScenarioParserTest {
@Test
public void testThatUndefValuesAreUndefined() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "scenario-test", "schema-only", "cycles-test=20"});
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
List<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;");
assertThat(cmds.get(0).getArg("cycles-test")).isEqualTo("20");
NBCLIOptions opts1 = new NBCLIOptions(new String[]{ "scenario-test", "schema-only", "doundef=20"});
List<NBCLIOptions.Cmd> cmds1 = opts1.getCommands();
List<Cmd> cmds1 = opts1.getCommands();
assertThat(cmds1.size()).isEqualTo(1);
assertThat(cmds1.get(0).getCmdSpec()).isEqualTo("driver=stdout;workload=scenario-test;tags=phase:schema;");
assertThat(cmds1.get(0).getArg("cycles-test")).isNull();
}

View File

@@ -18,8 +18,6 @@
package io.nosqlbench.engine.cli;
import io.nosqlbench.engine.cli.NBCLIOptions;
import io.nosqlbench.engine.cli.NBCLIScriptAssembly;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,9 +31,8 @@ public class NBCLIScriptAssemblyTest {
"testscripts/printscript.js",
"param1=value1"
});
NBCLIScriptAssembly.ScriptData sd = NBCLIScriptAssembly.assembleScript(opts);
String assembledScript = sd.getScriptTextIgnoringParams();
assertThat(assembledScript).matches("(?s).*a single line.*");
String script = NBCLIScriptAssembly.assemble(opts);
assertThat(script).matches("(?s).*a single line.*");
}
@Test
@@ -49,9 +46,8 @@ public class NBCLIScriptAssemblyTest {
"paramname=another",
"param2=andanother"
});
NBCLIScriptAssembly.ScriptData sd = NBCLIScriptAssembly.assembleScript(opts);
String assembledScript = sd.getScriptTextIgnoringParams();
assertThat(assembledScript).matches("(?s).*a single line.*");
String script = NBCLIScriptAssembly.assemble(opts);
assertThat(script).matches("(?s).*a single line.*");
}
}

View File

@@ -19,8 +19,8 @@ public class TestNBCLIOptions {
NBCLIOptions opts = new NBCLIOptions(new String[]{"start", "foo=wan", "start", "bar=lan"});
assertThat(opts.getCommands()).isNotNull();
assertThat(opts.getCommands().size()).isEqualTo(2);
assertThat(opts.getCommands().get(0).getCmdSpec()).isEqualTo("foo=wan;");
assertThat(opts.getCommands().get(1).getCmdSpec()).isEqualTo("bar=lan;");
assertThat(opts.getCommands().get(0).getParams()).containsEntry("foo","wan");
assertThat(opts.getCommands().get(1).getParams()).containsEntry("bar","lan");
}
@Test
@@ -28,7 +28,8 @@ public class TestNBCLIOptions {
NBCLIOptions opts = new NBCLIOptions(new String[]{"start", "param1=param2", "param3=param4",
"--report-graphite-to", "woot", "--report-interval", "23"});
assertThat(opts.getCommands().size()).isEqualTo(1);
assertThat(opts.getCommands().get(0).getCmdSpec()).isEqualTo("param1=param2;param3=param4;");
assertThat(opts.getCommands().get(0).getParams()).containsEntry("param1","param2");
assertThat(opts.getCommands().get(0).getParams()).containsEntry("param3","param4");
assertThat(opts.wantsReportGraphiteTo()).isEqualTo("woot");
assertThat(opts.getReportInterval()).isEqualTo(23);
}
@@ -52,10 +53,10 @@ public class TestNBCLIOptions {
NBCLIOptions opts = new NBCLIOptions(new String[]{"script", "ascriptaone", "script", "ascriptatwo"});
assertThat(opts.getCommands()).isNotNull();
assertThat(opts.getCommands().size()).isEqualTo(2);
assertThat(opts.getCommands().get(0).getCmdType()).isEqualTo(NBCLIOptions.CmdType.script);
assertThat(opts.getCommands().get(0).getCmdSpec()).isEqualTo("ascriptaone");
assertThat(opts.getCommands().get(1).getCmdType()).isEqualTo(NBCLIOptions.CmdType.script);
assertThat(opts.getCommands().get(1).getCmdSpec()).isEqualTo("ascriptatwo");
assertThat(opts.getCommands().get(0).getCmdType()).isEqualTo(Cmd.CmdType.script);
assertThat(opts.getCommands().get(0).getArg("script_path")).isEqualTo("ascriptaone");
assertThat(opts.getCommands().get(1).getCmdType()).isEqualTo(Cmd.CmdType.script);
assertThat(opts.getCommands().get(1).getArg("script_path")).isEqualTo("ascriptatwo");
}
@Test
@@ -95,10 +96,10 @@ public class TestNBCLIOptions {
public void testShouldRecognizeScriptParams() {
NBCLIOptions opts = new NBCLIOptions(new String[]{"script", "ascript", "param1=value1"});
assertThat(opts.getCommands().size()).isEqualTo(1);
NBCLIOptions.Cmd cmd = opts.getCommands().get(0);
assertThat(cmd.getCmdArgs().size()).isEqualTo(1);
assertThat(cmd.getCmdArgs()).containsKey("param1");
assertThat(cmd.getCmdArgs().get("param1")).isEqualTo("value1");
Cmd cmd = opts.getCommands().get(0);
assertThat(cmd.getParams().size()).isEqualTo(2);
assertThat(cmd.getParams()).containsKey("param1");
assertThat(cmd.getParams().get("param1")).isEqualTo("value1");
}
@Test(expected = InvalidParameterException.class)
@@ -114,88 +115,89 @@ public class TestNBCLIOptions {
@Test
public void testScriptInterpolation() {
NBCLIOptions opts = new NBCLIOptions(new String[]{"script", "script_to_interpolate", "parameter1=replaced"});
NBCLIScriptAssembly.ScriptData s = NBCLIScriptAssembly.assembleScript(opts);
assertThat(s.getScriptTextIgnoringParams()).contains("var foo=replaced;");
assertThat(s.getScriptTextIgnoringParams()).contains("var bar=UNSET:parameter2");
String s = NBCLIScriptAssembly.assemble(opts);
assertThat(s).contains("let foo=replaced;");
assertThat(s).contains("let bar=UNSET:parameter2");
}
@Test
public void testAutoScriptCommand() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "acommand" });
NBCLIScriptAssembly.ScriptData s = NBCLIScriptAssembly.assembleScript(opts);
assertThat(s.getScriptTextIgnoringParams()).contains("acommand script text");
String s = NBCLIScriptAssembly.assemble(opts);
assertThat(s).contains("acommand script text");
}
@Test
public void shouldRecognizeStartActivityCmd() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "start", "driver=woot" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
List<Cmd> cmds = opts.getCommands();
assertThat(cmds).hasSize(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(NBCLIOptions.CmdType.start);
assertThat(cmds.get(0).getCmdType()).isEqualTo(Cmd.CmdType.start);
}
@Test
public void shouldRecognizeRunActivityCmd() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "run", "driver=runwoot" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
List<Cmd> cmds = opts.getCommands();
assertThat(cmds).hasSize(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(NBCLIOptions.CmdType.run);
assertThat(cmds.get(0).getCmdType()).isEqualTo(Cmd.CmdType.run);
}
@Test
public void shouldRecognizeStopActivityCmd() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "stop", "woah" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
List<Cmd> cmds = opts.getCommands();
assertThat(cmds).hasSize(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(NBCLIOptions.CmdType.stop);
assertThat(cmds.get(0).getCmdSpec()).isEqualTo("woah");
assertThat(cmds.get(0).getCmdType()).isEqualTo(Cmd.CmdType.stop);
assertThat(cmds.get(0).getArg("alias_name")).isEqualTo("woah");
}
@Test(expected = InvalidParameterException.class)
public void shouldThrowErrorForInvalidStopActivity() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "stop", "woah=woah" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
List<Cmd> cmds = opts.getCommands();
}
@Test
public void shouldRecognizeAwaitActivityCmd() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "await", "awaitme" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getCmdType()).isEqualTo(NBCLIOptions.CmdType.await);
assertThat(cmds.get(0).getCmdSpec()).isEqualTo("awaitme");
List<Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getCmdType()).isEqualTo(Cmd.CmdType.await);
assertThat(cmds.get(0).getArg("alias_name")).isEqualTo("awaitme");
}
@Test(expected = InvalidParameterException.class)
public void shouldThrowErrorForInvalidAwaitActivity() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "await", "awaitme=notvalid" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
List<Cmd> cmds = opts.getCommands();
}
@Test
public void shouldRecognizewaitMillisCmd() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "waitmillis", "23234" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getCmdType()).isEqualTo(NBCLIOptions.CmdType.waitmillis);
assertThat(cmds.get(0).getCmdSpec()).isEqualTo("23234");
List<Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getCmdType()).isEqualTo(Cmd.CmdType.waitmillis);
assertThat(cmds.get(0).getArg("millis_to_wait")).isEqualTo("23234");
}
@Test(expected = NumberFormatException.class)
public void shouldThrowErrorForInvalidWaitMillisOperand() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "waitmillis", "noway" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
List<Cmd> cmds = opts.getCommands();
NBCLIScriptAssembly.assemble(opts);
}
@Test
public void listWorkloads() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "--list-workloads"});
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
List<Cmd> cmds = opts.getCommands();
assertThat(opts.wantsScenariosList());
}

View File

@@ -1,3 +1,3 @@
var foo=<<parameter1:value1>>;
var bar=<<parameter2>>;
var baz;
let foo=TEMPLATE(parameter1:value1);
let bar=TEMPLATE(parameter2);
let baz;