Merge branch 'master' into releases

This commit is contained in:
Jonathan Shook
2020-03-16 23:16:10 -05:00
13 changed files with 80 additions and 80 deletions

View File

@@ -53,7 +53,7 @@ public class NBCLI {
System.exit(0);
}
EBCLIOptions options = new EBCLIOptions(args);
NBCLIOptions options = new NBCLIOptions(args);
if (options.wantsBasicHelp()) {
System.out.println(loadHelpFile("commandline.md"));
@@ -161,13 +161,13 @@ public class NBCLI {
}
}
for (EBCLIOptions.LoggerConfig histoLogger : options.getHistoLoggerConfigs()) {
for (NBCLIOptions.LoggerConfig histoLogger : options.getHistoLoggerConfigs()) {
ActivityMetrics.addHistoLogger(sessionName, histoLogger.pattern, histoLogger.file, histoLogger.interval);
}
for (EBCLIOptions.LoggerConfig statsLogger : options.getStatsLoggerConfigs()) {
for (NBCLIOptions.LoggerConfig statsLogger : options.getStatsLoggerConfigs()) {
ActivityMetrics.addStatsLogger(sessionName, statsLogger.pattern, statsLogger.file, statsLogger.interval);
}
for (EBCLIOptions.LoggerConfig classicConfigs : options.getClassicHistoConfigs()) {
for (NBCLIOptions.LoggerConfig classicConfigs : options.getClassicHistoConfigs()) {
ActivityMetrics.addClassicHistos(sessionName, classicConfigs.pattern, classicConfigs.file, classicConfigs.interval);
}
@@ -183,7 +183,7 @@ public class NBCLI {
ScenariosExecutor executor = new ScenariosExecutor("executor-" + sessionName, 1);
Scenario scenario = new Scenario(sessionName, options.getProgressSpec());
EBCLIScriptAssembly.ScriptData scriptData = EBCLIScriptAssembly.assembleScript(options);
NBCLIScriptAssembly.ScriptData scriptData = NBCLIScriptAssembly.assembleScript(options);
if (options.wantsShowScript()) {
System.out.println("// Rendered Script");
System.out.println(scriptData.getScriptParamsAndText());

View File

@@ -16,10 +16,10 @@ import java.util.stream.Collectors;
* No CLI parser lib is useful for command structures, it seems. So we have this instead, which is good enough.
* If something better is needed later, this can be replaced.
*/
public class EBCLIOptions {
public class NBCLIOptions {
public static final String docoptFileName = "commandline.md";
private final static Logger logger = LoggerFactory.getLogger(EBCLIOptions.class);
private final static Logger logger = LoggerFactory.getLogger(NBCLIOptions.class);
// Discovery
private static final String HELP = "--help";
@@ -108,7 +108,7 @@ public class EBCLIOptions {
private boolean enableChart = false;
private boolean dockerMetrics = false;
public EBCLIOptions(String[] args) {
public NBCLIOptions(String[] args) {
parse(args);
}

View File

@@ -11,15 +11,15 @@ import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
public class EBCLIScriptAssembly {
private final static Logger logger = LoggerFactory.getLogger(EBCLIScriptAssembly.class);
public class NBCLIScriptAssembly {
private final static Logger logger = LoggerFactory.getLogger(NBCLIScriptAssembly.class);
public static ScriptData assembleScript(EBCLIOptions options) {
public static ScriptData assembleScript(NBCLIOptions options) {
StringBuilder sb = new StringBuilder();
Map<String,String> params = new HashMap<>();
for (EBCLIOptions.Cmd cmd : options.getCommands()) {
for (NBCLIOptions.Cmd cmd : options.getCommands()) {
String cmdSpec = cmd.getCmdSpec();
EBCLIOptions.CmdType cmdType = cmd.getCmdType();
NBCLIOptions.CmdType cmdType = cmd.getCmdType();
ActivityDef activityDef;
switch (cmd.getCmdType()) {
case script:
@@ -71,7 +71,7 @@ public class EBCLIScriptAssembly {
return new ScriptData(sb.toString(), params);
}
private static ScriptData loadScript(EBCLIOptions.Cmd cmd) {
private static ScriptData loadScript(NBCLIOptions.Cmd cmd) {
String scriptData;
try {

View File

@@ -18,8 +18,8 @@
package io.nosqlbench.engine.cli;
import io.nosqlbench.engine.cli.EBCLIOptions;
import io.nosqlbench.engine.cli.EBCLIScriptAssembly;
import io.nosqlbench.engine.cli.NBCLIOptions;
import io.nosqlbench.engine.cli.NBCLIScriptAssembly;
import org.testng.annotations.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -28,19 +28,19 @@ public class NBCLIScriptAssemblyTest {
@Test
public void testScriptParamsSingle() {
EBCLIOptions opts = new EBCLIOptions(new String[] {
NBCLIOptions opts = new NBCLIOptions(new String[] {
"script",
"testscripts/printscript.js",
"param1=value1"
});
EBCLIScriptAssembly.ScriptData sd = EBCLIScriptAssembly.assembleScript(opts);
NBCLIScriptAssembly.ScriptData sd = NBCLIScriptAssembly.assembleScript(opts);
String assembledScript = sd.getScriptTextIgnoringParams();
assertThat(assembledScript).matches("(?s).*a single line.*");
}
@Test
public void testScriptParamsMulti() {
EBCLIOptions opts = new EBCLIOptions(new String[] {
NBCLIOptions opts = new NBCLIOptions(new String[] {
"script",
"testscripts/printscript.js",
"param1=value1",
@@ -49,9 +49,9 @@ public class NBCLIScriptAssemblyTest {
"paramname=another",
"param2=andanother"
});
EBCLIScriptAssembly.ScriptData sd = EBCLIScriptAssembly.assembleScript(opts);
NBCLIScriptAssembly.ScriptData sd = NBCLIScriptAssembly.assembleScript(opts);
String assembledScript = sd.getScriptTextIgnoringParams();
assertThat(assembledScript).matches("(?s).*a single line.*");
}
}
}

View File

@@ -12,7 +12,7 @@ public class TestNBCLIOptions {
@Test
public void shouldRecognizeActivities() {
EBCLIOptions opts = new EBCLIOptions(new String[]{"start", "foo=wan", "start", "bar=lan"});
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;");
@@ -21,7 +21,7 @@ public class TestNBCLIOptions {
@Test
public void shouldParseLongActivityForm() {
EBCLIOptions opts = new EBCLIOptions(new String[]{"start", "param1=param2", "param3=param4",
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;");
@@ -31,64 +31,64 @@ public class TestNBCLIOptions {
@Test
public void shouldRecognizeShortVersion() {
EBCLIOptions opts = new EBCLIOptions(new String[]{"--version"});
NBCLIOptions opts = new NBCLIOptions(new String[]{"--version"});
assertThat(opts.isWantsVersionShort()).isTrue();
assertThat(opts.wantsVersionCoords()).isFalse();
}
@Test
public void shouldRecognizeVersion() {
EBCLIOptions opts = new EBCLIOptions(new String[]{"--version-coords"});
NBCLIOptions opts = new NBCLIOptions(new String[]{"--version-coords"});
assertThat(opts.isWantsVersionShort()).isFalse();
assertThat(opts.wantsVersionCoords()).isTrue();
}
@Test
public void shouldRecognizeScripts() {
EBCLIOptions opts = new EBCLIOptions(new String[]{"script", "ascriptaone", "script", "ascriptatwo"});
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(EBCLIOptions.CmdType.script);
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(EBCLIOptions.CmdType.script);
assertThat(opts.getCommands().get(1).getCmdType()).isEqualTo(NBCLIOptions.CmdType.script);
assertThat(opts.getCommands().get(1).getCmdSpec()).isEqualTo("ascriptatwo");
}
@Test
public void shouldRecognizeWantsActivityTypes() {
EBCLIOptions opts = new EBCLIOptions(new String[]{"--list-activity-types"});
NBCLIOptions opts = new NBCLIOptions(new String[]{"--list-activity-types"});
assertThat(opts.wantsActivityTypes()).isTrue();
opts = new EBCLIOptions(new String[]{"--version"});
opts = new NBCLIOptions(new String[]{"--version"});
assertThat(opts.wantsActivityTypes()).isFalse();
}
@Test
public void shouldRecognizeWantsBasicHelp() {
EBCLIOptions opts = new EBCLIOptions(new String[]{"--help"});
NBCLIOptions opts = new NBCLIOptions(new String[]{"--help"});
assertThat(opts.wantsBasicHelp()).isTrue();
opts = new EBCLIOptions(new String[]{"--version"});
opts = new NBCLIOptions(new String[]{"--version"});
assertThat(opts.wantsTopicalHelp()).isFalse();
}
@Test
public void shouldRecognizeWantsActivityHelp() {
EBCLIOptions opts = new EBCLIOptions(new String[]{"--help", "foo"});
NBCLIOptions opts = new NBCLIOptions(new String[]{"--help", "foo"});
assertThat(opts.wantsTopicalHelp()).isTrue();
assertThat(opts.wantsTopicalHelpFor()).isEqualTo("foo");
opts = new EBCLIOptions(new String[]{"--version"});
opts = new NBCLIOptions(new String[]{"--version"});
assertThat(opts.wantsTopicalHelp()).isFalse();
}
@Test(expectedExceptions = {InvalidParameterException.class}, expectedExceptionsMessageRegExp = ".*unrecognized option.*")
public void shouldErrorSanelyWhenNoMatch() {
EBCLIOptions opts = new EBCLIOptions(new String[]{"unrecognizable command"});
NBCLIOptions opts = new NBCLIOptions(new String[]{"unrecognizable command"});
}
@Test
public void testShouldRecognizeScriptParams() {
EBCLIOptions opts = new EBCLIOptions(new String[]{"script", "ascript", "param1=value1"});
NBCLIOptions opts = new NBCLIOptions(new String[]{"script", "ascript", "param1=value1"});
assertThat(opts.getCommands().size()).isEqualTo(1);
EBCLIOptions.Cmd cmd = opts.getCommands().get(0);
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");
@@ -97,93 +97,93 @@ public class TestNBCLIOptions {
@Test(expectedExceptions = {InvalidParameterException.class},
expectedExceptionsMessageRegExp = ".*script name must precede.*")
public void testShouldErrorSanelyWhenScriptNameSkipped() {
EBCLIOptions opts = new EBCLIOptions(new String[]{"script", "param1=value1"});
NBCLIOptions opts = new NBCLIOptions(new String[]{"script", "param1=value1"});
}
@Test(expectedExceptions = {InvalidParameterException.class},
expectedExceptionsMessageRegExp = ".*script name not found.*")
public void testShouldErrorForMissingScriptName() {
EBCLIOptions opts = new EBCLIOptions(new String[]{"script"});
NBCLIOptions opts = new NBCLIOptions(new String[]{"script"});
}
@Test
public void testScriptInterpolation() {
EBCLIOptions opts = new EBCLIOptions(new String[]{"script", "script_to_interpolate", "parameter1=replaced"});
EBCLIScriptAssembly.ScriptData s = EBCLIScriptAssembly.assembleScript(opts);
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");
}
@Test
public void testAutoScriptCommand() {
EBCLIOptions opts = new EBCLIOptions(new String[]{ "acommand" });
EBCLIScriptAssembly.ScriptData s = EBCLIScriptAssembly.assembleScript(opts);
NBCLIOptions opts = new NBCLIOptions(new String[]{ "acommand" });
NBCLIScriptAssembly.ScriptData s = NBCLIScriptAssembly.assembleScript(opts);
assertThat(s.getScriptTextIgnoringParams()).contains("acommand script text");
}
@Test
public void shouldRecognizeStartActivityCmd() {
EBCLIOptions opts = new EBCLIOptions(new String[]{ "start", "type=woot" });
List<EBCLIOptions.Cmd> cmds = opts.getCommands();
NBCLIOptions opts = new NBCLIOptions(new String[]{ "start", "type=woot" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
assertThat(cmds).hasSize(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(EBCLIOptions.CmdType.start);
assertThat(cmds.get(0).getCmdType()).isEqualTo(NBCLIOptions.CmdType.start);
}
@Test
public void shouldRecognizeRunActivityCmd() {
EBCLIOptions opts = new EBCLIOptions(new String[]{ "run", "type=runwoot" });
List<EBCLIOptions.Cmd> cmds = opts.getCommands();
NBCLIOptions opts = new NBCLIOptions(new String[]{ "run", "type=runwoot" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
assertThat(cmds).hasSize(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(EBCLIOptions.CmdType.run);
assertThat(cmds.get(0).getCmdType()).isEqualTo(NBCLIOptions.CmdType.run);
}
@Test
public void shouldRecognizeStopActivityCmd() {
EBCLIOptions opts = new EBCLIOptions(new String[]{ "stop", "woah" });
List<EBCLIOptions.Cmd> cmds = opts.getCommands();
NBCLIOptions opts = new NBCLIOptions(new String[]{ "stop", "woah" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
assertThat(cmds).hasSize(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(EBCLIOptions.CmdType.stop);
assertThat(cmds.get(0).getCmdType()).isEqualTo(NBCLIOptions.CmdType.stop);
assertThat(cmds.get(0).getCmdSpec()).isEqualTo("woah");
}
@Test(expectedExceptions = InvalidParameterException.class)
public void shouldThrowErrorForInvalidStopActivity() {
EBCLIOptions opts = new EBCLIOptions(new String[]{ "stop", "woah=woah" });
List<EBCLIOptions.Cmd> cmds = opts.getCommands();
NBCLIOptions opts = new NBCLIOptions(new String[]{ "stop", "woah=woah" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
}
@Test
public void shouldRecognizeAwaitActivityCmd() {
EBCLIOptions opts = new EBCLIOptions(new String[]{ "await", "awaitme" });
List<EBCLIOptions.Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getCmdType()).isEqualTo(EBCLIOptions.CmdType.await);
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");
}
@Test(expectedExceptions = InvalidParameterException.class)
public void shouldThrowErrorForInvalidAwaitActivity() {
EBCLIOptions opts = new EBCLIOptions(new String[]{ "await", "awaitme=notvalid" });
List<EBCLIOptions.Cmd> cmds = opts.getCommands();
NBCLIOptions opts = new NBCLIOptions(new String[]{ "await", "awaitme=notvalid" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
}
@Test
public void shouldRecognizewaitMillisCmd() {
EBCLIOptions opts = new EBCLIOptions(new String[]{ "waitmillis", "23234" });
List<EBCLIOptions.Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getCmdType()).isEqualTo(EBCLIOptions.CmdType.waitmillis);
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");
}
@Test(expectedExceptions = NumberFormatException.class)
public void shouldThrowErrorForInvalidWaitMillisOperand() {
EBCLIOptions opts = new EBCLIOptions(new String[]{ "waitmillis", "noway" });
List<EBCLIOptions.Cmd> cmds = opts.getCommands();
NBCLIOptions opts = new NBCLIOptions(new String[]{ "waitmillis", "noway" });
List<NBCLIOptions.Cmd> cmds = opts.getCommands();
}