Skip to content

Commit e40ff35

Browse files
authored
PYTHON-4322 Fix racy unified tests of unacknowledged writes (#1578)
1 parent 9d43606 commit e40ff35

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

test/command_logging/unacknowledged-write.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "unacknowledged-write",
3-
"schemaVersion": "1.13",
3+
"schemaVersion": "1.16",
44
"createEntities": [
55
{
66
"client": {
@@ -53,11 +53,27 @@
5353
"_id": 2
5454
}
5555
}
56+
},
57+
{
58+
"name": "find",
59+
"object": "collection",
60+
"arguments": {
61+
"filter": {}
62+
},
63+
"expectResult": [
64+
{
65+
"_id": 1
66+
},
67+
{
68+
"_id": 2
69+
}
70+
]
5671
}
5772
],
5873
"expectLogMessages": [
5974
{
6075
"client": "client",
76+
"ignoreExtraMessages": true,
6177
"messages": [
6278
{
6379
"level": "debug",

test/command_monitoring/unacknowledgedBulkWrite.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "unacknowledgedBulkWrite",
3-
"schemaVersion": "1.0",
3+
"schemaVersion": "1.7",
44
"createEntities": [
55
{
66
"client": {
@@ -64,11 +64,29 @@
6464
],
6565
"ordered": false
6666
}
67+
},
68+
{
69+
"name": "find",
70+
"object": "collection",
71+
"arguments": {
72+
"filter": {}
73+
},
74+
"expectResult": [
75+
{
76+
"_id": 1,
77+
"x": 11
78+
},
79+
{
80+
"_id": "unorderedBulkWriteInsertW0",
81+
"x": 44
82+
}
83+
]
6784
}
6885
],
6986
"expectEvents": [
7087
{
7188
"client": "client",
89+
"ignoreExtraEvents": true,
7290
"events": [
7391
{
7492
"commandStartedEvent": {

test/unified_format.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,8 @@ def format_logs(log_list):
17881788
clientid = self.entity_map[client["client"]]._topology_settings._topology_id
17891789
actual_logs = formatted_logs[clientid]
17901790
actual_logs = [log for log in actual_logs if log["component"] in components]
1791+
if client.get("ignoreExtraMessages", False):
1792+
actual_logs = actual_logs[: len(client["messages"])]
17911793
self.assertEqual(len(client["messages"]), len(actual_logs))
17921794
for expected_msg, actual_msg in zip(client["messages"], actual_logs):
17931795
expected_data, actual_data = expected_msg.pop("data"), actual_msg.pop("data")

0 commit comments

Comments
 (0)