Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.x: Expose scyllaVersion in additional classes, interfaces #419

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ enum Workload {
*/
VersionNumber getDSEVersion();

/**
* Returns the Scylla version of this CCM cluster if this is a Scylla cluster, otherwise null.
*
* @return The version of this CCM cluster.
*/
VersionNumber getScyllaVersion();

/** @return The config directory for this CCM cluster. */
File getCcmDir();

Expand Down
31 changes: 29 additions & 2 deletions driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ private static VersionNumber parseScyllaInputVersion(String versionString) {

private final VersionNumber dseVersion;

private final VersionNumber scyllaVersion;

private final int storagePort;

private final int thriftPort;
Expand Down Expand Up @@ -402,6 +404,7 @@ protected CCMBridge(
String clusterName,
VersionNumber cassandraVersion,
VersionNumber dseVersion,
VersionNumber scyllaVersion,
String ipPrefix,
int storagePort,
int thriftPort,
Expand All @@ -415,6 +418,7 @@ protected CCMBridge(
this.clusterName = clusterName;
this.cassandraVersion = cassandraVersion;
this.dseVersion = dseVersion;
this.scyllaVersion = scyllaVersion;
this.ipPrefix = ipPrefix;
this.storagePort = storagePort;
this.thriftPort = thriftPort;
Expand Down Expand Up @@ -489,6 +493,11 @@ public VersionNumber getDSEVersion() {
return dseVersion;
}

@Override
public VersionNumber getScyllaVersion() {
return scyllaVersion;
}

@Override
public File getCcmDir() {
return ccmDir;
Expand Down Expand Up @@ -1000,6 +1009,7 @@ public static class Builder {
private int[] jmxPorts = {};
private boolean start = true;
private boolean dse = isDse();
private boolean scylla = GLOBAL_SCYLLA_VERSION_NUMBER != null;
private boolean startSniProxy = false;
private VersionNumber version = null;
private final Set<String> createOptions = new LinkedHashSet<String>();
Expand Down Expand Up @@ -1091,8 +1101,8 @@ public Builder notStarted() {
}

/**
* The Cassandra or DSE version to use. If not specified the globally configured version is used
* instead.
* The Cassandra or DSE or Scylla version to use. If not specified the globally configured
* version is used instead.
*/
public Builder withVersion(VersionNumber version) {
this.version = version;
Expand All @@ -1105,6 +1115,12 @@ public Builder withDSE(boolean dse) {
return this;
}

/** Indicates whether or not this cluster is meant to be a Scylla cluster. */
public Builder withScylla(boolean scylla) {
this.scylla = scylla;
return this;
}

/**
* Free-form options that will be added at the end of the {@code ccm create} command (defaults
* to {@link #CASSANDRA_INSTALL_ARGS} if this is never called).
Expand Down Expand Up @@ -1175,17 +1191,26 @@ public CCMBridge build() {

VersionNumber dseVersion;
VersionNumber cassandraVersion;
VersionNumber scyllaVersion;
boolean versionConfigured = this.version != null;
// No version was explicitly provided, fallback on global config.
if (!versionConfigured) {
scyllaVersion = GLOBAL_SCYLLA_VERSION_NUMBER;
dseVersion = GLOBAL_DSE_VERSION_NUMBER;
cassandraVersion = GLOBAL_CASSANDRA_VERSION_NUMBER;
} else if (dse) {
// given version is the DSE version, base cassandra version on DSE version.
scyllaVersion = null;
dseVersion = this.version;
cassandraVersion = getCassandraVersion(dseVersion);
} else if (scylla) {
scyllaVersion = this.version;
dseVersion = null;
// Versions from 5.1 to 6.2.0 seem to report release_version 3.0.8 in system_local
cassandraVersion = VersionNumber.parse("3.0.8");
} else {
// given version is cassandra version.
scyllaVersion = null;
dseVersion = null;
cassandraVersion = this.version;
}
Expand Down Expand Up @@ -1240,6 +1265,7 @@ public CCMBridge build() {
clusterName,
cassandraVersion,
dseVersion,
scyllaVersion,
ipPrefix,
storagePort,
thriftPort,
Expand Down Expand Up @@ -1449,6 +1475,7 @@ public boolean equals(Object o) {

if (ipPrefix != builder.ipPrefix) return false;
if (dse != builder.dse) return false;
if (scylla != builder.scylla) return false;
if (!Arrays.equals(nodes, builder.nodes)) return false;
if (version != null ? !version.equals(builder.version) : builder.version != null)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public VersionNumber getDSEVersion() {
return ccm.getDSEVersion();
}

@Override
public VersionNumber getScyllaVersion() {
return ccm.getScyllaVersion();
}

@Override
public File getCcmDir() {
return ccm.getCcmDir();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ public VersionNumber getDSEVersion() {
return delegate.getDSEVersion();
}

@Override
public VersionNumber getScyllaVersion() {
return delegate.getScyllaVersion();
}

@Override
public InetSocketAddress addressOfNode(int n) {
return delegate.addressOfNode(n);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ public void should_receive_events_when_node_states_change() throws InterruptedEx
ccm().start(1);
listener.waitForEvent();

listener.setExpectedEvent(REMOVE);
// Different expectation for Scylla versions since 6.0.0 and 2024.2, both included
VersionNumber scyllaVer = ccm().getScyllaVersion();
if (scyllaVer != null
&& ((scyllaVer.getMajor() >= 6 && scyllaVer.getMajor() <= 9)
|| (scyllaVer.getMajor() >= 2024 && scyllaVer.getMinor() >= 2))) {
listener.setExpectedEvent(DOWN);
} else {
listener.setExpectedEvent(REMOVE);
}
ccm().decommission(2);
listener.waitForEvent();
}
Expand Down