Skip to content

Commit 202770e

Browse files
committed
Remove ambiguity in Cassandra and DSE versions
Motivation: Originally CCMBridge was developed targeting running Apache Cassandra clusters using CCM. Over time this has changed to also work with DataStax Enterprise. There are some cases where there was ambiguity with regards to whether the DSE or Cassandra version was used. This attempts to fix this. Also, there were some places where the globally configured Cassandra/DSE version was used (passed in via -Dcassandra.version) instead of a locally configured one for a particular test. This commit also fixes this. In Addition, TestUtils.getDesiredProtocolVersion was made available to determine the ProtocolVersion to use based on the globally configured Cassandra version. This functionality has been moved to CCMAccess, so one can get the ProtocolVersion tied to the version of Cassandra used scoped to the test. Finally, update default cassandra.version used in tests to 3.10. Modifications: Break out CCMAccess.getVersion() into two methods, CCMAccess.getCassandraVersion() and CCMAccess.getDSEVersion(). If DSE is not configured getDSEVersion() returns null, if it is configured getCassandraVersion() returns the mapped version of Cassandra from DSE. Move TestUtils.getDesiredProtocolVersion to CCMAccess. Rename CCMBridge.CASSANDRA_VERSION to CCMBridge.INPUT_CASSANDRA_VERSION. Add CCMBridge.CASSANDRA_VERSION_NUMBER and CCMBridge.DSE_VERSION_NUMBER. Rename CCMBridge.getCassandraVersion() and getDSEVersion() to CCMBridge.getGlobalCassandraVersion() and CCMBridge.getGlobalDSEVersion(). These methods return VersionNumber instead of String. Result: Ambiguity removed between Cassandra and DSE versions. Annotations that call out CCM remain unchanged.
1 parent 32f6abd commit 202770e

27 files changed

Lines changed: 357 additions & 368 deletions

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public void should_parse_and_format_aggregate_with_udts() {
185185
@Test(groups = "short")
186186
@CassandraVersion("2.2.0")
187187
public void should_parse_and_format_aggregate_with_composite_type_literal_initcond() {
188-
VersionNumber ver = VersionNumber.parse(CCMBridge.getCassandraVersion());
188+
VersionNumber ver = ccm().getCassandraVersion();
189189
if (ver.getMajor() == 3) {
190190
if ((ver.getMinor() >= 1 && ver.getMinor() < 4) || (ver.getMinor() == 0 && ver.getPatch() < 4)) {
191191
throw new SkipException("Requires C* 2.2.X, 3.0.4+ or 3.4.X+");
@@ -206,7 +206,7 @@ public void should_parse_and_format_aggregate_with_composite_type_literal_initco
206206
@Test(groups = "short")
207207
@CassandraVersion("3.4")
208208
public void should_parse_and_format_aggregate_with_composite_type_hex_initcond() {
209-
VersionNumber ver = VersionNumber.parse(CCMBridge.getCassandraVersion());
209+
VersionNumber ver = ccm().getCassandraVersion();
210210
if ((ver.getMinor() >= 1 && ver.getMinor() < 4)) {
211211
throw new SkipException("Requires 3.0.4+ or 3.4.X+");
212212
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class AuthenticationTest extends CCMTestsSupport {
4141
public void sleepIf12() {
4242
// For C* 1.2, sleep before attempting to connect as there is a small delay between
4343
// user being created.
44-
if (ccm().getVersion().getMajor() < 2) {
44+
if (ccm().getCassandraVersion().getMajor() < 2) {
4545
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
4646
}
4747
}

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,21 @@ enum Workload {cassandra, solr, hadoop, spark, cfs, graph}
3232
String getClusterName();
3333

3434
/**
35-
* Returns the Cassandra version of this CCM cluster.
35+
* Returns the Cassandra version of this CCM cluster. If {@link #getDSEVersion()} is non-null it is assumed
36+
* that this value is only used for representing the compatible Cassandra version for that DSE version.
3637
* <p/>
37-
* By default the version is equal to {@link CCMBridge#getCassandraVersion()}.
3838
*
3939
* @return The version of this CCM cluster.
4040
*/
41-
VersionNumber getVersion();
41+
VersionNumber getCassandraVersion();
42+
43+
/**
44+
* Returns the DSE version of this CCM cluster if this is a DSE cluster, otherwise null.
45+
* <p/>
46+
*
47+
* @return The version of this CCM cluster.
48+
*/
49+
VersionNumber getDSEVersion();
4250

4351
/**
4452
* @return The config directory for this CCM cluster.
@@ -236,4 +244,19 @@ enum Workload {cassandra, solr, hadoop, spark, cfs, graph}
236244
*/
237245
void waitForDown(int node);
238246

247+
/**
248+
* @return The target protocolVersion to use when connecting to this CCM cluster.
249+
* <p/>
250+
* This should be based on the highest protocol version that both the cluster and driver support.
251+
* <p/>
252+
* For example, C* 2.0.17 should return {@link ProtocolVersion#V2} since C* supports up to V2 and the driver
253+
* supports that version.
254+
*/
255+
ProtocolVersion getProtocolVersion();
256+
257+
/**
258+
* @param maximumAllowed The maximum protocol version to use.
259+
* @return The target protocolVersion or maximumAllowed if {@link #getProtocolVersion} is greater.
260+
*/
261+
ProtocolVersion getProtocolVersion(ProtocolVersion maximumAllowed);
239262
}

0 commit comments

Comments
 (0)