Skip to content

Commit e96d148

Browse files
authored
JAVA-3099: fix failing LoadBalancingPolicyBootstrapTest and SchemaChangesCCTest (#1721)
1 parent 0ad3014 commit e96d148

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,8 +1139,12 @@ private static <T> T instantiate(Class<? extends T> clazz)
11391139
}
11401140
}
11411141

1142+
protected boolean isCassandraVersionOrHigher(String version) {
1143+
return CCMBridge.getGlobalCassandraVersion().compareTo(VersionNumber.parse(version)) >= 0;
1144+
}
1145+
11421146
protected void skipTestWithCassandraVersionOrHigher(String version, String testKind) {
1143-
if (CCMBridge.getGlobalCassandraVersion().compareTo(VersionNumber.parse(version)) >= 0) {
1147+
if (isCassandraVersionOrHigher(version)) {
11441148
throw new SkipException(
11451149
String.format(
11461150
"%s tests not applicable to cassandra version >= %s (configured: %s)",

driver-core/src/test/java/com/datastax/driver/core/LoadBalancingPolicyBootstrapTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,16 @@ public void should_send_down_notifications_after_init_when_contact_points_are_do
9999
ccm().stop(nodeToStop);
100100
ccm().waitForDown(nodeToStop);
101101

102+
// usually only one contact point is used to build the test cluster
103+
// here we explicitly add both endpoints so we can test load
104+
// balancing initial connection when the first connection point is down
102105
HistoryPolicy policy = new HistoryPolicy(new RoundRobinPolicy());
103-
Cluster cluster = register(createClusterBuilder().withLoadBalancingPolicy(policy).build());
106+
Cluster cluster =
107+
register(
108+
createClusterBuilder()
109+
.addContactPoints(ccm().getContactPoints().get(1))
110+
.withLoadBalancingPolicy(policy)
111+
.build());
104112

105113
try {
106114
cluster.init();

driver-core/src/test/java/com/datastax/driver/core/SchemaChangesCCTest.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ public void should_receive_changes_made_while_control_connection_is_down_on_reco
9898
// Perform some schema changes that we'll validate when the control connection comes back.
9999
session2.execute("drop keyspace ks2");
100100
session2.execute("drop table ks1.tbl2");
101-
session2.execute("alter keyspace ks1 with durable_writes=false");
101+
102+
// Modifying keyspaces with a node down is not possible in 4.0+ (CASSANDRA-14404)
103+
if (!isCassandraVersionOrHigher("4.0.0")) {
104+
session2.execute("alter keyspace ks1 with durable_writes=false");
105+
}
106+
102107
session2.execute("alter table ks1.tbl1 add new_col varchar");
103108
session2.execute(String.format(CREATE_KEYSPACE_SIMPLE_FORMAT, "ks3", 1));
104109
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
152157
.isDurableWrites()
153158
.isEqualTo(prealteredKeyspace);
154159

155-
// New metadata should reflect that the durable writes attribute changed.
156-
assertThat(alteredKeyspace.getValue()).hasName("ks1").isNotDurableWrites();
160+
// Modifying keyspaces with a node down is not possible in 4.0+ (CASSANDRA-14404)
161+
if (!isCassandraVersionOrHigher("4.0.0")) {
162+
// New metadata should reflect that the durable writes attribute changed.
163+
assertThat(alteredKeyspace.getValue()).hasName("ks1").isNotDurableWrites();
164+
}
157165

158166
// Ensure the alter table event shows up.
159167
ArgumentCaptor<TableMetadata> alteredTable = ArgumentCaptor.forClass(TableMetadata.class);

0 commit comments

Comments
 (0)