Search in sources :

Example 16 with ToolResult

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

the class CassandrastressTest method testNoArgsPrintsHelp.

@Test
public void testNoArgsPrintsHelp() {
    ToolResult tool = ToolRunner.invokeCassandraStress();
    assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
    assertTrue("Tool stderr: " + tool.getCleanedStderr(), tool.getCleanedStderr().isEmpty());
    assertEquals(1, tool.getExitCode());
}
Also used : ToolResult(org.apache.cassandra.tools.ToolRunner.ToolResult) Test(org.junit.Test)

Example 17 with ToolResult

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

the class CassandrastressTest method invokeAndAssertCleanExit.

void invokeAndAssertCleanExit(String[] baseArgs, String... extraArgs) {
    String[] args = Arrays.copyOf(baseArgs, baseArgs.length + extraArgs.length);
    System.arraycopy(extraArgs, 0, args, baseArgs.length, extraArgs.length);
    ToolResult tool = ToolRunner.invokeCassandraStress(args);
    tool.assertOnCleanExit();
}
Also used : ToolResult(org.apache.cassandra.tools.ToolRunner.ToolResult)

Example 18 with ToolResult

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

the class StandaloneVerifierOnSSTablesTest method testCorruptStatsFile.

@Test
public void testCorruptStatsFile() throws Exception {
    String keyspaceName = "StandaloneVerifierTestCorruptStatsKs";
    String corruptStatsTable = "corruptStatsTable";
    createAndPopulateTable(keyspaceName, corruptStatsTable, cfs -> {
        SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
        try (RandomAccessFile file = new RandomAccessFile(sstable.descriptor.filenameFor(Component.STATS), "rw")) {
            file.seek(0);
            file.writeBytes(StringUtils.repeat('z', 2));
        }
    });
    ToolResult tool = ToolRunner.invokeClass(StandaloneVerifier.class, keyspaceName, corruptStatsTable);
    assertEquals(1, tool.getExitCode());
    Assertions.assertThat(tool.getStderr()).contains("Error Loading", corruptStatsTable);
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) RandomAccessFile(java.io.RandomAccessFile) ToolResult(org.apache.cassandra.tools.ToolRunner.ToolResult) Test(org.junit.Test)

Example 19 with ToolResult

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

the class StandaloneScrubberTest method testHelpArg.

@Test
public void testHelpArg() {
    Arrays.asList("-h", "--help").forEach(arg -> {
        ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, arg);
        assertThat("Arg: [" + arg + "]", tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
        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 20 with ToolResult

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

the class StandaloneScrubberTest method testDefaultCall.

@Test
public void testDefaultCall() {
    ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "system_schema", "tables");
    assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("Pre-scrub sstables snapshotted into snapshot"));
    Assertions.assertThat(tool.getCleanedStderr()).isEmpty();
    assertEquals(0, 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