Skip to content

Commit db9440f

Browse files
Bouncheckavelanarius
authored andcommitted
Replace numberOfLocalCoreConnections usages with "Sharded" version
There are multiple tests that use TestUtils.numberOfLocalCoreConnections(cluster) to determine the expected number of open connections. This works fine in case of Cassandra but with the current state of the driver does not work fine with multi shard Scylla. Switch will allow those tests to pass at the cost of not following PoolingOptions strictly. This change affects ClusterStressTest, ReconnectionTest, SessionStressTest, TimeoutStressTest. This is just a workaround.
1 parent 31f8523 commit db9440f

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public CreateClusterAndCheckConnections call() throws Exception {
197197
assertEquals(cluster.manager.sessions.size(), 1);
198198
assertEquals(
199199
(int) cluster.getMetrics().getOpenConnections().getValue(),
200-
1 + TestUtils.numberOfLocalCoreConnections(cluster));
200+
1 + TestUtils.numberOfLocalCoreConnectionsSharded(cluster));
201201
assertEquals(
202202
channelMonitor.openChannels(getContactPointsWithPorts()).size(),
203203
1 + TestUtils.numberOfLocalCoreConnections(cluster));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public void should_use_connection_from_reconnection_in_pool() {
237237
cluster.connect();
238238
cluster.connect();
239239

240-
int corePoolSize = TestUtils.numberOfLocalCoreConnections(cluster);
240+
int corePoolSize = TestUtils.numberOfLocalCoreConnectionsSharded(cluster);
241241

242242
// Right after init, 1 connection has been opened by the control connection, and the core size
243243
// for each pool.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,12 @@ public void sessions_should_not_leak_connections() {
116116
// This is a local cluster so we also have 2 connections per session
117117
Session session = stressCluster.connect();
118118
assertEquals(stressCluster.manager.sessions.size(), 1);
119-
int coreConnections = TestUtils.numberOfLocalCoreConnections(stressCluster);
119+
int coreConnections = TestUtils.numberOfLocalCoreConnectionsSharded(stressCluster);
120120
assertEquals(
121121
(int) stressCluster.getMetrics().getOpenConnections().getValue(), 1 + coreConnections);
122122
assertEquals(
123-
channelMonitor.openChannels(getContactPointsWithPorts()).size(), 1 + coreConnections);
123+
channelMonitor.openChannels(getContactPointsWithPorts()).size(),
124+
1 + TestUtils.numberOfLocalCoreConnections(stressCluster));
124125

125126
// Closing the session keeps the control connection opened
126127
session.close();

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ public void host_state_should_be_maintained_with_timeouts() throws Exception {
132132
AtomicBoolean stopped = new AtomicBoolean(false);
133133

134134
// Ensure that we never exceed MaxConnectionsPerHost * nodes + 1 control connection.
135-
int maxConnections =
136-
TestUtils.numberOfLocalCoreConnections(cluster()) * getContactPoints().size() + 1;
135+
// numberOfLocalCoreConnectionsSharded iterates over all hosts, so there is no need to multiply
136+
// by nodes now.
137+
int maxConnections = TestUtils.numberOfLocalCoreConnectionsSharded(cluster()) + 1;
137138

138139
try {
139140
Semaphore concurrentQueries = new Semaphore(CONCURRENT_QUERIES);

0 commit comments

Comments
 (0)