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).

Types

Link copied to clipboard

A temporary keyspace: session is bound to it, admin is unbound.

Properties

Link copied to clipboard

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.

Link copied to clipboard

Contact points as a host:port CSV, ready for Kandra's contactPoints config string.

Link copied to clipboard

True when KANDRA_TEST_BACKEND=cloud. Fails fast if the cloud env is not configured.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Shared truststore (cloud + TLS + CA PEM only; null otherwise). Built once per JVM, deleted on JVM exit.

Link copied to clipboard

Auth credentials (never log). Docker's container runs AllowAllAuthenticator, so both are blank there.

Functions

Link copied to clipboard
fun createKeyspace(name: String, rf: Int = 1)

CREATE KEYSPACE IF NOT EXISTS (SimpleStrategy; on the cloud: effectiveRf and tablets disabled).

Link copied to clipboard
fun createKeyspaceCql(name: String, rf: Int = 1): String

CQL used by createKeyspace (for tests that run it on their own session).

Link copied to clipboard
fun dropKeyspace(name: String)
Link copied to clipboard
fun effectiveRf(requested: Int): Int

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.

Link copied to clipboard

Creates a unique keyspace and returns sessions for it; FreshKeyspace.close always drops it.

Link copied to clipboard

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).

Link copied to clipboard
fun newSession(keyspace: String? = null): CqlSession

Opens a session (optionally bound to keyspace). Caller must close it.

Link copied to clipboard
fun sessionBuilder(): CqlSessionBuilder

A configured (unbuilt) session builder with 30s timeouts. Caller owns the built session.