Skip to content

Add missing tests for bulkWrite command #1803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions source/crud/tests/unified/client-bulkWrite-delete-options.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions source/crud/tests/unified/client-bulkWrite-delete-options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,56 @@ tests:
- databaseName: *database0Name
collectionName: *collection0Name
documents: []
- description: "client bulk write delete with non-Int32 hint"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bulk write should be bulkWrite for consistency with other tests.

operations:
- object: *client0
name: clientBulkWrite
arguments:
models:
- deleteOne:
namespace: *namespace
filter: { _id: 1 }
hint: { _id: { $numberLong: "1" } }
- deleteMany:
namespace: *namespace
filter: { _id: { $gt: 1 } }
hint: { _id: { $numberLong: "1" } }
verboseResults: true
expectResult:
insertedCount: 0
upsertedCount: 0
matchedCount: 0
modifiedCount: 0
deletedCount: 3
insertResults: {}
updateResults: {}
deleteResults:
0:
deletedCount: 1
1:
deletedCount: 2
expectEvents:
- client: *client0
events:
- commandStartedEvent:
commandName: bulkWrite
databaseName: admin
command:
bulkWrite: 1
errorsOnly: false
ordered: true
ops:
- delete: 0
filter: { _id: 1 }
hint: { _id: { $numberLong: "1" } }
multi: false
- delete: 0
filter: { _id: { $gt: 1 } }
hint: { _id: { $numberLong: "1" } }
multi: true
nsInfo:
- ns: *namespace
outcome:
- databaseName: *database0Name
collectionName: *collection0Name
documents: []
143 changes: 143 additions & 0 deletions source/crud/tests/unified/client-bulkWrite-options.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions source/crud/tests/unified/client-bulkWrite-options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,64 @@ tests:
document: { _id: 3, x: 33 }
nsInfo:
- ns: *namespace
- description: "client bulkWrite with unacknowledged write concern (w:0) for all batches"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include in the description that this test is expected to return an error.

runOnRequirements:
- minServerVersion: "8.0"
serverless: forbid
operations:
- object: *client0
name: clientBulkWrite
arguments:
models:
- insertOne:
namespace: *namespace
document: { _id: 5, x: 55 }
- insertOne:
namespace: *namespace
document: { _id: 6, x: 66 }
verboseResults: false
ordered: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ordered: true.

writeConcern: { w: 0 }
expectError:
isClientError: true
errorContains: "Cannot request unacknowledged write concern and ordered writes"
expectEvents:
- client: *client0
events: []
- description: "client bulkWrite with unacknowledged write concern (w:0) for all batches with ordered=false"
runOnRequirements:
- minServerVersion: "8.0"
serverless: forbid
operations:
- object: *client0
name: clientBulkWrite
arguments:
models:
- insertOne:
namespace: *namespace
document: { _id: 5, x: 55 }
- insertOne:
namespace: *namespace
document: { _id: 6, x: 66 }
verboseResults: false
ordered: false
writeConcern: { w: 0 }
expectResult: { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } }
expectEvents:
- client: *client0
events:
- commandStartedEvent:
commandName: bulkWrite
databaseName: admin
command:
bulkWrite: 1
errorsOnly: false
ordered: false
ops:
- insert: 0
document: { _id: 5, x: 55 }
- insert: 0
document: { _id: 6, x: 66 }
nsInfo:
- ns: *namespace
writeConcern: { w: 0 }
Loading