use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class SSTableMetadataViewerTest method testMaybeChangeDocs.
@Test
public void testMaybeChangeDocs() {
// If you added, modified options or help, please update docs if necessary
ToolResult tool = ToolRunner.invokeClass(SSTableMetadataViewer.class, "-h");
assertEquals("You must supply at least one sstable\n" + "usage: sstablemetadata <options> <sstable...> [-c] [-g <arg>] [-s] [-t <arg>] [-u]\n" + "\n" + "Dump information about SSTable[s] for Apache Cassandra 3.x\n" + "Options:\n" + " -c,--colors Use ANSI color sequences\n" + " -g,--gc_grace_seconds <arg> Time to use when calculating droppable tombstones\n" + " -s,--scan Full sstable scan for additional details. Only available in 3.0+ sstables. Defaults: false\n" + " -t,--timestamp_unit <arg> Time unit that cell timestamps are written with\n" + " -u,--unicode Use unicode to draw histograms and progress bars\n\n", tool.getCleanedStderr());
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class SSTableMetadataViewerTest method testGCArg.
@Test
public void testGCArg() {
Arrays.asList(Pair.of("-g", ""), Pair.of("-g", "w"), Pair.of("--gc_grace_seconds", ""), Pair.of("--gc_grace_seconds", "w")).forEach(arg -> {
ToolResult tool = ToolRunner.invokeClass(SSTableMetadataViewer.class, arg.getLeft(), arg.getRight(), "mockFile");
assertEquals(-1, tool.getExitCode());
Assertions.assertThat(tool.getStderr()).contains(NumberFormatException.class.getSimpleName());
});
Arrays.asList(Pair.of("-g", "5"), Pair.of("--gc_grace_seconds", "5")).forEach(arg -> {
ToolResult tool = ToolRunner.invokeClass(SSTableMetadataViewer.class, arg.getLeft(), arg.getRight(), "mockFile");
assertThat("Arg: [" + arg + "]", tool.getStdout(), CoreMatchers.containsStringIgnoringCase("No such file"));
Assertions.assertThat(tool.getCleanedStderr()).as("Arg: [%s]", arg).isEmpty();
tool.assertOnExitCode();
assertGoodEnvPostTest();
});
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class SSTableMetadataViewerTest method testNAFileCall.
@Test
public void testNAFileCall() {
ToolResult tool = ToolRunner.invokeClass(SSTableMetadataViewer.class, "mockFile");
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("No such file"));
Assertions.assertThat(tool.getCleanedStderr()).isEmpty();
assertEquals(0, tool.getExitCode());
assertGoodEnvPostTest();
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class SSTableMetadataViewerTest method testOnlySstableArg.
@Test
public void testOnlySstableArg() {
ToolResult tool = ToolRunner.invokeClass(SSTableMetadataViewer.class, sstable);
Assertions.assertThat(tool.getStdout()).doesNotContain(Util.BLUE);
assertTrue(tool.getStdout(), CharMatcher.ascii().matchesAllOf(tool.getStdout()));
Assertions.assertThat(tool.getStdout()).doesNotContain("Widest Partitions");
Assertions.assertThat(tool.getStdout()).contains(sstable.replaceAll("-Data\\.db$", ""));
assertTrue(tool.getStderr(), tool.getStderr().isEmpty());
assertEquals(0, tool.getExitCode());
assertGoodEnvPostTest();
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class SSTableMetadataViewerTest method testNoArgsPrintsHelp.
@Test
public void testNoArgsPrintsHelp() {
ToolResult tool = ToolRunner.invokeClass(SSTableMetadataViewer.class);
{
assertTrue(tool.getStdout(), tool.getStdout().isEmpty());
assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("Options:"));
assertEquals(1, tool.getExitCode());
}
assertNoUnexpectedThreadsStarted(null);
assertSchemaNotLoaded();
assertCLSMNotLoaded();
assertSystemKSNotLoaded();
assertKeyspaceNotLoaded();
assertServerNotLoaded();
}
Aggregations