Search in sources :

Example 56 with ToolResult

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();
}
Also used : ToolResult(org.apache.cassandra.tools.ToolRunner.ToolResult) Test(org.junit.Test)

Example 57 with ToolResult

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();
}
Also used : ToolResult(org.apache.cassandra.tools.ToolRunner.ToolResult) Test(org.junit.Test)

Example 58 with ToolResult

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());
    });
}
Also used : ToolResult(org.apache.cassandra.tools.ToolRunner.ToolResult) Test(org.junit.Test)

Example 59 with ToolResult

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();
    });
}
Also used : ToolResult(org.apache.cassandra.tools.ToolRunner.ToolResult) Test(org.junit.Test)

Example 60 with ToolResult

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);
}
Also used : ToolResult(org.apache.cassandra.tools.ToolRunner.ToolResult) Test(org.junit.Test)

Aggregations

ToolResult (org.apache.cassandra.tools.ToolRunner.ToolResult)123 Test (org.junit.Test)102 File (org.apache.cassandra.io.util.File)4 NoHostAvailableException (com.datastax.driver.core.exceptions.NoHostAvailableException)3 RandomAccessFile (java.io.RandomAccessFile)3 LegacySSTableTest (org.apache.cassandra.io.sstable.LegacySSTableTest)3 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)2 Session (com.datastax.driver.core.Session)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)1 Keyspace (org.apache.cassandra.db.Keyspace)1 Cluster (org.apache.cassandra.distributed.Cluster)1 IInvokableInstance (org.apache.cassandra.distributed.api.IInvokableInstance)1 Ignore (org.junit.Ignore)1