Skip to content
Merged
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
21 changes: 20 additions & 1 deletion packages/google-cloud-bigquery/tests/system/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2213,7 +2213,26 @@ def test_dbapi_connection_does_not_leak_sockets(self):
break
time.sleep(0.1)

self.assertLessEqual(conn_count_end, conn_count_start)
try:
self.assertLessEqual(conn_count_end, conn_count_start)
except AssertionError as e:
# Due to flakiness in this test (likely caused by OS cleanup delays or
# non-deterministic garbage collection of sockets), we want to capture
# the detailed state of connections in future failing runs to help
# decrease false positives and identify the root cause.
conn_debug = [
f"Status: {c.status}, Laddr: {c.laddr}, Raddr: {c.raddr}"
for c in current_process.net_connections()
]
Comment thread
chalmerlowe marked this conversation as resolved.
debug_msg = "\n".join(conn_debug)

raise AssertionError(
f"{e}\n\n"
f"--- Socket Leak Debug Info ---\n"
f"Start Count: {conn_count_start}\n"
f"End Count: {conn_count_end}\n"
f"Current Connections:\n{debug_msg}"
)

def _load_table_for_dml(self, rows, dataset_id, table_id):
from google.cloud._testing import _NamedTemporaryFile
Expand Down
Loading