Skip to content

Commit 1ec720f

Browse files
Apply review comments
1 parent c58cad0 commit 1ec720f

File tree

11 files changed

+52
-44
lines changed

11 files changed

+52
-44
lines changed

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def executeTests() {
157157
-Dmaven.test.failure.ignore=true \
158158
-Dmaven.javadoc.skip=${SKIP_JAVADOCS} \
159159
-Dccm.version=${CCM_CASSANDRA_VERSION} \
160-
-Dccm.${CCM_SERVER_TYPE:cassandra}=true \
160+
-Dccm.distribution=${CCM_SERVER_TYPE:cassandra} \
161161
-Dproxy.path=${HOME}/proxy \
162162
${SERIAL_ITS_ARGUMENT} \
163163
${ISOLATED_ITS_ARGUMENT} \

integration-tests/src/test/java/com/datastax/dse/driver/api/core/cql/continuous/ContinuousPagingIT.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,7 @@ public void prepared_statement_paging_should_be_resilient_to_schema_change() {
281281
// dropped.
282282
Row row = it.next();
283283
assertThat(row.getString("k")).isNotNull();
284-
assertThat(ccmRule.isDistributionOf(BackendType.DSE)).isTrue();
285-
if (ccmRule.getDistributionVersion().compareTo(Objects.requireNonNull(Version.parse("6.0.0")))
286-
>= 0) {
284+
if (ccmRule.isDistributionAtMinimalVersion(BackendType.DSE, Version.parse("6.0.0"))) {
287285
// DSE 6 only, v should be null here since dropped.
288286
// Not reliable for 5.1 since we may have gotten page queued before schema changed.
289287
assertThat(row.isNull("v")).isTrue();

integration-tests/src/test/java/com/datastax/dse/driver/api/core/graph/statement/GraphTraversalITBase.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
import com.datastax.oss.driver.api.core.Version;
3737
import com.datastax.oss.driver.api.core.servererrors.InvalidQueryException;
3838
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
39+
import com.datastax.oss.driver.api.testinfra.ccm.CcmBridge;
3940
import com.datastax.oss.driver.api.testinfra.ccm.CustomCcmRule;
41+
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
4042
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList;
4143
import com.datastax.oss.driver.shaded.guava.common.collect.Lists;
4244
import java.util.List;
@@ -598,7 +600,8 @@ public void should_allow_use_of_dsl_graph_binary() throws Exception {
598600
@Test
599601
public void should_return_correct_results_when_bulked() {
600602
Assumptions.assumeThat(
601-
ccmRule().getCcmBridge().getDistributionVersion().compareTo(Version.parse("5.1.2")) > 0)
603+
CcmBridge.isDistributionOf(BackendType.DSE)
604+
&& CcmBridge.getDistributionVersion().compareTo(Version.parse("5.1.2")) > 0)
602605
.isTrue();
603606

604607
GraphResultSet rs =

integration-tests/src/test/java/com/datastax/oss/driver/core/metadata/SchemaIT.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,8 @@ public void should_exclude_virtual_keyspaces_from_token_map() {
335335

336336
private void skipIfDse60() {
337337
// Special case: DSE 6.0 reports C* 4.0 but does not support virtual tables
338-
if (ccmRule.isDistributionOf(BackendType.DSE)) {
339-
if (ccmRule.getDistributionVersion().compareTo(DSE_MIN_VIRTUAL_TABLES) < 0) {
340-
throw new AssumptionViolatedException("DSE 6.0 does not support virtual tables");
341-
}
338+
if (!ccmRule.isDistributionAtMinimalVersion(BackendType.DSE, DSE_MIN_VIRTUAL_TABLES)) {
339+
throw new AssumptionViolatedException("DSE 6.0 does not support virtual tables");
342340
}
343341
}
344342
}

integration-tests/src/test/java/com/datastax/oss/driver/mapper/InventoryITBase.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ protected static List<String> createStatements(BaseCcmRule ccmRule) {
9494

9595
protected static boolean isSasiBroken(BaseCcmRule ccmRule) {
9696
// creating SASI indexes is broken in DSE 6.8.0
97-
return ccmRule.isDistributionOf(BackendType.DSE)
98-
&& ccmRule.getDistributionVersion().compareTo(BROKEN_SASI_VERSION) == 0;
97+
return ccmRule.isDistributionAtVersion(BackendType.DSE, BROKEN_SASI_VERSION);
9998
}
10099

101100
protected static boolean supportsSASI(BaseCcmRule ccmRule) {

osgi-tests/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ OSGi ones, you can do so as follows:
5252

5353
You can pass the following system properties to your tests:
5454

55-
1. `ccm.version=[version]`: the CCM version to use
56-
2. `ccm.[dse|hcd]=true`: choose target backend type (e.g. DSE, HCD)
57-
3. `osgi.debug=[true|false]`: whether to enable remote debugging of the OSGi container (see
55+
1. `ccm.version`: the CCM version to use
56+
2. `ccm.distribution`: choose target backend type (e.g. DSE, HCD)
57+
3. `osgi.debug`: whether to enable remote debugging of the OSGi container (see
5858
below).
5959

6060
## Debugging OSGi tests

osgi-tests/src/test/java/com/datastax/oss/driver/internal/osgi/support/CcmStagedReactor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class CcmStagedReactor extends AllConfinedStagedReactor {
3939

4040
static {
4141
CcmBridge.Builder builder = CcmBridge.builder().withNodes(1);
42-
if (CcmBridge.isDistributionOf(BackendType.DSE) && CcmBridge.VERSION.compareTo(DSE_5_0) >= 0) {
42+
if (CcmBridge.isDistributionAtMinimalVersion(BackendType.DSE, DSE_5_0)) {
4343
builder.withDseWorkloads("graph");
4444
}
4545
CCM_BRIDGE = builder.build();
@@ -57,7 +57,7 @@ public synchronized void beforeSuite() {
5757
if (!running) {
5858
LOGGER.info(
5959
"Starting CCM, running {} version {}",
60-
CcmBridge.distribution,
60+
CcmBridge.DISTRIBUTION,
6161
CcmBridge.getDistributionVersion());
6262
CCM_BRIDGE.create();
6363
CCM_BRIDGE.start();

test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/BaseCcmRule.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,21 @@ public void evaluate() {
7373
}
7474

7575
public BackendType getDistribution() {
76-
return CcmBridge.distribution;
76+
return CcmBridge.DISTRIBUTION;
7777
}
7878

7979
public boolean isDistributionOf(BackendType type) {
8080
return CcmBridge.isDistributionOf(type);
8181
}
8282

83+
public boolean isDistributionAtVersion(BackendType type, Version version) {
84+
return CcmBridge.isDistributionAtVersion(type, version);
85+
}
86+
87+
public boolean isDistributionAtMinimalVersion(BackendType type, Version version) {
88+
return CcmBridge.isDistributionAtMinimalVersion(type, version);
89+
}
90+
8391
public Version getDistributionVersion() {
8492
return CcmBridge.getDistributionVersion();
8593
}

test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/CcmBridge.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,16 @@ public class CcmBridge implements AutoCloseable {
5555

5656
private static final Logger LOG = LoggerFactory.getLogger(CcmBridge.class);
5757

58+
public static BackendType DISTRIBUTION =
59+
BackendType.valueOf(
60+
System.getProperty("ccm.distribution", BackendType.CASSANDRA.name()).toUpperCase());
5861
public static final Version VERSION =
5962
Objects.requireNonNull(Version.parse(System.getProperty("ccm.version", "4.0.0")));
6063

6164
public static final String INSTALL_DIRECTORY = System.getProperty("ccm.directory");
6265

6366
public static final String BRANCH = System.getProperty("ccm.branch");
6467

65-
public static BackendType distribution = null;
66-
6768
public static final String CLUSTER_NAME = "ccm_1";
6869

6970
public static final String DEFAULT_CLIENT_TRUSTSTORE_PASSWORD = "fakePasswordForTests";
@@ -116,16 +117,7 @@ public class CcmBridge implements AutoCloseable {
116117
public static final Version V4_0_11 = Version.parse("4.0.11");
117118

118119
static {
119-
distribution = BackendType.CASSANDRA; // default distribution
120-
for (BackendType backendType : BackendType.values()) {
121-
String enableFlag = "ccm." + backendType.name().toLowerCase();
122-
// look for system properties like 'ccm.dse', 'ccm.hcd' etc.
123-
if (Boolean.parseBoolean(System.getProperty(enableFlag, "false"))) {
124-
distribution = backendType;
125-
break;
126-
}
127-
}
128-
LOG.info("CCM Bridge configured with {} version {}", distribution.getFriendlyName(), VERSION);
120+
LOG.info("CCM Bridge configured with {} version {}", DISTRIBUTION.getFriendlyName(), VERSION);
129121
}
130122

131123
private final int[] nodes;
@@ -185,7 +177,15 @@ private static boolean isWindows() {
185177
}
186178

187179
public static boolean isDistributionOf(BackendType type) {
188-
return distribution == type;
180+
return DISTRIBUTION == type;
181+
}
182+
183+
public static boolean isDistributionAtVersion(BackendType type, Version version) {
184+
return isDistributionOf(type) && getDistributionVersion().compareTo(version) == 0;
185+
}
186+
187+
public static boolean isDistributionAtMinimalVersion(BackendType type, Version version) {
188+
return isDistributionOf(type) && getDistributionVersion().compareTo(version) >= 0;
189189
}
190190

191191
public static Version getDistributionVersion() {
@@ -196,7 +196,7 @@ public static Version getCassandraVersion() {
196196
if (isDistributionOf(BackendType.CASSANDRA)) {
197197
return VERSION;
198198
}
199-
return DistributionCassandraVersions.getCassandraVersion(distribution, VERSION);
199+
return DistributionCassandraVersions.getCassandraVersion(DISTRIBUTION, VERSION);
200200
}
201201

202202
private String getCcmVersionString(Version version) {
@@ -228,7 +228,7 @@ public void create() {
228228
} else {
229229
createOptions.add("-v " + getCcmVersionString(VERSION));
230230
}
231-
createOptions.addAll(Arrays.asList(distribution.getCcmOptions()));
231+
createOptions.addAll(Arrays.asList(DISTRIBUTION.getCcmOptions()));
232232
execute(
233233
"create",
234234
CLUSTER_NAME,
@@ -341,7 +341,7 @@ public void stop(int n) {
341341
public void add(int n, String dc) {
342342
List<String> addOptions = new ArrayList<>();
343343
addOptions.addAll(Arrays.asList("add", "-i", ipPrefix + n, "-d", dc, "node" + n));
344-
addOptions.addAll(Arrays.asList(distribution.getCcmOptions()));
344+
addOptions.addAll(Arrays.asList(DISTRIBUTION.getCcmOptions()));
345345
execute(addOptions.toArray(new String[0]));
346346
start(n);
347347
}

test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/DistributionCassandraVersions.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,36 @@
1919

2020
import com.datastax.oss.driver.api.core.Version;
2121
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
22+
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableSortedMap;
2223
import java.util.HashMap;
2324
import java.util.Map;
24-
import java.util.TreeMap;
2525

2626
/** Defines mapping of various distributions to shipped Apache Cassandra version. */
2727
public abstract class DistributionCassandraVersions {
28-
private static final Map<BackendType, TreeMap<Version, Version>> mappings = new HashMap<>();
28+
private static final Map<BackendType, ImmutableSortedMap<Version, Version>> mappings =
29+
new HashMap<>();
2930

3031
static {
3132
{
3233
// DSE
33-
TreeMap<Version, Version> dse = new TreeMap<>();
34-
dse.put(Version.V1_0_0, CcmBridge.V2_1_19);
35-
dse.put(Version.V5_0_0, CcmBridge.V3_0_15);
36-
dse.put(CcmBridge.V5_1_0, CcmBridge.V3_10);
37-
dse.put(CcmBridge.V6_0_0, CcmBridge.V4_0_0);
34+
ImmutableSortedMap<Version, Version> dse =
35+
ImmutableSortedMap.of(
36+
Version.V1_0_0, CcmBridge.V2_1_19,
37+
Version.V5_0_0, CcmBridge.V3_0_15,
38+
CcmBridge.V5_1_0, CcmBridge.V3_10,
39+
CcmBridge.V6_0_0, CcmBridge.V4_0_0);
3840
mappings.put(BackendType.DSE, dse);
3941
}
4042
{
4143
// HCD
42-
TreeMap<Version, Version> hcd = new TreeMap<>();
43-
hcd.put(Version.V1_0_0, CcmBridge.V4_0_11);
44+
ImmutableSortedMap<Version, Version> hcd =
45+
ImmutableSortedMap.of(Version.V1_0_0, CcmBridge.V4_0_11);
4446
mappings.put(BackendType.HCD, hcd);
4547
}
4648
}
4749

4850
public static Version getCassandraVersion(BackendType type, Version version) {
49-
TreeMap<Version, Version> mapping = mappings.get(type);
51+
ImmutableSortedMap<Version, Version> mapping = mappings.get(type);
5052
if (mapping == null) {
5153
return null;
5254
}

0 commit comments

Comments
 (0)