Search in sources :

Example 86 with ToolResult

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

Example 87 with ToolResult

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

Example 88 with ToolResult

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

Example 89 with ToolResult

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

Example 90 with ToolResult

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