KandraTestBackend
Connection provider for live-cluster tests: one abstraction over the shared Testcontainers Cassandra (KandraTestcontainers) and the env-driven Scylla Cloud cluster (KandraCloud).
Selected by KANDRA_TEST_BACKEND: unset / docker (default, behaviour unchanged) or cloud (requires the KANDRA_CLOUD_* env, see KandraCloud; TLS via KANDRA_CLOUD_TLS=true).
Tests read connection facts from here instead of KandraTestcontainers.container:
install(Kandra) {
contactPoints = KandraTestBackend.contactPointsCsv
localDatacenter = KandraTestBackend.localDatacenter
keyspace = KandraTestBackend.keyspaceName("ktor")
}
KandraTestBackend.newSession().use { it.execute("DROP KEYSPACE IF EXISTS $ks") }All sessions built here use a 30s request timeout (the driver's 2s default is too tight for DDL against a freshly started container under load, and for WAN latency to the cloud cluster).
Properties
Wall-clock budget, in seconds, for tests that race several simulated instances through the LWT/DDL bootstrap paths. 30 s against the Docker container. 180 s against the cloud, where each DDL statement takes 1-5 s (schema agreement over a ~245 ms WAN; measured 2026-10-25 on ScyllaDB Cloud) and simultaneous claims contend in Paxos.
Contact points as a host:port CSV, ready for Kandra's contactPoints config string.
Shared truststore (cloud + TLS + CA PEM only; null otherwise). Built once per JVM, deleted on JVM exit.
Functions
CREATE KEYSPACE IF NOT EXISTS (SimpleStrategy; on the cloud: effectiveRf and tablets disabled).
CQL used by createKeyspace (for tests that run it on their own session).
Replication factor to actually create. The cloud cluster cannot serve an RF=1 keyspace reliably (partitions with no live replica), so RF 1 is bumped to 3 there; tests that assert on replication metadata must use this value rather than assume what they asked for.
Creates a unique keyspace and returns sessions for it; FreshKeyspace.close always drops it.
A unique keyspace name. Docker: kandra_<tag>_<32 hex> (as the tests always used); cloud: the cleanup-friendly kt_<tag>_<8 hex>. Keep tag short (lowercase alphanumeric/underscore).
Opens a session (optionally bound to keyspace). Caller must close it.
A configured (unbuilt) session builder with 30s timeouts. Caller owns the built session.