Search in sources :

Example 66 with ToolResult

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

the class StandaloneVerifierOnSSTablesTest method testWorkingDataFile.

@Test
public void testWorkingDataFile() throws Exception {
    String keyspaceName = "StandaloneVerifierTestWorkingDataKs";
    String workingTable = "workingTable";
    createAndPopulateTable(keyspaceName, workingTable, x -> {
    });
    ToolResult tool = ToolRunner.invokeClass(StandaloneVerifier.class, keyspaceName, workingTable);
    assertEquals(0, tool.getExitCode());
    tool.assertOnCleanExit();
}
Also used : ToolResult(org.apache.cassandra.tools.ToolRunner.ToolResult) Test(org.junit.Test)

Example 67 with ToolResult

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

the class StandaloneVerifierOnSSTablesTest method testCheckVersionValidVersion.

@Test
public void testCheckVersionValidVersion() throws Exception {
    String keyspaceName = "StandaloneVerifierTestCheckVersionWorking";
    String workingTable = "workingCheckTable";
    createAndPopulateTable(keyspaceName, workingTable, x -> {
    });
    ToolResult tool = ToolRunner.invokeClass(StandaloneVerifier.class, keyspaceName, workingTable, "-c");
    assertEquals(0, tool.getExitCode());
    tool.assertOnCleanExit();
}
Also used : ToolResult(org.apache.cassandra.tools.ToolRunner.ToolResult) Test(org.junit.Test)

Example 68 with ToolResult

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

the class StandaloneScrubberTest method testWrongArgFailsAndPrintsHelp.

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

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

the class StandaloneSplitterWithCQLTesterTest method testNoSnapshotOption.

@Test
public void testNoSnapshotOption() throws Throwable {
    ToolResult tool = ToolRunner.invokeClass(StandaloneSplitter.class, "-s", "1", "--no-snapshot", sstableFileName);
    assertTrue(origSstables.size() < Arrays.asList(sstablesDir.tryList()).size());
    assertTrue(tool.getStdout(), tool.getStdout().isEmpty());
    assertTrue(tool.getCleanedStderr(), tool.getCleanedStderr().isEmpty());
    assertEquals(0, tool.getExitCode());
}
Also used : ToolResult(org.apache.cassandra.tools.ToolRunner.ToolResult) Test(org.junit.Test)

Example 70 with ToolResult

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

the class StandaloneSplitterWithCQLTesterTest method testSplittingMultipleSSTables.

@Test
public void testSplittingMultipleSSTables() throws Throwable {
    ArrayList<String> args = new ArrayList<>(Arrays.asList("-s", "1"));
    args.addAll(Arrays.asList(sstablesDir.tryList()).stream().map(f -> f.absolutePath()).collect(Collectors.toList()));
    ToolResult tool = ToolRunner.invokeClass(StandaloneSplitter.class, args.toArray(new String[args.size()]));
    List<File> splitFiles = Arrays.asList(sstablesDir.tryList());
    splitFiles.stream().forEach(f -> {
        if (f.name().endsWith("Data.db") && !origSstables.contains(f))
            assertTrue(f.name() + " is way bigger than 1MiB: [" + f.length() + "] bytes", // give a 20% margin on size check
            f.length() <= 1024 * 1024 * 1.2);
    });
    assertTrue(origSstables.size() < splitFiles.size());
    assertTrue(tool.getCleanedStderr(), tool.getCleanedStderr().isEmpty());
    assertEquals(0, tool.getExitCode());
}
Also used : ArrayList(java.util.ArrayList) File(org.apache.cassandra.io.util.File) 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