PYTHON-4701 - Topology logging should use suppress_event (#1826)

This commit is contained in:
Noah Stapp 2024-09-03 16:57:41 -04:00 committed by GitHub
parent ba8a139e72
commit 5a70039ad2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View File

@ -475,7 +475,7 @@ class Topology:
if server:
await server.pool.ready()
suppress_event = (self._publish_server or self._publish_tp) and sd_old == server_description
suppress_event = sd_old == server_description
if self._publish_server and not suppress_event:
assert self._events is not None
self._events.put(
@ -497,7 +497,7 @@ class Topology:
(td_old, self._description, self._topology_id),
)
)
if _SDAM_LOGGER.isEnabledFor(logging.DEBUG):
if _SDAM_LOGGER.isEnabledFor(logging.DEBUG) and not suppress_event:
_debug_log(
_SDAM_LOGGER,
topologyId=self._topology_id,

View File

@ -475,7 +475,7 @@ class Topology:
if server:
server.pool.ready()
suppress_event = (self._publish_server or self._publish_tp) and sd_old == server_description
suppress_event = sd_old == server_description
if self._publish_server and not suppress_event:
assert self._events is not None
self._events.put(
@ -497,7 +497,7 @@ class Topology:
(td_old, self._description, self._topology_id),
)
)
if _SDAM_LOGGER.isEnabledFor(logging.DEBUG):
if _SDAM_LOGGER.isEnabledFor(logging.DEBUG) and not suppress_event:
_debug_log(
_SDAM_LOGGER,
topologyId=self._topology_id,

View File

@ -1954,7 +1954,11 @@ class UnifiedSpecTestMixinV1(IntegrationTest):
if client.get("ignoreExtraMessages", False):
actual_logs = actual_logs[: len(client["messages"])]
self.assertEqual(len(client["messages"]), len(actual_logs))
self.assertEqual(
len(client["messages"]),
len(actual_logs),
f"expected {client['messages']} but got {actual_logs}",
)
for expected_msg, actual_msg in zip(client["messages"], actual_logs):
expected_data, actual_data = expected_msg.pop("data"), actual_msg.pop("data")