Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 30 additions & 16 deletions driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ protected CCMBridge(
this.thriftPort = thriftPort;
this.binaryPort = binaryPort;
this.isDSE = dseVersion != null;
this.isScylla = (getGlobalScyllaVersion() != null);
this.isScylla = (scyllaVersion != null);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
this.jvmArgs = jvmArgs;
this.nodes = nodes;
this.ccmDir = Files.createTempDir();
Expand Down Expand Up @@ -733,24 +733,38 @@ public void add(int n) {
public void add(int dc, int n) {
logger.debug(
String.format("Adding: node %s (%s%s:%s) to %s", n, ipPrefix, n, binaryPort, this));
String thriftItf = ipOfNode(n) + ":" + thriftPort;
String storageItf = ipOfNode(n) + ":" + storagePort;
String binaryItf = ipOfNode(n) + ":" + binaryPort;
String remoteLogItf = ipOfNode(n) + ":" + TestUtils.findAvailablePort();
execute(
CCM_COMMAND
+ " add node%d -d dc%s -i %s%d -t %s -l %s --binary-itf %s -j %d -r %s -s -b"
+ (isDSE ? " --dse" : "")
+ (isScylla ? " --scylla" : ""),
n,
dc,
ipPrefix,
n,
thriftItf,
storageItf,
binaryItf,
TestUtils.findAvailablePort(),
remoteLogItf);
if (isScylla) {
// scylla-ccm's `add` command has no thrift option: Scylla never had a Thrift interface.
execute(
CCM_COMMAND
+ " add node%d -d dc%s -i %s%d -l %s --binary-itf %s -j %d -r %s -s -b --scylla",
n,
dc,
ipPrefix,
n,
storageItf,
binaryItf,
TestUtils.findAvailablePort(),
remoteLogItf);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
} else {
String thriftItf = ipOfNode(n) + ":" + thriftPort;
execute(
CCM_COMMAND
+ " add node%d -d dc%s -i %s%d -t %s -l %s --binary-itf %s -j %d -r %s -s -b"
+ (isDSE ? " --dse" : ""),
n,
dc,
ipPrefix,
n,
thriftItf,
storageItf,
binaryItf,
TestUtils.findAvailablePort(),
remoteLogItf);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
})
@ScyllaOnly
@ScyllaVersion(minOSS = "6.0.0", minEnterprise = "2024.2", description = "Needs to support tablets")
public class TabletsIT extends CCMTestsSupport {
private static final Logger LOG = LoggerFactory.getLogger(TabletsIT.class);
public class TabletsTest extends CCMTestsSupport {
Comment thread
nikagra marked this conversation as resolved.
private static final Logger LOG = LoggerFactory.getLogger(TabletsTest.class);
private static final int INITIAL_TABLETS = 32;
private static final int QUERIES = 1600;
private static final int REPLICATION_FACTOR = 2;
Expand Down Expand Up @@ -190,8 +190,13 @@ public void every_statement_should_deliver_tablet_info() {
continue;
}
Session session = sessionEntry.getValue().get();
// Empty out tablets information
session.getCluster().getMetadata().getTabletMap().removeTableMappings(KEYSPACE_NAME);
// Empty out tablets information. The mapping is keyed by the lowercased keyspace name, as
// reported by the server, so the key has to be lowercased here too or this is a no-op.
session
.getCluster()
.getMetadata()
.getTabletMap()
.removeTableMappings(KEYSPACE_NAME.toLowerCase());
Statement stmt;
try {
stmt = stmtEntry.getValue().apply(session);
Expand Down Expand Up @@ -226,6 +231,10 @@ public void every_statement_should_deliver_tablet_info() {
stmtEntry.getKey(), sessionEntry.getKey()));
continue;
}
// executeOnAllHostsAndReturnIfResultHasTabletsInfo pins the statement to a specific host
// while hunting for tablet info. Clear that pin, otherwise the routing check below always
// observes the pinned host and can never detect misrouting.
stmt.setHost(null);
if (!checkIfRoutedProperly(session, stmt)) {
testErrors.add(
String.format(
Expand Down Expand Up @@ -343,6 +352,11 @@ private static boolean checkIfRoutedProperly(Session session, Statement stmt) {
int expectedNodesCount = stmt.isLWT() ? 1 : REPLICATION_FACTOR;
Set<Host> nodes = new HashSet<>();
for (int i = 0; i < REPLICATION_FACTOR * 3; i++) {
// PagingOptimizingLoadBalancingPolicy returns Statement.getLastHost() ahead of the real query
// plan, and that field is set after every successful BoundStatement execution. Clearing it
// keeps the loop from being pinned to the first coordinator, which would let any routing
// behaviour satisfy the check below.
stmt.setLastHost(null);
nodes.add(session.execute(stmt).getExecutionInfo().getQueriedHost());
}
return nodes.size() <= expectedNodesCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class ZeroTokenNodesIT {
public class ZeroTokenNodesTest {
Comment thread
nikagra marked this conversation as resolved.

@DataProvider(name = "loadBalancingPolicies")
public static Object[][] loadBalancingPolicies() {
Expand Down Expand Up @@ -173,12 +173,17 @@ public void should_discover_zero_token_DC_when_option_is_enabled(
queriedNodes.add(rs.getExecutionInfo().getQueriedHost().getEndPoint().resolve());
}

// containsOnly, not containsExactly: queriedNodes is a HashSet, whose iteration order is
// hash-derived rather than insertion order, so an order-sensitive assertion is a latent
// flake.
// AssertJ 1.7.1, pinned by this module, has no containsExactlyInAnyOrder; for a Set,
// containsOnly is equivalent to it.
if (isDcAware) {
assertThat(queriedNodes)
.containsExactly(ccmBridge.addressOfNode(1), ccmBridge.addressOfNode(2));
.containsOnly(ccmBridge.addressOfNode(1), ccmBridge.addressOfNode(2));
} else {
assertThat(queriedNodes)
.containsExactly(
.containsOnly(
ccmBridge.addressOfNode(1),
ccmBridge.addressOfNode(2),
ccmBridge.addressOfNode(3),
Expand Down

This file was deleted.

Loading
Loading