use of org.apache.cassandra.distributed.api.IInvokableInstance in project cassandra by apache.
the class JVMStabilityInspectorCorruptSSTableExceptionTest method test.
private static void test(DiskFailurePolicy policy, boolean expectNativeTransportRunning, boolean expectGossiperEnabled) throws Exception {
String table = policy.name();
try (final Cluster cluster = init(getCluster(policy).start())) {
IInvokableInstance node = cluster.get(1);
boolean[] setup = node.callOnInstance(() -> {
CassandraDaemon instanceForTesting = CassandraDaemon.getInstanceForTesting();
instanceForTesting.completeSetup();
StorageService.instance.registerDaemon(instanceForTesting);
return new boolean[] { StorageService.instance.isNativeTransportRunning(), Gossiper.instance.isEnabled() };
});
// make sure environment is setup propertly
Assert.assertTrue("Native support is not running, test is not ready!", setup[0]);
Assert.assertTrue("Gossiper is not running, test is not ready!", setup[1]);
cluster.schemaChange("CREATE TABLE " + KEYSPACE + "." + table + " (id bigint PRIMARY KEY)");
node.executeInternal("INSERT INTO " + KEYSPACE + "." + table + " (id) VALUES (?)", 0L);
corruptTable(node, KEYSPACE, table);
try {
cluster.coordinator(1).execute("SELECT * FROM " + KEYSPACE + '.' + table + " WHERE id=?", ConsistencyLevel.ONE, 0L);
Assert.fail("Select should fail as we corrupted SSTable on purpose.");
} catch (final Exception ex) {
// we expect that above query fails as we corrupted an sstable
}
waitForStop(!expectGossiperEnabled, node, new SerializableCallable<Boolean>() {
public Boolean call() {
return Gossiper.instance.isEnabled();
}
});
waitForStop(!expectNativeTransportRunning, node, new SerializableCallable<Boolean>() {
public Boolean call() {
return StorageService.instance.isNativeTransportRunning();
}
});
}
}
use of org.apache.cassandra.distributed.api.IInvokableInstance in project cassandra by apache.
the class NetstatsRepairStreamingTest method executeTest.
private void executeTest(boolean compressionEnabled) throws Exception {
final ExecutorService executorService = Executors.newFixedThreadPool(1);
try (final Cluster cluster = Cluster.build().withNodeIdTopology(NetworkTopology.singleDcNetworkTopology(2, "dc0", "rack0")).withConfig(config -> config.with(NETWORK, GOSSIP, NATIVE_PROTOCOL).set("stream_throughput_outbound", "122KiB/s").set("compaction_throughput", "1MiB/s").set("stream_entire_sstables", false)).start()) {
final IInvokableInstance node1 = cluster.get(1);
final IInvokableInstance node2 = cluster.get(2);
createTable(cluster, 1, compressionEnabled);
node1.nodetoolResult("disableautocompaction", "netstats_test").asserts().success();
node2.nodetoolResult("disableautocompaction", "netstats_test").asserts().success();
populateData(compressionEnabled);
node1.flush("netstats_test");
node2.flush("netstats_test");
// change RF from 1 to 2 so we need to repair it, repairing will causes streaming shown in netstats
changeReplicationFactor();
final Future<NetstatResults> resultsFuture1 = executorService.submit(new NetstatsCallable(node1));
node1.nodetoolResult("repair", "netstats_test").asserts().success();
final NetstatResults results = resultsFuture1.get(1, MINUTES);
results.assertSuccessful();
NetstatsOutputParser.validate(NetstatsOutputParser.parse(results));
}
}
use of org.apache.cassandra.distributed.api.IInvokableInstance in project cassandra by apache.
the class IPMembershipTest method sameIPFailWithoutReplace.
/**
* Port of replace_address_test.py::fail_without_replace_test to jvm-dtest
*/
@Test
public void sameIPFailWithoutReplace() throws IOException {
try (Cluster cluster = Cluster.build(3).withConfig(c -> c.with(Feature.GOSSIP, Feature.NATIVE_PROTOCOL).set(Constants.KEY_DTEST_API_STARTUP_FAILURE_AS_SHUTDOWN, false)).start()) {
IInvokableInstance nodeToReplace = cluster.get(3);
ToolRunner.invokeCassandraStress("write", "n=10000", "-schema", "replication(factor=3)", "-port", "native=9042").assertOnExitCode();
for (boolean auto_bootstrap : Arrays.asList(true, false)) {
stopUnchecked(nodeToReplace);
getDirectories(nodeToReplace).forEach(FileUtils::deleteRecursive);
nodeToReplace.config().set("auto_bootstrap", auto_bootstrap);
Assertions.assertThatThrownBy(() -> nodeToReplace.startup()).hasMessage("A node with address /127.0.0.3:7012 already exists, cancelling join. Use cassandra.replace_address if you want to replace this node.");
}
}
}
use of org.apache.cassandra.distributed.api.IInvokableInstance in project cassandra by apache.
the class FailingRepairTest method cleanupState.
@Before
public void cleanupState() {
for (int i = 1; i <= CLUSTER.size(); i++) {
IInvokableInstance inst = CLUSTER.get(i);
if (inst.isShutdown())
inst.startup();
inst.runOnInstance(InstanceKiller::clear);
}
}
use of org.apache.cassandra.distributed.api.IInvokableInstance in project cassandra by apache.
the class IncRepairAdminTest method repairAdminCancelHelper.
private void repairAdminCancelHelper(boolean coordinator, boolean force) throws IOException {
try (Cluster cluster = init(Cluster.build(3).withConfig(config -> config.with(GOSSIP).with(NETWORK)).start())) {
boolean shouldFail = !coordinator && !force;
cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (k INT PRIMARY KEY, v INT)");
cluster.forEach(i -> {
NodeToolResult res = i.nodetoolResult("repair_admin");
res.asserts().stdoutContains("no sessions");
});
UUID uuid = makeFakeSession(cluster);
awaitNodetoolRepairAdminContains(cluster, uuid, "REPAIRING", false);
IInvokableInstance instance = cluster.get(coordinator ? 1 : 2);
NodeToolResult res;
if (force) {
res = instance.nodetoolResult("repair_admin", "cancel", "--session", uuid.toString(), "--force");
} else {
res = instance.nodetoolResult("repair_admin", "cancel", "--session", uuid.toString());
}
if (shouldFail) {
res.asserts().failure();
// if nodetool repair_admin cancel fails, the session should still be repairing:
awaitNodetoolRepairAdminContains(cluster, uuid, "REPAIRING", true);
} else {
res.asserts().success();
awaitNodetoolRepairAdminContains(cluster, uuid, "FAILED", true);
}
}
}
Aggregations