Skip to content

Commit d767759

Browse files
authored
PYTHON-5517 update SDAM error handling tests to ignore handshake failures (#2631)
1 parent 0010325 commit d767759

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

test/asynchronous/test_discovery_and_monitoring.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ async def got_app_error(topology, app_error):
145145
raise AssertionError
146146
except (AutoReconnect, NotPrimaryError, OperationFailure) as e:
147147
if when == "beforeHandshakeCompletes":
148+
# The pool would have added the SystemOverloadedError in this case.
149+
if isinstance(e, AutoReconnect):
150+
e._add_error_label("SystemOverloadedError")
148151
completed_handshake = False
149152
elif when == "afterHandshakeCompletes":
150153
completed_handshake = True

test/discovery_and_monitoring/errors/error_handling_handshake.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,22 @@
9797
"outcome": {
9898
"servers": {
9999
"a:27017": {
100-
"type": "Unknown",
101-
"topologyVersion": null,
100+
"type": "RSPrimary",
101+
"setName": "rs",
102+
"topologyVersion": {
103+
"processId": {
104+
"$oid": "000000000000000000000001"
105+
},
106+
"counter": {
107+
"$numberLong": "1"
108+
}
109+
},
102110
"pool": {
103-
"generation": 1
111+
"generation": 0
104112
}
105113
}
106114
},
107-
"topologyType": "ReplicaSetNoPrimary",
115+
"topologyType": "ReplicaSetWithPrimary",
108116
"logicalSessionTimeoutMinutes": null,
109117
"setName": "rs"
110118
}

test/test_discovery_and_monitoring.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ def got_app_error(topology, app_error):
145145
raise AssertionError
146146
except (AutoReconnect, NotPrimaryError, OperationFailure) as e:
147147
if when == "beforeHandshakeCompletes":
148+
# The pool would have added the SystemOverloadedError in this case.
149+
if isinstance(e, AutoReconnect):
150+
e._add_error_label("SystemOverloadedError")
148151
completed_handshake = False
149152
elif when == "afterHandshakeCompletes":
150153
completed_handshake = True

0 commit comments

Comments
 (0)