mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-26 00:31:07 -06:00
--list-scripts
This commit is contained in:
parent
abf8986c81
commit
281e4f9124
@ -350,6 +350,34 @@ public class NBCLIScenarioParser {
|
||||
|
||||
}
|
||||
|
||||
public static List<String> getScripts(boolean defaultIncludes, String... includes) {
|
||||
|
||||
NBPathsAPI.GetPrefix searchin = NBIO.all();
|
||||
if (defaultIncludes) {
|
||||
searchin = searchin.prefix(SEARCH_IN);
|
||||
}
|
||||
|
||||
List<Path> scriptPaths = searchin
|
||||
.prefix("scripts/auto")
|
||||
.prefix(includes)
|
||||
.extension("js")
|
||||
.list().stream().map(Content::asPath).collect(Collectors.toList());
|
||||
;
|
||||
|
||||
List<String> scriptNames = new ArrayList();
|
||||
|
||||
for (Path scriptPath : scriptPaths) {
|
||||
String name = scriptPath.getFileName().toString();
|
||||
name = name.substring(0, name.lastIndexOf('.'));
|
||||
|
||||
scriptNames.add(name);
|
||||
}
|
||||
|
||||
|
||||
return scriptNames;
|
||||
|
||||
}
|
||||
|
||||
public static Map<String, String> matchTemplates(String line, Map<String, String> templates) {
|
||||
Matcher matcher = templatePattern.matcher(line);
|
||||
|
||||
|
@ -208,6 +208,11 @@ public class NBCLI {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
if (options.wantsScriptList()) {
|
||||
NBCLIScripts.printScripts(true, options.wantsIncludes());
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
if (options.wantsToCopyResource()) {
|
||||
String resourceToCopy = options.wantsToCopyResourceNamed();
|
||||
logger.debug("user requests to copy out " + resourceToCopy);
|
||||
|
@ -46,6 +46,7 @@ public class NBCLIOptions {
|
||||
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_SCRIPTS = "--list-scripts";
|
||||
private static final String LIST_WORKLOADS = "--list-workloads";
|
||||
private static final String LIST_SCENARIOS = "--list-scenarios";
|
||||
private static final String LIST_INPUT_TYPES = "--list-input-types";
|
||||
@ -133,6 +134,7 @@ public class NBCLIOptions {
|
||||
private boolean enableChart = false;
|
||||
private boolean dockerMetrics = false;
|
||||
private boolean wantsScenariosList = false;
|
||||
private boolean wantsScriptList = false;
|
||||
private String wantsToCopyWorkload = null;
|
||||
private boolean wantsWorkloadsList = false;
|
||||
private final List<String> wantsToIncludePaths = new ArrayList<>();
|
||||
@ -519,6 +521,10 @@ public class NBCLIOptions {
|
||||
arglist.removeFirst();
|
||||
wantsScenariosList = true;
|
||||
break;
|
||||
case LIST_SCRIPTS:
|
||||
arglist.removeFirst();
|
||||
wantsScriptList = true;
|
||||
break;
|
||||
case LIST_WORKLOADS:
|
||||
arglist.removeFirst();
|
||||
wantsWorkloadsList = true;
|
||||
@ -775,6 +781,10 @@ public class NBCLIOptions {
|
||||
return wantsScenariosList;
|
||||
}
|
||||
|
||||
public boolean wantsScriptList() {
|
||||
return wantsScriptList;
|
||||
}
|
||||
|
||||
public boolean wantsToCopyResource() {
|
||||
return wantsToCopyWorkload != null;
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package io.nosqlbench.engine.cli;
|
||||
|
||||
import io.nosqlbench.engine.api.scenarios.NBCLIScenarioParser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NBCLIScripts {
|
||||
public static void printScripts(boolean includeScenarios,
|
||||
String... includes) {
|
||||
List<String> scripts =
|
||||
NBCLIScenarioParser.getScripts(true, includes);
|
||||
|
||||
for (String script: scripts) {
|
||||
System.out.println(script);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -13,6 +13,9 @@
|
||||
# To get a list of scenarios to run:
|
||||
./nb --list-scenarios
|
||||
|
||||
# To get a list of scripts to run:
|
||||
./nb --list-scripts
|
||||
|
||||
# To provide your own contact points (comma separated), add the hosts= parameter
|
||||
./nb cql-iot hosts=host1,host2
|
||||
|
||||
|
@ -178,6 +178,13 @@ public class TestNBCLIOptions {
|
||||
assertThat(opts.wantsScenariosList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listScripts() {
|
||||
NBCLIOptions opts = new NBCLIOptions(new String[]{ "--list-scripts"});
|
||||
List<Cmd> cmds = opts.getCommands();
|
||||
assertThat(opts.wantsScriptList());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void clTest() {
|
||||
|
Loading…
Reference in New Issue
Block a user