Search in sources :

Example 31 with ToolResult

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

Example 32 with ToolResult

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

Example 33 with ToolResult

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

Example 34 with ToolResult

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

Example 35 with ToolResult

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();
}
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