diff --git a/driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java b/driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java index ca9f5e45d6f..02345c42cc8 100644 --- a/driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java +++ b/driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java @@ -1139,8 +1139,12 @@ private static T instantiate(Class clazz) } } + protected boolean isCassandraVersionOrHigher(String version) { + return CCMBridge.getGlobalCassandraVersion().compareTo(VersionNumber.parse(version)) >= 0; + } + protected void skipTestWithCassandraVersionOrHigher(String version, String testKind) { - if (CCMBridge.getGlobalCassandraVersion().compareTo(VersionNumber.parse(version)) >= 0) { + if (isCassandraVersionOrHigher(version)) { throw new SkipException( String.format( "%s tests not applicable to cassandra version >= %s (configured: %s)", diff --git a/driver-core/src/test/java/com/datastax/driver/core/LoadBalancingPolicyBootstrapTest.java b/driver-core/src/test/java/com/datastax/driver/core/LoadBalancingPolicyBootstrapTest.java index 5069d33c569..efe0f6f16dc 100644 --- a/driver-core/src/test/java/com/datastax/driver/core/LoadBalancingPolicyBootstrapTest.java +++ b/driver-core/src/test/java/com/datastax/driver/core/LoadBalancingPolicyBootstrapTest.java @@ -99,8 +99,16 @@ public void should_send_down_notifications_after_init_when_contact_points_are_do ccm().stop(nodeToStop); ccm().waitForDown(nodeToStop); + // usually only one contact point is used to build the test cluster + // here we explicitly add both endpoints so we can test load + // balancing initial connection when the first connection point is down HistoryPolicy policy = new HistoryPolicy(new RoundRobinPolicy()); - Cluster cluster = register(createClusterBuilder().withLoadBalancingPolicy(policy).build()); + Cluster cluster = + register( + createClusterBuilder() + .addContactPoints(ccm().getContactPoints().get(1)) + .withLoadBalancingPolicy(policy) + .build()); try { cluster.init(); diff --git a/driver-core/src/test/java/com/datastax/driver/core/SchemaChangesCCTest.java b/driver-core/src/test/java/com/datastax/driver/core/SchemaChangesCCTest.java index 2340b45678b..0538cf87e07 100644 --- a/driver-core/src/test/java/com/datastax/driver/core/SchemaChangesCCTest.java +++ b/driver-core/src/test/java/com/datastax/driver/core/SchemaChangesCCTest.java @@ -98,7 +98,12 @@ public void should_receive_changes_made_while_control_connection_is_down_on_reco // Perform some schema changes that we'll validate when the control connection comes back. session2.execute("drop keyspace ks2"); session2.execute("drop table ks1.tbl2"); - session2.execute("alter keyspace ks1 with durable_writes=false"); + + // Modifying keyspaces with a node down is not possible in 4.0+ (CASSANDRA-14404) + if (!isCassandraVersionOrHigher("4.0.0")) { + session2.execute("alter keyspace ks1 with durable_writes=false"); + } + session2.execute("alter table ks1.tbl1 add new_col varchar"); session2.execute(String.format(CREATE_KEYSPACE_SIMPLE_FORMAT, "ks3", 1)); session2.execute("create table ks1.tbl3 (k text primary key, v text)"); @@ -152,8 +157,11 @@ public void should_receive_changes_made_while_control_connection_is_down_on_reco .isDurableWrites() .isEqualTo(prealteredKeyspace); - // New metadata should reflect that the durable writes attribute changed. - assertThat(alteredKeyspace.getValue()).hasName("ks1").isNotDurableWrites(); + // Modifying keyspaces with a node down is not possible in 4.0+ (CASSANDRA-14404) + if (!isCassandraVersionOrHigher("4.0.0")) { + // New metadata should reflect that the durable writes attribute changed. + assertThat(alteredKeyspace.getValue()).hasName("ks1").isNotDurableWrites(); + } // Ensure the alter table event shows up. ArgumentCaptor alteredTable = ArgumentCaptor.forClass(TableMetadata.class);