mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
provide better error messages for malformed yaml
This commit is contained in:
parent
5355edf759
commit
8143a2c275
@ -45,11 +45,11 @@ public class RawStmtsLoader {
|
||||
try {
|
||||
Optional<Content<?>> oyaml = NBIO.all().prefix(searchPaths).name(path).extension(YAML_EXTENSIONS).first();
|
||||
data = oyaml.map(Content::asString).orElseThrow(() -> new BasicError("Unable to load " + path));
|
||||
return loadString(logger, data);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("error while reading file " + path, e);
|
||||
}
|
||||
|
||||
return loadString(logger, data);
|
||||
}
|
||||
|
||||
private RawStmtsDocList parseYaml(Logger logger, String data) {
|
||||
|
@ -267,6 +267,8 @@ public class NBCLIScenarioParser {
|
||||
|
||||
for (Path yamlPath : yamlPathList) {
|
||||
|
||||
try {
|
||||
|
||||
String referenced = yamlPath.toString();
|
||||
|
||||
if (referenced.startsWith("/")) {
|
||||
@ -302,7 +304,7 @@ public class NBCLIScenarioParser {
|
||||
templates = matchTemplates(line, templates);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
@ -323,6 +325,10 @@ public class NBCLIScenarioParser {
|
||||
String description = stmts.getDescription();
|
||||
workloadDescriptions.add(new WorkloadDesc(referenced, scenarioNames, sortedTemplates, description, ""));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error while scanning path '" + yamlPath.toString() + "':" + e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
Collections.sort(workloadDescriptions);
|
||||
|
||||
|
@ -84,8 +84,12 @@ public class RawYamlStatementLoaderTest {
|
||||
assertThat(blocks).hasSize(1);
|
||||
RawStmtsBlock rawStmtsBlock = blocks.get(0);
|
||||
assertThat(rawStmtsBlock.getName()).isEqualTo("block0");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testErrorMsg() {
|
||||
RawStmtsLoader ysl = new RawStmtsLoader();
|
||||
RawStmtsDocList erthing = ysl.loadPath(logger, "testdocs/badyamlfile.yaml");
|
||||
}
|
||||
|
||||
}
|
||||
|
2
engine-api/src/test/resources/testdocs/badyamlfile.yaml
Normal file
2
engine-api/src/test/resources/testdocs/badyamlfile.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
# This is just a testing file too.
|
||||
description: This is just a testing file too
|
@ -8,9 +8,13 @@ import java.util.List;
|
||||
public class NBCLIScenarios {
|
||||
public static void printWorkloads(boolean includeScenarios,
|
||||
String... includes) {
|
||||
List<WorkloadDesc> workloads =
|
||||
NBCLIScenarioParser.getWorkloadsWithScenarioScripts(true, includes);
|
||||
List<WorkloadDesc> workloads = List.of();
|
||||
try {
|
||||
workloads= NBCLIScenarioParser.getWorkloadsWithScenarioScripts(true, includes);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error while getting workloads:" + e.getMessage(), e);
|
||||
|
||||
}
|
||||
for (WorkloadDesc workload : workloads) {
|
||||
System.out.println(workload.toMarkdown(includeScenarios));
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class NBCliIntegrationTests {
|
||||
invoker.setLogDir("logs/test");
|
||||
ProcessResult result = invoker.run(
|
||||
"workload-test", 15, java, "-jar",
|
||||
JARNAME, "--logs-dir", "logs/test", "--list-workloads"
|
||||
JARNAME, "--logs-dir", "logs/test", "--list-workloads", "--show-stacktraces"
|
||||
);
|
||||
System.out.println(result.getStdoutData());
|
||||
System.out.println(result.getStderrData());
|
||||
|
Loading…
Reference in New Issue
Block a user