mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-11-23 09:16:37 -06:00
nosqlbench-370 Specifying full path to the yaml workload crashes
This commit is contained in:
parent
53199e72bb
commit
9ea609142b
@ -145,10 +145,12 @@ public class NBCLIScenarioParser {
|
||||
undefKeys.forEach(buildingCmd::remove);
|
||||
|
||||
if (!buildingCmd.containsKey("workload")) {
|
||||
String relativeWorkloadPathFromRoot = yamlWithNamedScenarios.asPath().toString();
|
||||
relativeWorkloadPathFromRoot = relativeWorkloadPathFromRoot.startsWith("/") ?
|
||||
relativeWorkloadPathFromRoot.substring(1) : relativeWorkloadPathFromRoot;
|
||||
buildingCmd.put("workload", "workload=" + relativeWorkloadPathFromRoot);
|
||||
// The logic to remove the leading slash was likely used to fix a nuisance bug before,
|
||||
// although it is clearly not correct as-is. Leaving temporarily for context.
|
||||
// String relativeWorkloadPathFromRoot = yamlWithNamedScenarios.asPath().toString();
|
||||
// relativeWorkloadPathFromRoot = relativeWorkloadPathFromRoot.startsWith("/") ?
|
||||
// relativeWorkloadPathFromRoot.substring(1) : relativeWorkloadPathFromRoot;
|
||||
buildingCmd.put("workload", "workload=" + workloadName);
|
||||
}
|
||||
|
||||
if (!buildingCmd.containsKey("alias")) {
|
||||
|
@ -4,6 +4,7 @@ import io.nosqlbench.engine.api.scenarios.NBCLIScenarioParser;
|
||||
import io.nosqlbench.nb.api.errors.BasicError;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@ -76,7 +77,7 @@ public class NBCLIScenarioParserTest {
|
||||
assertThat(cmds.size()).isEqualTo(1);
|
||||
assertThat(cmds.get(0).getArg("driver")).isEqualTo("stdout");
|
||||
assertThat(cmds.get(0).getArg("cycles")).isEqualTo("10");
|
||||
assertThat(cmds.get(0).getArg("workload")).isEqualTo("target/test-classes/activities/scenario-test.yaml");
|
||||
assertThat(cmds.get(0).getArg("workload")).isEqualTo("scenario-test");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -87,7 +88,7 @@ public class NBCLIScenarioParserTest {
|
||||
assertThat(cmds.get(0).getArg("driver")).isEqualTo("stdout");
|
||||
assertThat(cmds.get(0).getArg("cycles")).isEqualTo("20");
|
||||
assertThat(cmds.get(0).getArg("cycles-test")).isEqualTo("20");
|
||||
assertThat(cmds.get(0).getArg("workload")).isEqualTo("target/test-classes/activities/scenario-test.yaml");
|
||||
assertThat(cmds.get(0).getArg("workload")).isEqualTo("scenario-test");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -100,9 +101,23 @@ public class NBCLIScenarioParserTest {
|
||||
List<Cmd> cmds1 = opts1.getCommands();
|
||||
assertThat(cmds1.size()).isEqualTo(1);
|
||||
assertThat(cmds1.get(0).getArg("cycles-test")).isNull();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatFullyQualifiedScenarioFilesAreSupported() {
|
||||
Path cwd = Path.of(".").toAbsolutePath();
|
||||
System.out.println("cwd: '" + cwd + "'");
|
||||
|
||||
Path rel = Path.of("src/test/resources/activities/scenario-test.yaml");
|
||||
|
||||
assertThat(rel).exists();
|
||||
Path absolute = rel.toAbsolutePath();
|
||||
assertThat(absolute).exists();
|
||||
|
||||
NBCLIOptions opts = new NBCLIOptions(new String[]{ absolute.toString(), "schema-only", "cycles-test=20"});
|
||||
List<Cmd> cmds = opts.getCommands();
|
||||
assertThat(cmds.size()).isGreaterThan(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanitizer() {
|
||||
|
@ -2,6 +2,10 @@ package io.nosqlbench.nb.api.content;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.LinkedHashSet;
|
||||
@ -257,4 +261,20 @@ public class NBIOTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchFullyQualifiedPathCorrectly() {
|
||||
Path tmpdir = Paths.get("/tmp");
|
||||
if (!Files.isDirectory(tmpdir)) return;
|
||||
try {
|
||||
File tempFile = File.createTempFile(tmpdir.toString(), "testfile.csv");
|
||||
tempFile.deleteOnExit();
|
||||
String fullpath = tempFile.getAbsolutePath();
|
||||
Files.write(Path.of(fullpath), "COL1,COL2\n\"val1\",\"val2\"\n".getBytes(StandardCharsets.UTF_8));
|
||||
List<Content<?>> results = NBIO.all().name(fullpath).list();
|
||||
assertThat(results.size()).isEqualTo(1);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user