From 10bcf2e3858a9f28f69048c934ce08bf56a2044b Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Tue, 24 Feb 2026 22:34:00 -0400 Subject: [PATCH] IT: fix flaky HeartbeatTests.HeartbeatFailed test Use 1 connection per host instead of the default per-shard pool to avoid asynchronous shard-aware connection establishment racing with the baseline connection count read. Fixes #395 --- tests/src/integration/tests/test_heartbeat.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/src/integration/tests/test_heartbeat.cpp b/tests/src/integration/tests/test_heartbeat.cpp index 6cdc59ee..8a0e9193 100644 --- a/tests/src/integration/tests/test_heartbeat.cpp +++ b/tests/src/integration/tests/test_heartbeat.cpp @@ -84,8 +84,12 @@ CASSANDRA_INTEGRATION_TEST_F(HeartbeatTests, HeartbeatFailed) { CHECK_FAILURE; logger_.add_critera("Timed out while waiting for response to keepalive request"); - Cluster cluster = - default_cluster().with_connection_heartbeat_interval(1).with_connection_idle_timeout(5); + // Use 1 connection per host to avoid asynchronous shard-aware connection + // establishment that could race with the baseline connection count read. + Cluster cluster = default_cluster() + .with_core_connections_per_host(1) + .with_connection_heartbeat_interval(1) + .with_connection_idle_timeout(5); connect(cluster); cass_uint64_t initial_connections = session_.metrics().stats.total_connections;