use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class NodeToolEnableDisableBinaryTest method testEnableDisableBinary.
@Test
public void testEnableDisableBinary() throws Throwable {
// We can connect
assertTrue(canConnect());
// We can't connect after disabling
ToolResult tool = ToolRunner.invokeNodetoolJvmDtest(cluster.get(1), "disablebinary");
Assertions.assertThat(tool.getStdout()).containsIgnoringCase("Stop listening for CQL clients");
assertTrue(tool.getCleanedStderr().isEmpty());
assertEquals(0, tool.getExitCode());
assertFalse(canConnect());
// We can connect after re-enabling
tool = ToolRunner.invokeNodetoolJvmDtest(cluster.get(1), "enablebinary");
Assertions.assertThat(tool.getStdout()).containsIgnoringCase("Starting listening for CQL clients");
assertTrue(tool.getCleanedStderr().isEmpty());
assertEquals(0, tool.getExitCode());
assertTrue(canConnect());
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneUpgraderOnSStablesTest method testUpgradeKeepFiles.
@Test
public void testUpgradeKeepFiles() throws Throwable {
LegacySSTableTest.truncateLegacyTables(legacyId);
LegacySSTableTest.loadLegacyTables(legacyId);
List<String> origFiles = getSStableFiles("legacy_tables", "legacy_" + legacyId + "_simple");
ToolResult tool = ToolRunner.invokeClass(StandaloneUpgrader.class, "-k", "legacy_tables", "legacy_" + legacyId + "_simple");
Assertions.assertThat(tool.getStdout()).contains("Found 1 sstables that need upgrading.");
Assertions.assertThat(tool.getStdout()).contains("legacy_tables/legacy_" + legacyId + "_simple");
Assertions.assertThat(tool.getStdout()).contains("-Data.db");
tool.assertOnCleanExit();
List<String> newFiles = getSStableFiles("legacy_tables", "legacy_" + legacyId + "_simple");
origFiles.removeAll(newFiles);
// check previous version files are kept
assertEquals(0, origFiles.size());
// need to make sure the new sstables are live, so that they get truncated later
Keyspace.open("legacy_tables").getColumnFamilyStore("legacy_" + legacyId + "_simple").loadNewSSTables();
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneUpgraderOnSStablesTest method testUpgrade.
@Test
public void testUpgrade() throws Throwable {
LegacySSTableTest.truncateLegacyTables(legacyId);
LegacySSTableTest.loadLegacyTables(legacyId);
List<String> origFiles = getSStableFiles("legacy_tables", "legacy_" + legacyId + "_simple");
ToolResult tool = ToolRunner.invokeClass(StandaloneUpgrader.class, "legacy_tables", "legacy_" + legacyId + "_simple");
Assertions.assertThat(tool.getStdout()).contains("Found 1 sstables that need upgrading.");
Assertions.assertThat(tool.getStdout()).contains("legacy_tables/legacy_" + legacyId + "_simple");
Assertions.assertThat(tool.getStdout()).contains("-Data.db");
tool.assertOnCleanExit();
List<String> newFiles = getSStableFiles("legacy_tables", "legacy_" + legacyId + "_simple");
int origSize = origFiles.size();
origFiles.removeAll(newFiles);
// check previous version files are gone
assertEquals(origSize, origFiles.size());
// need to make sure the new sstables are live, so that they get truncated later
Keyspace.open("legacy_tables").getColumnFamilyStore("legacy_" + legacyId + "_simple").loadNewSSTables();
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneVerifierOnSSTablesTest method testCheckVersionWithWrongVersion.
@Test
public void testCheckVersionWithWrongVersion() throws Exception {
String keyspace = "StandaloneVerifierTestWrongVersions";
String tableName = "legacy_ma_simple";
createAndPopulateTable(keyspace, tableName, cfs -> {
// let's just copy old version files from test data into the source dir
File testDataDir = new File("test/data/legacy-sstables/ma/legacy_tables/legacy_ma_simple");
for (org.apache.cassandra.io.util.File cfsDir : cfs.getDirectories().getCFDirectories()) {
FileUtils.copyDirectory(testDataDir, cfsDir.toJavaIOFile());
}
});
ToolResult tool = ToolRunner.invokeClass(StandaloneVerifier.class, keyspace, tableName, "-c");
assertEquals(1, tool.getExitCode());
Assertions.assertThat(tool.getStdout()).contains("is not the latest version, run upgradesstables");
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneVerifierOnSSTablesTest method testCorruptDataFile.
@Test
public void testCorruptDataFile() throws Exception {
String keyspaceName = "StandaloneVerifierTestCorruptDataKs";
String corruptDataTable = "corruptDataTable";
createAndPopulateTable(keyspaceName, corruptDataTable, cfs -> {
SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
long row0Start = sstable.getPosition(PartitionPosition.ForKey.get(ByteBufferUtil.bytes("0"), cfs.getPartitioner()), SSTableReader.Operator.EQ).position;
long row1Start = sstable.getPosition(PartitionPosition.ForKey.get(ByteBufferUtil.bytes("1"), cfs.getPartitioner()), SSTableReader.Operator.EQ).position;
long startPosition = Math.min(row0Start, row1Start);
try (RandomAccessFile file = new RandomAccessFile(sstable.getFilename(), "rw")) {
file.seek(startPosition);
file.writeBytes(StringUtils.repeat('z', 2));
}
});
ToolResult tool = ToolRunner.invokeClass(StandaloneVerifier.class, keyspaceName, corruptDataTable);
assertEquals(1, tool.getExitCode());
Assertions.assertThat(tool.getStdout()).contains("Invalid SSTable", corruptDataTable);
}
Aggregations