Search in sources :

Example 11 with ToolResult

use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.

the class StandaloneVerifierTest method testTooManyArgs.

@Test
public void testTooManyArgs() {
    ToolResult tool = ToolRunner.invokeClass(StandaloneVerifier.class, "another arg", "system_schema", "tables");
    assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
    assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("Too many arguments"));
    assertEquals(1, tool.getExitCode());
}
Also used : ToolResult(org.apache.cassandra.tools.ToolRunner.ToolResult) Test(org.junit.Test)

Example 12 with ToolResult

use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.

the class StandaloneVerifierTest method testDebugArg.

@Test
public void testDebugArg() {
    ToolResult tool = ToolRunner.invokeClass(StandaloneVerifier.class, "--debug", "system_schema", "tables");
    assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("debug=true"));
    Assertions.assertThat(tool.getCleanedStderr()).isEmpty();
    assertCorrectEnvPostTest();
    tool.assertOnCleanExit();
}
Also used : ToolResult(org.apache.cassandra.tools.ToolRunner.ToolResult) Test(org.junit.Test)

Example 13 with ToolResult

use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.

the class StandaloneVerifierTest method testMaybeChangeDocs.

@Test
public void testMaybeChangeDocs() {
    // If you added, modified options or help, please update docs if necessary
    ToolResult tool = ToolRunner.invokeClass(StandaloneVerifier.class, "-h");
    String help = "usage: sstableverify [options] <keyspace> <column_family>\n" + "--\n" + "Verify the sstable for the provided table.\n" + "--\n" + "Options are:\n" + " -c,--check_version          make sure sstables are the latest version\n" + "    --debug                  display stack traces\n" + " -e,--extended               extended verification\n" + " -h,--help                   display this help message\n" + " -q,--quick                  do a quick check, don't read all data\n" + " -r,--mutate_repair_status   don't mutate repair status\n" + " -t,--token_range <range>    long token range of the format left,right.\n" + "                             This may be provided multiple times to define multiple different ranges\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 14 with ToolResult

use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.

the class StandaloneVerifierTest method testWrongArgFailsAndPrintsHelp.

@Test
public void testWrongArgFailsAndPrintsHelp() {
    ToolResult tool = ToolRunner.invokeClass(StandaloneVerifier.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 15 with ToolResult

use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.

the class ToolsEnvsConfigsTest method testJDKEnvInfoDefaultCleaners.

// Some JDK can output env info on stdout/err. Check we can clean them
@SuppressWarnings("resource")
@Test
public void testJDKEnvInfoDefaultCleaners() {
    ToolResult tool = ToolRunner.invoke(ImmutableMap.of("_JAVA_OPTIONS", "-Djava.net.preferIPv4Stack=true"), null, CQLTester.buildNodetoolArgs(Collections.emptyList()));
    assertTrue("Cleaned Stderr was not empty: " + tool.getCleanedStderr(), tool.getCleanedStderr().isEmpty());
}
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