mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Merge pull request #1960 from cognitree/better-error-on-scenario-step-selection
Better error when users select a scenario step without setting the scenario
This commit is contained in:
commit
82e60d3f2a
@ -234,4 +234,11 @@ public class NBCLIScenarioPreprocessorTest {
|
|||||||
.isThrownBy(() -> NBCLIScenarioPreprocessor.splitCommand(unclosedQuoteCmd))
|
.isThrownBy(() -> NBCLIScenarioPreprocessor.splitCommand(unclosedQuoteCmd))
|
||||||
.withMessageContaining("Unclosed quote found in scenario cmd");
|
.withMessageContaining("Unclosed quote found in scenario cmd");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testThatSuggestionsAreShownForDirectStepNameUsage() {
|
||||||
|
assertThatExceptionOfType(BasicError.class)
|
||||||
|
.isThrownBy(() -> new NBCLIOptions(new String[]{"scenario_test", "schema"}, NBCLIOptions.Mode.ParseAllOptions))
|
||||||
|
.withMessageContainingAll("default.schema", "schema_only.schema");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,8 +133,20 @@ public class NBCLIScenarioPreprocessor {
|
|||||||
if (nameparts.length==1) {
|
if (nameparts.length==1) {
|
||||||
Map<String, String> namedScenario = scenarios.getNamedScenario(scenarioName);
|
Map<String, String> namedScenario = scenarios.getNamedScenario(scenarioName);
|
||||||
if (namedScenario==null) {
|
if (namedScenario==null) {
|
||||||
throw new BasicError("Unable to find named scenario '" + scenarioName + "' in workload '" + workloadName
|
List<String> matchingSteps = new LinkedList<>();
|
||||||
+ "', but you can pick from one of: " + String.join(", ", scenarios.getScenarioNames()));
|
for (String scenario : scenarios.getScenarioNames()) {
|
||||||
|
Map<String, String> selectedScenario = scenarios.getNamedScenario(scenario);
|
||||||
|
if (selectedScenario.containsKey(scenarioName)) {
|
||||||
|
matchingSteps.add(scenario + "." + scenarioName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (matchingSteps.isEmpty()) {
|
||||||
|
throw new BasicError("Unable to find named scenario '" + scenarioName + "' in workload '" + workloadName
|
||||||
|
+ "', but you can pick from one of: " + String.join(", ", scenarios.getScenarioNames()));
|
||||||
|
} else {
|
||||||
|
throw new BasicError("Unable to find named scenario '" + scenarioName + "' in workload '" + workloadName
|
||||||
|
+ "', you might be looking for one of these scenario steps: " + String.join(", ", matchingSteps));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
namedSteps.putAll(namedScenario);
|
namedSteps.putAll(namedScenario);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user