use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class SSTableExpiredBlockersTest method testDefaultCall.
@Test
public void testDefaultCall() {
ToolResult tool = ToolRunner.invokeClass(SSTableExpiredBlockers.class, "system_schema", "tables");
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("No sstables for"));
Assertions.assertThat(tool.getCleanedStderr()).isEmpty();
assertEquals(1, tool.getExitCode());
assertCorrectEnvPostTest();
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class SSTableExportTest method testExcludePKArgOutOfOrder.
@Test
public void testExcludePKArgOutOfOrder() {
ToolResult tool = ToolRunner.invokeClass(SSTableExport.class, "-x", "0", sstable);
assertThat(tool.getStdout(), containsStringIgnoringCase("usage:"));
assertThat(tool.getCleanedStderr(), containsStringIgnoringCase("You must supply exactly one sstable"));
assertThat(tool.getCleanedStderr(), containsStringIgnoringCase("before the -k/-x options"));
assertEquals(1, tool.getExitCode());
assertPostTestEnv();
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class SSTableMetadataViewerTest method testScanArg.
@Test
public void testScanArg() {
Arrays.asList("-s", "--scan").stream().forEach(arg -> {
ToolResult tool = ToolRunner.invokeClass(SSTableMetadataViewer.class, arg, sstable);
Assertions.assertThat(tool.getStdout()).contains("Widest Partitions");
Assertions.assertThat(tool.getStdout()).contains(sstable.replaceAll("-Data\\.db$", ""));
assertTrue("Arg: [" + arg + "]\n" + tool.getStderr(), tool.getStderr().isEmpty());
assertEquals(0, tool.getExitCode());
});
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class SSTableMetadataViewerTest method testTSUnitArg.
@Test
public void testTSUnitArg() {
Arrays.asList(Pair.of("-t", ""), Pair.of("-t", "w"), Pair.of("--timestamp_unit", ""), Pair.of("--timestamp_unit", "w")).forEach(arg -> {
ToolResult tool = ToolRunner.invokeClass(SSTableMetadataViewer.class, arg.getLeft(), arg.getRight(), "mockFile");
assertEquals(-1, tool.getExitCode());
Assertions.assertThat(tool.getStderr()).contains(IllegalArgumentException.class.getSimpleName());
});
Arrays.asList(Pair.of("-t", "SECONDS"), Pair.of("--timestamp_unit", "SECONDS")).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 NodeToolEnableDisableBinaryTest method testMaybeChangeDocs.
@Test
public void testMaybeChangeDocs() {
// If you added, modified options or help, please update docs if necessary
ToolResult tool = ToolRunner.invokeNodetoolJvmDtest(cluster.get(1), "help", "disablebinary");
String help = "NAME\n" + " nodetool disablebinary - Disable native transport (binary protocol)\n" + "\n" + "SYNOPSIS\n" + " nodetool [(-h <host> | --host <host>)] [(-p <port> | --port <port>)]\n" + " [(-pp | --print-port)] [(-pw <password> | --password <password>)]\n" + " [(-pwf <passwordFilePath> | --password-file <passwordFilePath>)]\n" + " [(-u <username> | --username <username>)] disablebinary\n" + "\n" + "OPTIONS\n" + " -h <host>, --host <host>\n" + " Node hostname or ip address\n" + "\n" + " -p <port>, --port <port>\n" + " Remote jmx agent port number\n" + "\n" + " -pp, --print-port\n" + " Operate in 4.0 mode with hosts disambiguated by port number\n" + "\n" + " -pw <password>, --password <password>\n" + " Remote jmx agent password\n" + "\n" + " -pwf <passwordFilePath>, --password-file <passwordFilePath>\n" + " Path to the JMX password file\n" + "\n" + " -u <username>, --username <username>\n" + " Remote jmx agent username\n" + "\n" + "\n";
Assertions.assertThat(tool.getStdout()).isEqualTo(help);
tool = ToolRunner.invokeNodetoolJvmDtest(cluster.get(1), "help", "enablebinary");
help = "NAME\n" + " nodetool enablebinary - Reenable native transport (binary protocol)\n" + "\n" + "SYNOPSIS\n" + " nodetool [(-h <host> | --host <host>)] [(-p <port> | --port <port>)]\n" + " [(-pp | --print-port)] [(-pw <password> | --password <password>)]\n" + " [(-pwf <passwordFilePath> | --password-file <passwordFilePath>)]\n" + " [(-u <username> | --username <username>)] enablebinary\n" + "\n" + "OPTIONS\n" + " -h <host>, --host <host>\n" + " Node hostname or ip address\n" + "\n" + " -p <port>, --port <port>\n" + " Remote jmx agent port number\n" + "\n" + " -pp, --print-port\n" + " Operate in 4.0 mode with hosts disambiguated by port number\n" + "\n" + " -pw <password>, --password <password>\n" + " Remote jmx agent password\n" + "\n" + " -pwf <passwordFilePath>, --password-file <passwordFilePath>\n" + " Path to the JMX password file\n" + "\n" + " -u <username>, --username <username>\n" + " Remote jmx agent username\n" + "\n" + "\n";
Assertions.assertThat(tool.getStdout()).isEqualTo(help);
}
Aggregations