Skip to content

Commit

Permalink
GODRIVER-2388 Improved Bulk Write API.
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Sep 11, 2024
1 parent c5b9705 commit 2d56e0e
Show file tree
Hide file tree
Showing 34 changed files with 19,541 additions and 51 deletions.
171 changes: 141 additions & 30 deletions testdata/command-monitoring/unacknowledgedBulkWrite.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
{
"description": "unacknowledgedBulkWrite",
"schemaVersion": "1.0",
"description": "unacknowledged-client-bulkWrite",
"schemaVersion": "1.7",
"runOnRequirements": [
{
"minServerVersion": "8.0",
"serverless": "forbid"
}
],
"createEntities": [
{
"client": {
"id": "client",
"useMultipleMongoses": false,
"observeEvents": [
"commandStartedEvent",
"commandSucceededEvent",
"commandFailedEvent"
]
],
"uriOptions": {
"w": 0
}
}
},
{
Expand All @@ -23,12 +33,7 @@
"collection": {
"id": "collection",
"database": "database",
"collectionName": "test",
"collectionOptions": {
"writeConcern": {
"w": 0
}
}
"collectionName": "test"
}
}
],
Expand All @@ -40,64 +45,170 @@
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
],
"_yamlAnchors": {
"namespace": "command-monitoring-tests.test"
},
"tests": [
{
"description": "A successful unordered bulk write with an unacknowledged write concern",
"description": "A successful mixed client bulkWrite",
"operations": [
{
"name": "bulkWrite",
"object": "collection",
"object": "client",
"name": "clientBulkWrite",
"arguments": {
"requests": [
"models": [
{
"insertOne": {
"namespace": "command-monitoring-tests.test",
"document": {
"_id": "unorderedBulkWriteInsertW0",
"_id": 4,
"x": 44
}
}
},
{
"updateOne": {
"namespace": "command-monitoring-tests.test",
"filter": {
"_id": 3
},
"update": {
"$set": {
"x": 333
}
}
}
}
],
"ordered": false
]
},
"expectResult": {
"insertedCount": {
"$$unsetOrMatches": 0
},
"upsertedCount": {
"$$unsetOrMatches": 0
},
"matchedCount": {
"$$unsetOrMatches": 0
},
"modifiedCount": {
"$$unsetOrMatches": 0
},
"deletedCount": {
"$$unsetOrMatches": 0
},
"insertResults": {
"$$unsetOrMatches": {}
},
"updateResults": {
"$$unsetOrMatches": {}
},
"deleteResults": {
"$$unsetOrMatches": {}
}
}
},
{
"object": "collection",
"name": "find",
"arguments": {
"filter": {}
},
"expectResult": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 333
},
{
"_id": 4,
"x": 44
}
]
}
],
"expectEvents": [
{
"client": "client",
"ignoreExtraEvents": true,
"events": [
{
"commandStartedEvent": {
"commandName": "bulkWrite",
"databaseName": "admin",
"command": {
"insert": "test",
"documents": [
"bulkWrite": 1,
"errorsOnly": true,
"ordered": true,
"ops": [
{
"_id": "unorderedBulkWriteInsertW0",
"x": 44
"insert": 0,
"document": {
"_id": 4,
"x": 44
}
},
{
"update": 0,
"filter": {
"_id": 3
},
"updateMods": {
"$set": {
"x": 333
}
},
"multi": false
}
],
"ordered": false,
"writeConcern": {
"w": 0
}
},
"commandName": "insert",
"databaseName": "command-monitoring-tests"
"nsInfo": [
{
"ns": "command-monitoring-tests.test"
}
]
}
}
},
{
"commandSucceededEvent": {
"commandName": "bulkWrite",
"reply": {
"ok": 1,
"n": {
"nInserted": {
"$$exists": false
},
"nMatched": {
"$$exists": false
},
"nModified": {
"$$exists": false
},
"nUpserted": {
"$$exists": false
},
"nDeleted": {
"$$exists": false
}
},
"commandName": "insert"
}
}
}
]
Expand Down
95 changes: 75 additions & 20 deletions testdata/command-monitoring/unacknowledgedBulkWrite.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
description: "unacknowledgedBulkWrite"
description: "unacknowledged-client-bulkWrite"

schemaVersion: "1.0"
schemaVersion: "1.7"

runOnRequirements:
- minServerVersion: "8.0"
serverless: forbid

createEntities:
- client:
id: &client client
useMultipleMongoses: false
observeEvents:
- commandStartedEvent
- commandSucceededEvent
- commandFailedEvent
uriOptions:
w: 0
- database:
id: &database database
client: *client
Expand All @@ -17,39 +24,87 @@ createEntities:
id: &collection collection
database: *database
collectionName: &collectionName test
collectionOptions:
writeConcern: { w: 0 }

initialData:
- collectionName: *collectionName
databaseName: *databaseName
documents:
- { _id: 1, x: 11 }
- { _id: 2, x: 22 }
- { _id: 3, x: 33 }

_yamlAnchors:
namespace: &namespace "command-monitoring-tests.test"

tests:
- description: "A successful unordered bulk write with an unacknowledged write concern"
- description: 'A successful mixed client bulkWrite'
operations:
- name: bulkWrite
object: *collection
- object: *client
name: clientBulkWrite
arguments:
requests:
models:
- insertOne:
document: { _id: "unorderedBulkWriteInsertW0", x: 44 }
ordered: false
namespace: *namespace
document: { _id: 4, x: 44 }
- updateOne:
namespace: *namespace
filter: { _id: 3 }
update: { $set: { x: 333 } }
expectResult:
insertedCount:
$$unsetOrMatches: 0
upsertedCount:
$$unsetOrMatches: 0
matchedCount:
$$unsetOrMatches: 0
modifiedCount:
$$unsetOrMatches: 0
deletedCount:
$$unsetOrMatches: 0
insertResults:
$$unsetOrMatches: {}
updateResults:
$$unsetOrMatches: {}
deleteResults:
$$unsetOrMatches: {}
# Force completion of the w:0 write by executing a find on the same connection
- object: *collection
name: find
arguments:
filter: {}
expectResult:
- { _id: 1, x: 11 }
- { _id: 2, x: 22 }
- { _id: 3, x: 333 }
- { _id: 4, x: 44 }

expectEvents:
- client: *client
-
client: *client
ignoreExtraEvents: true
events:
- commandStartedEvent:
commandName: bulkWrite
databaseName: admin
command:
insert: *collectionName
documents:
- { _id: "unorderedBulkWriteInsertW0", x: 44 }
ordered: false
writeConcern: { w: 0 }
commandName: insert
databaseName: *databaseName
bulkWrite: 1
errorsOnly: true
ordered: true
ops:
- insert: 0
document: { _id: 4, x: 44 }
- update: 0
filter: { _id: 3 }
updateMods: { $set: { x: 333 } }
multi: false
nsInfo:
- ns: *namespace
- commandSucceededEvent:
commandName: bulkWrite
reply:
ok: 1
n: { $$exists: false }
commandName: insert
nInserted: { $$exists: false }
nMatched: { $$exists: false }
nModified: { $$exists: false }
nUpserted: { $$exists: false }
nDeleted: { $$exists: false }
Loading

0 comments on commit 2d56e0e

Please sign in to comment.