Skip to content

Commit 1492d6c

Browse files
committed
CASSANDRA-19292: Enable Jenkins to test against Cassandra 4.1.x
patch by Bret McGuire; reviewed by Bret McGuire, Alexandre Dutra for CASSANDRA-19292
1 parent 07265b4 commit 1492d6c

File tree

4 files changed

+86
-9
lines changed

4 files changed

+86
-9
lines changed

Jenkinsfile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,10 @@ pipeline {
256256
choices: ['2.1', // Legacy Apache CassandraⓇ
257257
'2.2', // Legacy Apache CassandraⓇ
258258
'3.0', // Previous Apache CassandraⓇ
259-
'3.11', // Current Apache CassandraⓇ
260-
'4.0', // Development Apache CassandraⓇ
259+
'3.11', // Previous Apache CassandraⓇ
260+
'4.0', // Previous Apache CassandraⓇ
261+
'4.1', // Current Apache CassandraⓇ
262+
'5.0', // Development Apache CassandraⓇ
261263
'dse-4.8.16', // Previous EOSL DataStax Enterprise
262264
'dse-5.0.15', // Long Term Support DataStax Enterprise
263265
'dse-5.1.35', // Legacy DataStax Enterprise
@@ -291,7 +293,11 @@ pipeline {
291293
</tr>
292294
<tr>
293295
<td><strong>4.0</strong></td>
294-
<td>Apache Cassandra&reg; v4.x (<b>CURRENTLY UNDER DEVELOPMENT</b>)</td>
296+
<td>Apache Cassandra&reg; v4.0.x</td>
297+
</tr>
298+
<tr>
299+
<td><strong>4.1</strong></td>
300+
<td>Apache Cassandra&reg; v4.1.x</td>
295301
</tr>
296302
<tr>
297303
<td><strong>dse-4.8.16</strong></td>
@@ -445,7 +451,7 @@ pipeline {
445451
axis {
446452
name 'SERVER_VERSION'
447453
values '3.11', // Latest stable Apache CassandraⓇ
448-
'4.0', // Development Apache CassandraⓇ
454+
'4.1', // Development Apache CassandraⓇ
449455
'dse-6.8.30' // Current DataStax Enterprise
450456
}
451457
axis {
@@ -554,8 +560,10 @@ pipeline {
554560
name 'SERVER_VERSION'
555561
values '2.1', // Legacy Apache CassandraⓇ
556562
'3.0', // Previous Apache CassandraⓇ
557-
'3.11', // Current Apache CassandraⓇ
558-
'4.0', // Development Apache CassandraⓇ
563+
'3.11', // Previous Apache CassandraⓇ
564+
'4.0', // Previous Apache CassandraⓇ
565+
'4.1', // Current Apache CassandraⓇ
566+
'5.0', // Development Apache CassandraⓇ
559567
'dse-4.8.16', // Previous EOSL DataStax Enterprise
560568
'dse-5.0.15', // Last EOSL DataStax Enterprise
561569
'dse-5.1.35', // Legacy DataStax Enterprise

core/src/main/java/com/datastax/oss/driver/api/core/Version.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class Version implements Comparable<Version>, Serializable {
5252
@NonNull public static final Version V2_2_0 = Objects.requireNonNull(parse("2.2.0"));
5353
@NonNull public static final Version V3_0_0 = Objects.requireNonNull(parse("3.0.0"));
5454
@NonNull public static final Version V4_0_0 = Objects.requireNonNull(parse("4.0.0"));
55+
@NonNull public static final Version V4_1_0 = Objects.requireNonNull(parse("4.1.0"));
5556
@NonNull public static final Version V5_0_0 = Objects.requireNonNull(parse("5.0.0"));
5657
@NonNull public static final Version V6_7_0 = Objects.requireNonNull(parse("6.7.0"));
5758
@NonNull public static final Version V6_8_0 = Objects.requireNonNull(parse("6.8.0"));

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,19 @@ public void should_get_virtual_metadata() {
265265
+ " total bigint,\n"
266266
+ " unit text,\n"
267267
+ " PRIMARY KEY (keyspace_name, table_name, task_id)\n"
268+
+ "); */",
269+
// Cassandra 4.1
270+
"/* VIRTUAL TABLE system_views.sstable_tasks (\n"
271+
+ " keyspace_name text,\n"
272+
+ " table_name text,\n"
273+
+ " task_id timeuuid,\n"
274+
+ " completion_ratio double,\n"
275+
+ " kind text,\n"
276+
+ " progress bigint,\n"
277+
+ " sstables int,\n"
278+
+ " total bigint,\n"
279+
+ " unit text,\n"
280+
+ " PRIMARY KEY (keyspace_name, table_name, task_id)\n"
268281
+ "); */");
269282
// ColumnMetadata is as expected
270283
ColumnMetadata cm = tm.getColumn("progress").get();

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

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,33 @@ public void create() {
236236
Arrays.stream(nodes).mapToObj(n -> "" + n).collect(Collectors.joining(":")),
237237
createOptions.stream().collect(Collectors.joining(" ")));
238238

239+
Version cassandraVersion = getCassandraVersion();
239240
for (Map.Entry<String, Object> conf : cassandraConfiguration.entrySet()) {
240-
execute("updateconf", String.format("%s:%s", conf.getKey(), conf.getValue()));
241+
String originalKey = conf.getKey();
242+
Object originalValue = conf.getValue();
243+
execute(
244+
"updateconf",
245+
String.join(
246+
":",
247+
getConfigKey(originalKey, originalValue, cassandraVersion),
248+
getConfigValue(originalKey, originalValue, cassandraVersion)));
241249
}
242-
if (getCassandraVersion().compareTo(Version.V2_2_0) >= 0) {
243-
execute("updateconf", "enable_user_defined_functions:true");
250+
251+
// If we're dealing with anything more recent than 2.2 explicitly enable UDF... but run it
252+
// through our conversion process to make
253+
// sure more recent versions don't have a problem.
254+
if (cassandraVersion.compareTo(Version.V2_2_0) >= 0) {
255+
String originalKey = "enable_user_defined_functions";
256+
Object originalValue = "true";
257+
execute(
258+
"updateconf",
259+
String.join(
260+
":",
261+
getConfigKey(originalKey, originalValue, cassandraVersion),
262+
getConfigValue(originalKey, originalValue, cassandraVersion)));
244263
}
264+
265+
// Note that we aren't performing any substitution on DSE key/value props (at least for now)
245266
if (DSE_ENABLEMENT) {
246267
for (Map.Entry<String, Object> conf : dseConfiguration.entrySet()) {
247268
execute("updatedseconf", String.format("%s:%s", conf.getKey(), conf.getValue()));
@@ -463,6 +484,40 @@ private Optional<Integer> overrideJvmVersionForDseWorkloads() {
463484
return Optional.empty();
464485
}
465486

487+
private static String IN_MS_STR = "_in_ms";
488+
private static int IN_MS_STR_LENGTH = IN_MS_STR.length();
489+
private static String ENABLE_STR = "enable_";
490+
private static int ENABLE_STR_LENGTH = ENABLE_STR.length();
491+
private static String IN_KB_STR = "_in_kb";
492+
private static int IN_KB_STR_LENGTH = IN_KB_STR.length();
493+
494+
@SuppressWarnings("unused")
495+
private String getConfigKey(String originalKey, Object originalValue, Version cassandraVersion) {
496+
497+
// At least for now we won't support substitutions on nested keys. This requires an extra
498+
// traversal of the string
499+
// but we'll live with that for now
500+
if (originalKey.contains(".")) return originalKey;
501+
if (cassandraVersion.compareTo(Version.V4_1_0) < 0) return originalKey;
502+
if (originalKey.endsWith(IN_MS_STR))
503+
return originalKey.substring(0, originalKey.length() - IN_MS_STR_LENGTH);
504+
if (originalKey.startsWith(ENABLE_STR))
505+
return originalKey.substring(ENABLE_STR_LENGTH) + "_enabled";
506+
if (originalKey.endsWith(IN_KB_STR))
507+
return originalKey.substring(0, originalKey.length() - IN_KB_STR_LENGTH);
508+
return originalKey;
509+
}
510+
511+
private String getConfigValue(
512+
String originalKey, Object originalValue, Version cassandraVersion) {
513+
514+
String originalValueStr = originalValue.toString();
515+
if (cassandraVersion.compareTo(Version.V4_1_0) < 0) return originalValueStr;
516+
if (originalKey.endsWith(IN_MS_STR)) return originalValueStr + "ms";
517+
if (originalKey.endsWith(IN_KB_STR)) return originalValueStr + "KiB";
518+
return originalValueStr;
519+
}
520+
466521
public static Builder builder() {
467522
return new Builder();
468523
}

0 commit comments

Comments
 (0)