mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2026-08-08 20:18:11 -05:00
merge of nb5-preview onto main, main is now the feed for nb5-preview work
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package io.nosqlbench.engine.cli;
|
||||
|
||||
import io.nosqlbench.docexporter.BundledMarkdownExporter;
|
||||
import io.nosqlbench.docsys.core.NBWebServerApp;
|
||||
import io.nosqlbench.engine.api.activityapi.cyclelog.outputs.cyclelog.CycleLogDumperUtility;
|
||||
import io.nosqlbench.engine.api.activityapi.cyclelog.outputs.cyclelog.CycleLogImporterUtility;
|
||||
@@ -17,6 +18,7 @@ import io.nosqlbench.engine.core.script.Scenario;
|
||||
import io.nosqlbench.engine.core.script.ScenariosExecutor;
|
||||
import io.nosqlbench.engine.core.script.ScriptParams;
|
||||
import io.nosqlbench.engine.docker.DockerMetricsManager;
|
||||
import io.nosqlbench.nb.annotations.Maturity;
|
||||
import io.nosqlbench.nb.api.annotations.Annotation;
|
||||
import io.nosqlbench.nb.api.annotations.Layer;
|
||||
import io.nosqlbench.nb.api.content.Content;
|
||||
@@ -56,19 +58,18 @@ public class NBCLI {
|
||||
|
||||
public NBCLI(String commandName) {
|
||||
this.commandName = commandName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
NBCLI cli = new NBCLI("eb");
|
||||
NBCLI cli = new NBCLI("nb");
|
||||
cli.run(args);
|
||||
} catch (Exception e) {
|
||||
boolean showStackTraces = false;
|
||||
for (String arg : args) {
|
||||
if (arg.toLowerCase(Locale.ROOT).equals("--show-stacktraces")) {
|
||||
showStackTraces=true;
|
||||
|
||||
if (arg.toLowerCase(Locale.ROOT).startsWith("-v") || (arg.toLowerCase(Locale.ROOT).equals("--show-stacktraces"))) {
|
||||
showStackTraces = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,6 +171,10 @@ public class NBCLI {
|
||||
annotatorsConfig = "[{type:'log',level:'info'}]";
|
||||
}
|
||||
|
||||
if (args.length > 0 && args[0].toLowerCase().equals("export-docs")) {
|
||||
BundledMarkdownExporter.main(Arrays.copyOfRange(args,1,args.length));
|
||||
System.exit(0);
|
||||
}
|
||||
if (args.length > 0 && args[0].toLowerCase().equals("virtdata")) {
|
||||
VirtDataMainApp.main(Arrays.copyOfRange(args, 1, args.length));
|
||||
System.exit(0);
|
||||
@@ -263,12 +268,12 @@ public class NBCLI {
|
||||
}
|
||||
|
||||
if (options.wantsInputTypes()) {
|
||||
InputType.FINDER.getAllSelectors().forEach(System.out::println);
|
||||
InputType.FINDER.getAllSelectors().forEach((k,v) -> System.out.println(k + " (" + v.name() + ")"));
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
if (options.wantsMarkerTypes()) {
|
||||
OutputType.FINDER.getAllSelectors().forEach(System.out::println);
|
||||
OutputType.FINDER.getAllSelectors().forEach((k,v) -> System.out.println(k + " (" + v.name() + ")"));
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@@ -364,8 +369,8 @@ public class NBCLI {
|
||||
options.wantsCompileScript(),
|
||||
options.getReportSummaryTo(),
|
||||
String.join("\n", args),
|
||||
options.getLogsDirectory()
|
||||
);
|
||||
options.getLogsDirectory(),
|
||||
Maturity.Unspecified);
|
||||
|
||||
ScriptBuffer buffer = new BasicScriptBuffer()
|
||||
.add(options.getCommands()
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.nosqlbench.engine.cli;
|
||||
import io.nosqlbench.engine.api.metrics.IndicatorMode;
|
||||
import io.nosqlbench.engine.api.util.Unit;
|
||||
import io.nosqlbench.engine.core.script.Scenario;
|
||||
import io.nosqlbench.nb.annotations.Maturity;
|
||||
import io.nosqlbench.nb.api.NBEnvironment;
|
||||
import io.nosqlbench.nb.api.errors.BasicError;
|
||||
import io.nosqlbench.nb.api.logging.NBLogLevel;
|
||||
@@ -59,6 +60,8 @@ public class NBCLIOptions {
|
||||
private static final String SCRIPT_FILE = "--script-file";
|
||||
private static final String COPY = "--copy";
|
||||
private static final String SHOW_STACKTRACES = "--show-stacktraces";
|
||||
private static final String EXPERIMENTAL = "--experimental";
|
||||
private static final String MATURITY = "--maturity";
|
||||
|
||||
// Execution
|
||||
private static final String EXPORT_CYCLE_LOG = "--export-cycle-log";
|
||||
@@ -67,6 +70,7 @@ public class NBCLIOptions {
|
||||
|
||||
// Execution Options
|
||||
|
||||
|
||||
private static final String SESSION_NAME = "--session-name";
|
||||
private static final String LOGS_DIR = "--logs-dir";
|
||||
private static final String WORKSPACES_DIR = "--workspaces-dir";
|
||||
@@ -162,6 +166,7 @@ public class NBCLIOptions {
|
||||
private String dockerPromRetentionDays = "183d";
|
||||
private String reportSummaryTo = REPORT_SUMMARY_TO_DEFAULT;
|
||||
private boolean enableAnsi = System.getenv("TERM")!=null && !System.getenv("TERM").isEmpty();
|
||||
private Maturity minMaturity = Maturity.Unspecified;
|
||||
|
||||
public String getAnnotatorsConfig() {
|
||||
return annotatorsConfig;
|
||||
@@ -297,10 +302,12 @@ public class NBCLIOptions {
|
||||
break;
|
||||
case DASH_VV_DEBUG:
|
||||
consoleLevel = NBLogLevel.DEBUG;
|
||||
setWantsStackTraces(true);
|
||||
arglist.removeFirst();
|
||||
break;
|
||||
case DASH_VVV_TRACE:
|
||||
consoleLevel = NBLogLevel.TRACE;
|
||||
setWantsStackTraces(true);
|
||||
arglist.removeFirst();
|
||||
break;
|
||||
case ANNOTATE_EVENTS:
|
||||
@@ -392,6 +399,15 @@ public class NBCLIOptions {
|
||||
arglist.removeFirst();
|
||||
showStackTraces = true;
|
||||
break;
|
||||
case EXPERIMENTAL:
|
||||
arglist.removeFirst();
|
||||
arglist.addFirst("experimental");
|
||||
arglist.addFirst("--maturity");
|
||||
break;
|
||||
case MATURITY:
|
||||
arglist.removeFirst();
|
||||
String maturity = readWordOrThrow(arglist,"maturity of components to allow");
|
||||
this.minMaturity = Maturity.valueOf(maturity.toLowerCase(Locale.ROOT));
|
||||
default:
|
||||
nonincludes.addLast(arglist.removeFirst());
|
||||
}
|
||||
@@ -626,6 +642,10 @@ public class NBCLIOptions {
|
||||
return configs;
|
||||
}
|
||||
|
||||
public Maturity allowMinMaturity() {
|
||||
return minMaturity;
|
||||
}
|
||||
|
||||
public List<Cmd> getCommands() {
|
||||
return cmdList;
|
||||
}
|
||||
|
||||
+9
-1
@@ -38,8 +38,16 @@ public class NBCLIScenarioParserTemplateVarTest {
|
||||
OpTemplate optpl1 = workload1.getStmts().get(0);
|
||||
System.out.println("op from cmd1:"+optpl1);
|
||||
assertThat(optpl1.getStmt()).contains("cycle {cycle} overridden overridden\n");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testThatAdditionalCLIParamIsAdded() {
|
||||
NBCLIOptions opts = new NBCLIOptions(new String[]{"local/example-scenarios-templatevars", "tvar3=tval3"});
|
||||
List<Cmd> cmds = opts.getCommands();
|
||||
cmds.forEach(System.out::println);
|
||||
assertThat(cmds).hasSize(2);
|
||||
assertThat(cmds.get(0).getParams().get("tvar3")).isEqualTo("tval3");
|
||||
assertThat(cmds.get(1).getParams().get("tvar3")).isEqualTo("tval3");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -143,6 +143,24 @@ public class NBCLIScenarioParserTest {
|
||||
public void testSanitizer() {
|
||||
String sanitized = NBCLIScenarioParser.sanitize("A-b,c_d");
|
||||
assertThat(sanitized).isEqualTo("Abcd");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubStepSelection() {
|
||||
NBCLIOptions opts = new NBCLIOptions(new String[]{ "scenario-test", "schema-only", "cycles-test=20"});
|
||||
List<Cmd> cmds = opts.getCommands();
|
||||
assertThat(cmds.size()).isEqualTo(1);
|
||||
assertThat(cmds.get(0).getParams()).isEqualTo(Map.of(
|
||||
"alias","scenariotest_schemaonly_000",
|
||||
"cycles-test","20",
|
||||
"driver","stdout",
|
||||
"tags","phase:schema",
|
||||
"workload","scenario-test"
|
||||
));
|
||||
NBCLIOptions opts1 = new NBCLIOptions(new String[]{ "local/example-scenarios", "namedsteps.one", "testparam1=testvalue2"});
|
||||
List<Cmd> cmds1 = opts1.getCommands();
|
||||
assertThat(cmds1.size()).isEqualTo(1);
|
||||
assertThat(cmds1.get(0).getArg("cycles-test")).isNull();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,13 @@ scenarios:
|
||||
default:
|
||||
- run cycles=3 alias=A driver=stdout
|
||||
- run cycles=5 alias=B driver=stdout
|
||||
namedsteps:
|
||||
one: run cycles=3 alias=A driver=stdout testparam1=testvalue1
|
||||
two: run cycles=5 alias=B driver=stdout
|
||||
|
||||
bindings:
|
||||
cycle: Identity()
|
||||
name: NumberNameToCycle()
|
||||
|
||||
statements:
|
||||
- cycle: "cycle {cycle}\n"
|
||||
|
||||
Reference in New Issue
Block a user