Skip to content

Commit

Permalink
JAVA-3099: fix failing LoadBalancingPolicyBootstrapTest and SchemaCha…
Browse files Browse the repository at this point in the history
…ngesCCTest (#1721)
  • Loading branch information
hhughes authored Aug 24, 2023
1 parent 0ad3014 commit e96d148
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1139,8 +1139,12 @@ private static <T> T instantiate(Class<? extends T> 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)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
Expand Down Expand Up @@ -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<TableMetadata> alteredTable = ArgumentCaptor.forClass(TableMetadata.class);
Expand Down

0 comments on commit e96d148

Please sign in to comment.