Search in sources :

Example 1 with BOOTSTRAP_SCHEMA_DELAY_MS

use of org.apache.cassandra.config.CassandraRelevantProperties.BOOTSTRAP_SCHEMA_DELAY_MS in project cassandra by apache.

the class BaseAssassinatedCase method test.

@Test
public void test() throws IOException {
    TokenSupplier even = TokenSupplier.evenlyDistributedTokens(3);
    try (Cluster cluster = Cluster.build(3).withConfig(c -> c.with(Feature.GOSSIP, Feature.NETWORK)).withTokenSupplier(node -> even.token(node == 4 || node == 5 ? NODE_TO_REMOVE_NUM : node)).start()) {
        IInvokableInstance seed = cluster.get(SEED_NUM);
        IInvokableInstance nodeToRemove = cluster.get(NODE_TO_REMOVE_NUM);
        IInvokableInstance peer = cluster.get(PEER_NUM);
        setupCluster(cluster);
        consume(cluster, nodeToRemove);
        assertRingState(seed, nodeToRemove, "Normal");
        // assassinate the node
        peer.nodetoolResult("assassinate", getBroadcastAddressHostWithPortString(nodeToRemove)).asserts().success();
        // wait until the peer sees this assassination
        awaitGossipStatus(seed, nodeToRemove, "LEFT");
        // Any extra checks to run after the node has been as LEFT
        afterNodeStatusIsLeft(cluster, nodeToRemove);
        // allow replacing nodes with the LEFT state, this should fail since the token isn't in the ring
        assertThatThrownBy(() -> replaceHostAndStart(cluster, nodeToRemove, properties -> {
            // since there are downed nodes its possible gossip has the downed node with an old schema, so need
            // this property to allow startup
            properties.set(BOOTSTRAP_SKIP_SCHEMA_CHECK, true);
            // since the bootstrap should fail because the token, don't wait "too long" on schema as it doesn't
            // matter for this test
            properties.set(BOOTSTRAP_SCHEMA_DELAY_MS, 10);
        })).hasMessage(expectedMessage(nodeToRemove));
    }
}
Also used : ClusterUtils.awaitGossipStatus(org.apache.cassandra.distributed.shared.ClusterUtils.awaitGossipStatus) ClusterUtils.getTokens(org.apache.cassandra.distributed.shared.ClusterUtils.getTokens) Feature(org.apache.cassandra.distributed.api.Feature) HostReplacementTest.setupCluster(org.apache.cassandra.distributed.test.hostreplacement.HostReplacementTest.setupCluster) IOException(java.io.IOException) Test(org.junit.Test) BOOTSTRAP_SKIP_SCHEMA_CHECK(org.apache.cassandra.config.CassandraRelevantProperties.BOOTSTRAP_SKIP_SCHEMA_CHECK) TokenSupplier(org.apache.cassandra.distributed.api.TokenSupplier) ClusterUtils.replaceHostAndStart(org.apache.cassandra.distributed.shared.ClusterUtils.replaceHostAndStart) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) IInvokableInstance(org.apache.cassandra.distributed.api.IInvokableInstance) ClusterUtils.getBroadcastAddressHostWithPortString(org.apache.cassandra.distributed.shared.ClusterUtils.getBroadcastAddressHostWithPortString) TestBaseImpl(org.apache.cassandra.distributed.test.TestBaseImpl) Cluster(org.apache.cassandra.distributed.Cluster) ClusterUtils.assertRingState(org.apache.cassandra.distributed.shared.ClusterUtils.assertRingState) BOOTSTRAP_SCHEMA_DELAY_MS(org.apache.cassandra.config.CassandraRelevantProperties.BOOTSTRAP_SCHEMA_DELAY_MS) IInvokableInstance(org.apache.cassandra.distributed.api.IInvokableInstance) TokenSupplier(org.apache.cassandra.distributed.api.TokenSupplier) HostReplacementTest.setupCluster(org.apache.cassandra.distributed.test.hostreplacement.HostReplacementTest.setupCluster) Cluster(org.apache.cassandra.distributed.Cluster) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 BOOTSTRAP_SCHEMA_DELAY_MS (org.apache.cassandra.config.CassandraRelevantProperties.BOOTSTRAP_SCHEMA_DELAY_MS)1 BOOTSTRAP_SKIP_SCHEMA_CHECK (org.apache.cassandra.config.CassandraRelevantProperties.BOOTSTRAP_SKIP_SCHEMA_CHECK)1 Cluster (org.apache.cassandra.distributed.Cluster)1 Feature (org.apache.cassandra.distributed.api.Feature)1 IInvokableInstance (org.apache.cassandra.distributed.api.IInvokableInstance)1 TokenSupplier (org.apache.cassandra.distributed.api.TokenSupplier)1 ClusterUtils.assertRingState (org.apache.cassandra.distributed.shared.ClusterUtils.assertRingState)1 ClusterUtils.awaitGossipStatus (org.apache.cassandra.distributed.shared.ClusterUtils.awaitGossipStatus)1 ClusterUtils.getBroadcastAddressHostWithPortString (org.apache.cassandra.distributed.shared.ClusterUtils.getBroadcastAddressHostWithPortString)1 ClusterUtils.getTokens (org.apache.cassandra.distributed.shared.ClusterUtils.getTokens)1 ClusterUtils.replaceHostAndStart (org.apache.cassandra.distributed.shared.ClusterUtils.replaceHostAndStart)1 TestBaseImpl (org.apache.cassandra.distributed.test.TestBaseImpl)1 HostReplacementTest.setupCluster (org.apache.cassandra.distributed.test.hostreplacement.HostReplacementTest.setupCluster)1 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)1 Test (org.junit.Test)1