PYTHON-4322 Fix racy unified tests of unacknowledged writes (#1578)

This commit is contained in:
Steven Silvester 2024-04-10 20:19:51 -05:00 committed by GitHub
parent 9d43606662
commit e40ff35168
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"description": "unacknowledged-write",
"schemaVersion": "1.13",
"schemaVersion": "1.16",
"createEntities": [
{
"client": {
@ -53,11 +53,27 @@
"_id": 2
}
}
},
{
"name": "find",
"object": "collection",
"arguments": {
"filter": {}
},
"expectResult": [
{
"_id": 1
},
{
"_id": 2
}
]
}
],
"expectLogMessages": [
{
"client": "client",
"ignoreExtraMessages": true,
"messages": [
{
"level": "debug",

View File

@ -1,6 +1,6 @@
{
"description": "unacknowledgedBulkWrite",
"schemaVersion": "1.0",
"schemaVersion": "1.7",
"createEntities": [
{
"client": {
@ -64,11 +64,29 @@
],
"ordered": false
}
},
{
"name": "find",
"object": "collection",
"arguments": {
"filter": {}
},
"expectResult": [
{
"_id": 1,
"x": 11
},
{
"_id": "unorderedBulkWriteInsertW0",
"x": 44
}
]
}
],
"expectEvents": [
{
"client": "client",
"ignoreExtraEvents": true,
"events": [
{
"commandStartedEvent": {

View File

@ -1788,6 +1788,8 @@ class UnifiedSpecTestMixinV1(IntegrationTest):
clientid = self.entity_map[client["client"]]._topology_settings._topology_id
actual_logs = formatted_logs[clientid]
actual_logs = [log for log in actual_logs if log["component"] in components]
if client.get("ignoreExtraMessages", False):
actual_logs = actual_logs[: len(client["messages"])]
self.assertEqual(len(client["messages"]), len(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")