Skip to content

Commit 4da0ccb

Browse files
authored
Switch tests to Cassandra 4.0 by default (#1566)
* Switch CCM to Cassandra 4.0 by default * Add a few startup tweaks for C* 3+ and 4+
1 parent 0606b49 commit 4da0ccb

File tree

5 files changed

+58
-36
lines changed

5 files changed

+58
-36
lines changed

integration-tests/src/test/java/com/datastax/oss/driver/core/cql/PreparedStatementIT.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ public void should_fail_to_reprepare_if_query_becomes_invalid() {
279279
Throwable t = catchThrowable(() -> session.execute(ps.bind()));
280280

281281
// Then
282-
assertThat(t).isInstanceOf(InvalidQueryException.class).hasMessage("Undefined column name d");
282+
assertThat(t)
283+
.isInstanceOf(InvalidQueryException.class)
284+
.hasMessageContaining("Undefined column name d");
283285
}
284286

285287
@Test

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ public void should_get_virtual_metadata() {
226226
assertThat(tm).isNotNull();
227227
assertThat(tm.getName().toString()).isEqualTo("sstable_tasks");
228228
assertThat(tm.isVirtual()).isTrue();
229-
assertThat(tm.getColumns().size()).isEqualTo(7);
229+
// DSE 6.8+ reports 7 columns, Cassandra 4+ reports 8 columns
230+
assertThat(tm.getColumns().size()).isGreaterThanOrEqualTo(7);
230231
assertThat(tm.getIndexes().size()).isEqualTo(0);
231232
assertThat(tm.getPartitionKey().size()).isEqualTo(1);
232233
assertThat(tm.getPartitionKey().get(0).getName().toString()).isEqualTo("keyspace_name");
@@ -235,11 +236,24 @@ public void should_get_virtual_metadata() {
235236
assertThat(tm.getOptions().size()).isEqualTo(0);
236237
assertThat(tm.getKeyspace()).isEqualTo(kmd.getName());
237238
assertThat(tm.describe(true))
238-
.isEqualTo(
239+
.isIn(
240+
// DSE 6.8+
241+
"/* VIRTUAL TABLE system_views.sstable_tasks (\n"
242+
+ " keyspace_name text,\n"
243+
+ " table_name text,\n"
244+
+ " task_id uuid,\n"
245+
+ " kind text,\n"
246+
+ " progress bigint,\n"
247+
+ " total bigint,\n"
248+
+ " unit text,\n"
249+
+ " PRIMARY KEY (keyspace_name, table_name, task_id)\n"
250+
+ "); */",
251+
// Cassandra 4.0
239252
"/* VIRTUAL TABLE system_views.sstable_tasks (\n"
240253
+ " keyspace_name text,\n"
241254
+ " table_name text,\n"
242255
+ " task_id uuid,\n"
256+
+ " completion_ratio double,\n"
243257
+ " kind text,\n"
244258
+ " progress bigint,\n"
245259
+ " total bigint,\n"

integration-tests/src/test/resources/logback-test.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<logger name="com.datastax.oss.driver" level="${ossDriverLevel:-ERROR}"/>
3030
<logger name="com.datastax.dse.driver" level="${dseDriverLevel:-ERROR}"/>
3131
<logger name="com.datastax.oss.simulacron" level="${simulacronLevel:-ERROR}"/>
32-
<logger name="com.datastax.oss.driver.api.testinfra.ccm" level="${ccmLevel:-ERROR}"/>
32+
<logger name="com.datastax.oss.driver.api.testinfra.ccm" level="${ccmLevel:-INFO}"/>
3333
<!-- Set this logger to DEBUG to help debugging OSGi tests -->
3434
<logger name="org.ops4j" level="${osgiLevel:-ERROR}"/>
3535
</configuration>

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

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,10 @@
4949

5050
public class CcmBridge implements AutoCloseable {
5151

52-
private static final Logger logger = LoggerFactory.getLogger(CcmBridge.class);
53-
54-
private final int[] nodes;
55-
56-
private final Path configDirectory;
57-
58-
private final AtomicBoolean started = new AtomicBoolean();
59-
60-
private final AtomicBoolean created = new AtomicBoolean();
61-
62-
private final String ipPrefix;
63-
64-
private final Map<String, Object> cassandraConfiguration;
65-
private final Map<String, Object> dseConfiguration;
66-
private final List<String> rawDseYaml;
67-
private final List<String> createOptions;
68-
private final List<String> dseWorkloads;
69-
70-
private final String jvmArgs;
52+
private static final Logger LOG = LoggerFactory.getLogger(CcmBridge.class);
7153

7254
public static final Version VERSION =
73-
Objects.requireNonNull(Version.parse(System.getProperty("ccm.version", "3.11.0")));
55+
Objects.requireNonNull(Version.parse(System.getProperty("ccm.version", "4.0.0")));
7456

7557
public static final String INSTALL_DIRECTORY = System.getProperty("ccm.directory");
7658

@@ -126,6 +108,26 @@ public class CcmBridge implements AutoCloseable {
126108
private static final Version V3_0_15 = Version.parse("3.0.15");
127109
private static final Version V2_1_19 = Version.parse("2.1.19");
128110

111+
static {
112+
if (DSE_ENABLEMENT) {
113+
LOG.info("CCM Bridge configured with DSE version {}", VERSION);
114+
} else {
115+
LOG.info("CCM Bridge configured with Apache Cassandra version {}", VERSION);
116+
}
117+
}
118+
119+
private final int[] nodes;
120+
private final Path configDirectory;
121+
private final AtomicBoolean started = new AtomicBoolean();
122+
private final AtomicBoolean created = new AtomicBoolean();
123+
private final String ipPrefix;
124+
private final Map<String, Object> cassandraConfiguration;
125+
private final Map<String, Object> dseConfiguration;
126+
private final List<String> rawDseYaml;
127+
private final List<String> createOptions;
128+
private final List<String> dseWorkloads;
129+
private final String jvmArgs;
130+
129131
private CcmBridge(
130132
Path configDirectory,
131133
int[] nodes,
@@ -141,10 +143,7 @@ private CcmBridge(
141143
// Hack to ensure that the default DC is always called 'dc1': pass a list ('-nX:0') even if
142144
// there is only one DC (with '-nX', CCM configures `SimpleSnitch`, which hard-codes the name
143145
// to 'datacenter1')
144-
int[] tmp = new int[2];
145-
tmp[0] = nodes[0];
146-
tmp[1] = 0;
147-
this.nodes = tmp;
146+
this.nodes = new int[] {nodes[0], 0};
148147
} else {
149148
this.nodes = nodes;
150149
}
@@ -351,27 +350,27 @@ private void executeCheckLogError() {
351350

352351
private void execute(CommandLine cli, boolean forceErrorLogging) {
353352
if (forceErrorLogging) {
354-
logger.error("Executing: " + cli);
353+
LOG.error("Executing: " + cli);
355354
} else {
356-
logger.debug("Executing: " + cli);
355+
LOG.debug("Executing: " + cli);
357356
}
358357
ExecuteWatchdog watchDog = new ExecuteWatchdog(TimeUnit.MINUTES.toMillis(10));
359358
try (LogOutputStream outStream =
360359
new LogOutputStream() {
361360
@Override
362361
protected void processLine(String line, int logLevel) {
363362
if (forceErrorLogging) {
364-
logger.error("ccmout> {}", line);
363+
LOG.error("ccmout> {}", line);
365364
} else {
366-
logger.debug("ccmout> {}", line);
365+
LOG.debug("ccmout> {}", line);
367366
}
368367
}
369368
};
370369
LogOutputStream errStream =
371370
new LogOutputStream() {
372371
@Override
373372
protected void processLine(String line, int logLevel) {
374-
logger.error("ccmerr> {}", line);
373+
LOG.error("ccmerr> {}", line);
375374
}
376375
}) {
377376
Executor executor = new DefaultExecutor();
@@ -381,8 +380,7 @@ protected void processLine(String line, int logLevel) {
381380

382381
int retValue = executor.execute(cli);
383382
if (retValue != 0) {
384-
logger.error(
385-
"Non-zero exit code ({}) returned from executing ccm command: {}", retValue, cli);
383+
LOG.error("Non-zero exit code ({}) returned from executing ccm command: {}", retValue, cli);
386384
}
387385
} catch (IOException ex) {
388386
if (watchDog.killedProcess()) {
@@ -413,7 +411,7 @@ private static File createTempStore(String storePath) {
413411
f.deleteOnExit();
414412
Resources.copy(CcmBridge.class.getResource(storePath), os);
415413
} catch (IOException e) {
416-
logger.warn("Failure to write keystore, SSL-enabled servers may fail to start.", e);
414+
LOG.warn("Failure to write keystore, SSL-enabled servers may fail to start.", e);
417415
}
418416
return f;
419417
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import com.datastax.oss.driver.api.core.Version;
1919

20+
/** @see CcmRule */
21+
@SuppressWarnings("unused")
2022
public class DefaultCcmBridgeBuilderCustomizer {
2123

2224
public static CcmBridge.Builder configureBuilder(CcmBridge.Builder builder) {
@@ -25,6 +27,12 @@ public static CcmBridge.Builder configureBuilder(CcmBridge.Builder builder) {
2527
builder.withCassandraConfiguration("enable_materialized_views", true);
2628
builder.withCassandraConfiguration("enable_sasi_indexes", true);
2729
}
30+
if (CcmBridge.VERSION.nextStable().compareTo(Version.V3_0_0) >= 0) {
31+
builder.withJvmArgs("-Dcassandra.superuser_setup_delay_ms=0");
32+
builder.withJvmArgs("-Dcassandra.skip_wait_for_gossip_to_settle=0");
33+
builder.withCassandraConfiguration("num_tokens", "1");
34+
builder.withCassandraConfiguration("initial_token", "0");
35+
}
2836
return builder;
2937
}
3038
}

0 commit comments

Comments
 (0)