functional run named scenario ui (except for the run button)

This commit is contained in:
phact
2020-04-08 17:49:00 -04:00
parent d8b3e6214c
commit 71ee22039e
34 changed files with 126 additions and 57 deletions

View File

@@ -265,6 +265,7 @@ public class NBCLIScenarioParser {
// }
private static Pattern templatePattern = Pattern.compile("TEMPLATE\\((.+?)\\)");
private static Pattern innerTemplatePattern = Pattern.compile("TEMPLATE\\((.+?)$");
private static Pattern templatePattern2 = Pattern.compile("<<(.+?)>>");
@@ -289,21 +290,11 @@ public class NBCLIScenarioParser {
Content<?> content = referencedWorkload.orElseThrow();
StmtsDocList stmts = StatementsLoader.load(logger,content);
Set<String> templates = new HashSet<>();
Map<String, String> templates = new HashMap<>();
try {
List<String> lines = Files.readAllLines(yamlPath);
for (String line : lines) {
Matcher matcher = templatePattern.matcher(line);
while (matcher.find()) {
templates.add(matcher.group(1));
}
matcher = templatePattern2.matcher(line);
while (matcher.find()) {
templates.add(matcher.group(1));
}
templates = matchTemplates(line, templates);
}
} catch (IOException e) {
e.printStackTrace();
@@ -322,4 +313,34 @@ public class NBCLIScenarioParser {
return workloadDescriptions;
}
public static Map<String, String> matchTemplates(String line, Map<String, String> templates) {
Matcher matcher = templatePattern.matcher(line);
while (matcher.find()) {
String match = matcher.group(1);
Matcher innerMatcher = innerTemplatePattern.matcher(match);
String[] matchArray = match.split(",");
//TODO: support recursive matches
if (innerMatcher.find()) {
String[] innerMatch = innerMatcher.group(1).split(",");
//We want the outer name with the inner default value
templates.put(matchArray[0], innerMatch[1]);
}else{
templates.put(matchArray[0], matchArray[1]);
}
}
matcher = templatePattern2.matcher(line);
while (matcher.find()) {
String match = matcher.group(1);
String[] matchArray = match.split(":");
templates.put(matchArray[0],matchArray[1]);
}
return templates;
}
}

View File

@@ -1,14 +1,14 @@
package io.nosqlbench.engine.api.scenarios;
import java.util.List;
import java.util.Set;
import java.util.Map;
public class WorkloadDesc {
private final String yamlPath;
private final List<String> scenarioNames;
private final Set<String> templates;
private final Map<String, String> templates;
public WorkloadDesc(String yamlPath, List<String> scenarioNames, Set<String> templates) {
public WorkloadDesc(String yamlPath, List<String> scenarioNames, Map<String, String> templates) {
this.yamlPath = yamlPath;
this.scenarioNames = scenarioNames;
this.templates = templates;
@@ -27,7 +27,7 @@ public class WorkloadDesc {
return scenarioNames;
}
public Set<String> getTemplates() {
public Map<String, String> getTemplates() {
return templates;
}
}