Skip to content

Commit c7252e4

Browse files
committed
(fix) test: Fix KeyError in test_idle_heartbeat with connection replacement
The test_idle_heartbeat test was failing with a KeyError when connections were dynamically replaced during the test run in shard-aware environments. Root cause: The test captures connection object IDs at the start, sleeps for heartbeat intervals, then tries to validate those connections. In shard-aware ScyllaDB deployments, the driver may replace connections during this window. When a connection is replaced, the new connection object has a different Python ID, causing a KeyError on lookup. Fix: Skip validation for connections that weren't present in the initial snapshot. This preserves the test's intent (validating heartbeats on stable connections) while being robust to dynamic connection management in shard-aware mode. I'm not sure this is a great fix. I don't think it has anything to do with this branch. I'll push it and if it's OK, I'll also create a separate PR for it. Why it popped now? Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
1 parent 153c913 commit c7252e4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

tests/integration/standard/test_cluster.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,14 @@ def test_idle_heartbeat(self):
769769
connections = [c for holders in cluster.get_connection_holders() for c in holders.get_connections()]
770770

771771
# make sure requests were sent on all connections
772+
# Note: connections can be replaced in shard-aware environments, so we skip
773+
# connections that weren't present in the initial snapshot
772774
for c in connections:
773-
expected_ids = connection_request_ids[id(c)]
775+
conn_id = id(c)
776+
if conn_id not in connection_request_ids:
777+
# Connection was replaced during the test, skip validation
778+
continue
779+
expected_ids = connection_request_ids[conn_id]
774780
expected_ids.rotate(-1)
775781
with c.lock:
776782
assertListEqual(list(c.request_ids), list(expected_ids))

0 commit comments

Comments
 (0)