use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneSSTableUtilTest method testWrongArgFailsAndPrintsHelp.
@Test
public void testWrongArgFailsAndPrintsHelp() {
ToolResult tool = ToolRunner.invokeClass(StandaloneSSTableUtil.class, "--debugwrong", "system_schema", "tables");
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("Unrecognized option"));
assertEquals(1, tool.getExitCode());
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneSSTableUtilTest method testMaybeChangeDocs.
@Test
public void testMaybeChangeDocs() {
// If you added, modified options or help, please update docs if necessary
ToolResult tool = ToolRunner.invokeClass(StandaloneSSTableUtil.class, "-h");
String help = "usage: sstableutil [options] <keyspace> <column_family>\n" + "--\n" + "List sstable files for the provided table.\n" + "--\n" + "Options are:\n" + " -c,--cleanup clean-up any outstanding transactions\n" + " -d,--debug display stack traces\n" + " -h,--help display this help message\n" + " -o,--oplog include operation logs\n" + " -t,--type <arg> all (list all files, final or temporary), tmp (list\n" + " temporary files only), final (list final files only),\n" + " -v,--verbose verbose output\n";
Assertions.assertThat(tool.getStdout()).isEqualTo(help);
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneSSTableUtilTest method testDefaultCall.
@Test
public void testDefaultCall() {
ToolResult tool = ToolRunner.invokeClass(StandaloneSSTableUtil.class, "system_schema", "tables");
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("Listing files..."));
Assertions.assertThat(tool.getCleanedStderr()).isEmpty();
assertEquals(0, tool.getExitCode());
assertCorrectEnvPostTest();
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneSSTableUtilTest method testTypeArg.
@Test
public void testTypeArg() {
Arrays.asList("-t", "--type").forEach(arg -> {
ToolResult tool = ToolRunner.invokeClass(StandaloneSSTableUtil.class, arg, "system_schema", "tables");
assertThat("Arg: [" + arg + "]", tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
assertThat("Arg: [" + arg + "]", tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("Missing arguments"));
assertEquals("Arg: [" + arg + "]", 1, tool.getExitCode());
assertCorrectEnvPostTest();
});
// '-t wrong' renders 'all' file types
Arrays.asList(Pair.of("-t", "all"), Pair.of("-t", "tmp"), Pair.of("-t", "final"), Pair.of("-t", "wrong"), Pair.of("--type", "all"), Pair.of("--type", "tmp"), Pair.of("--type", "final"), Pair.of("--type", "wrong")).forEach(arg -> {
ToolResult tool = ToolRunner.invokeClass(StandaloneSSTableUtil.class, arg.getLeft(), arg.getRight(), "system_schema", "tables");
Assertions.assertThat(tool.getStdout()).as("Arg: [%s]", arg).isEqualTo("Listing files...\n");
Assertions.assertThat(tool.getCleanedStderr()).as("Arg: [%s]", arg).isEmpty();
tool.assertOnExitCode();
assertCorrectEnvPostTest();
});
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneSplitterTest method testWrongFilename.
@Test
public void testWrongFilename() {
ToolResult tool = ToolRunner.invokeClass(StandaloneSplitter.class, "mockFile");
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("Skipping inexisting file mockFile"));
assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("No valid sstables to split"));
assertEquals(1, tool.getExitCode());
assertCorrectEnvPostTest();
}
Aggregations