From cd08b7248eb4e3ab901a8f7905874da41b908f7c Mon Sep 17 00:00:00 2001 From: Jeff Yemin Date: Wed, 3 Apr 2024 12:43:43 -0400 Subject: [PATCH] DRIVERS-2877: Follow w: 0 write with a find in spec tests (#1560) This will force completion of the w: 0 write, which addresses a TCP-based race condition in the tests --- .../tests/logging/unacknowledged-write.json | 18 ++++++++++++++++- .../tests/logging/unacknowledged-write.yml | 12 ++++++++++- .../monitoring/unacknowledgedBulkWrite.json | 20 ++++++++++++++++++- .../monitoring/unacknowledgedBulkWrite.yml | 12 ++++++++++- 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/source/command-logging-and-monitoring/tests/logging/unacknowledged-write.json b/source/command-logging-and-monitoring/tests/logging/unacknowledged-write.json index 21e247df66..dad0c0a36a 100644 --- a/source/command-logging-and-monitoring/tests/logging/unacknowledged-write.json +++ b/source/command-logging-and-monitoring/tests/logging/unacknowledged-write.json @@ -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", diff --git a/source/command-logging-and-monitoring/tests/logging/unacknowledged-write.yml b/source/command-logging-and-monitoring/tests/logging/unacknowledged-write.yml index 7d4847e0d9..16ee0e3cc6 100644 --- a/source/command-logging-and-monitoring/tests/logging/unacknowledged-write.yml +++ b/source/command-logging-and-monitoring/tests/logging/unacknowledged-write.yml @@ -1,6 +1,6 @@ description: "unacknowledged-write" -schemaVersion: "1.13" +schemaVersion: "1.16" createEntities: - client: @@ -31,8 +31,18 @@ tests: object: *collection arguments: document: { _id: 2 } + # Force completion of the w: 0 write by executing a find on the same connection + - name: find + object: *collection + arguments: + filter: { } + expectResult: [ + { _id: 1 }, + { _id: 2 } + ] expectLogMessages: - client: *client + ignoreExtraMessages: true messages: - level: debug component: command diff --git a/source/command-logging-and-monitoring/tests/monitoring/unacknowledgedBulkWrite.json b/source/command-logging-and-monitoring/tests/monitoring/unacknowledgedBulkWrite.json index 4c16d6df11..782cb84a5b 100644 --- a/source/command-logging-and-monitoring/tests/monitoring/unacknowledgedBulkWrite.json +++ b/source/command-logging-and-monitoring/tests/monitoring/unacknowledgedBulkWrite.json @@ -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": { diff --git a/source/command-logging-and-monitoring/tests/monitoring/unacknowledgedBulkWrite.yml b/source/command-logging-and-monitoring/tests/monitoring/unacknowledgedBulkWrite.yml index d7c8ce0d0c..e512b2eb56 100644 --- a/source/command-logging-and-monitoring/tests/monitoring/unacknowledgedBulkWrite.yml +++ b/source/command-logging-and-monitoring/tests/monitoring/unacknowledgedBulkWrite.yml @@ -1,6 +1,6 @@ description: "unacknowledgedBulkWrite" -schemaVersion: "1.0" +schemaVersion: "1.7" createEntities: - client: @@ -36,8 +36,18 @@ tests: - insertOne: document: { _id: "unorderedBulkWriteInsertW0", x: 44 } ordered: false + # Force completion of the w: 0 write by executing a find on the same connection + - name: find + object: *collection + arguments: + filter: { } + expectResult: [ + { _id: 1, x: 11 }, + { _id: "unorderedBulkWriteInsertW0", x: 44 } + ] expectEvents: - client: *client + ignoreExtraEvents: true events: - commandStartedEvent: command: