Skip to content

Commit 1998141

Browse files
committed
scylla/3.11.x: fix ShardAwarenessTest for Scylla 2025.1
Two Scylla 2025.1 changes break correctShardInTracingTest: 1. Tablets enabled by default for NTS keyspaces make the driver's hash-based getShardId() prediction non-deterministic, so the hardcoded expected shards ("shard 0" / "shard 1") become unreliable. Fix: ADD TABLETS = {'enabled': false} to the CREATE KEYSPACE statement to restore traditional token-based shard assignment. 2. A new coordinator-side trace event runs on shard 0 regardless of the data shard, causing the previous per-event assertion to fail. Fix: only assert the shard for events whose description contains "querying locally" (the data-local event). Also: - Thread names now include a /sl:<service_level> suffix (e.g. "shard 0/sl:default"). Strip it before the startsWith() comparison. - assertThat(anyLocal) was a no-op BooleanAssert (never called .isTrue()). Replace with assertTrue(anyLocal) so the liveness guard actually fires.
1 parent 5f4f988 commit 1998141

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

driver-core/src/test/java/com/datastax/driver/core/ShardAwarenessTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,25 @@ private void verifyCorrectShardSingleRow(String pk, String ck, String v, String
8282
event.getSource(),
8383
event.getThreadName(),
8484
event.getDescription());
85-
assertThat(event.getThreadName()).startsWith(shard);
85+
// Only data-local events carry the owning shard. Scylla 2025.1 adds coordinator-side
86+
// events that legitimately run on shard 0 regardless of the data shard. Also, since
87+
// Scylla 2025.1 the thread name carries a service-level suffix ("shard N/sl:<level>"),
88+
// so strip it before comparing.
8689
if (event.getDescription().contains("querying locally")) {
8790
anyLocal = true;
91+
String normalized = event.getThreadName().replaceFirst("/sl:[^/]*$", "");
92+
assertThat(normalized).startsWith(shard);
8893
}
8994
}
90-
assertThat(anyLocal);
95+
assertTrue("No 'querying locally' trace event was observed for the query", anyLocal);
9196
}
9297

9398
@Test(groups = "short")
9499
public void correctShardInTracingTest() {
95100
session().execute("DROP KEYSPACE IF EXISTS shardawaretest");
96101
session()
97102
.execute(
98-
"CREATE KEYSPACE shardawaretest WITH replication = {'class': 'NetworkTopologyStrategy', 'datacenter1': '3'}");
103+
"CREATE KEYSPACE shardawaretest WITH replication = {'class': 'NetworkTopologyStrategy', 'datacenter1': '3'} AND TABLETS = {'enabled': false}");
99104
session()
100105
.execute("CREATE TABLE shardawaretest.t (pk text, ck text, v text, PRIMARY KEY (pk, ck))");
101106

0 commit comments

Comments
 (0)