From 8185ecdaad26a1f426d7891bd4eff5e335bd443a Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Tue, 29 Oct 2024 22:49:48 +0000 Subject: [PATCH 1/7] Sync CRUD unified tests --- .../crud/aggregate-allowdiskuse.yml | 75 +++ .../crud/aggregate-collation.yml | 48 ++ .../crud/aggregate-let.yml | 138 ++++++ .../crud/aggregate-merge-errorResponse.yml | 42 ++ .../crud/aggregate-merge.yml | 182 +++++++ .../crud/aggregate-out-readConcern.yml | 168 +++++++ .../crud/aggregate-out.yml | 72 +++ .../crud/aggregate-write-readPreference.yml | 143 ++++++ .../unified-test-format/crud/aggregate.yml | 232 +++++++++ .../bulkWrite-arrayFilters-clientError.yml | 95 ++++ .../crud/bulkWrite-arrayFilters.yml | 210 ++++++++ .../crud/bulkWrite-collation.yml | 130 +++++ .../crud/bulkWrite-comment.json | 30 +- .../crud/bulkWrite-comment.yml | 175 +++++++ .../bulkWrite-delete-hint-clientError.yml | 110 +++++ .../bulkWrite-delete-hint-serverError.yml | 139 ++++++ .../crud/bulkWrite-delete-hint.yml | 151 ++++++ ...lkWrite-deleteMany-hint-unacknowledged.yml | 98 ++++ .../crud/bulkWrite-deleteMany-let.yml | 86 ++++ ...ulkWrite-deleteOne-hint-unacknowledged.yml | 97 ++++ .../crud/bulkWrite-deleteOne-let.yml | 86 ++++ .../crud/bulkWrite-errorResponse.yml | 50 ++ .../bulkWrite-insertOne-dots_and_dollars.yml | 138 ++++++ .../bulkWrite-replaceOne-dots_and_dollars.yml | 165 +++++++ ...lkWrite-replaceOne-hint-unacknowledged.yml | 103 ++++ .../crud/bulkWrite-replaceOne-let.yml | 93 ++++ .../crud/bulkWrite-replaceOne-sort.json | 239 ++++++++++ .../crud/bulkWrite-replaceOne-sort.yml | 94 ++++ .../bulkWrite-update-hint-clientError.yml | 145 ++++++ .../bulkWrite-update-hint-serverError.yml | 236 +++++++++ .../crud/bulkWrite-update-hint.yml | 253 ++++++++++ .../crud/bulkWrite-update-validation.yml | 73 +++ .../bulkWrite-updateMany-dots_and_dollars.yml | 150 ++++++ ...lkWrite-updateMany-hint-unacknowledged.yml | 104 ++++ .../crud/bulkWrite-updateMany-let.yml | 96 ++++ .../bulkWrite-updateOne-dots_and_dollars.yml | 150 ++++++ ...ulkWrite-updateOne-hint-unacknowledged.yml | 103 ++++ .../crud/bulkWrite-updateOne-let.yml | 95 ++++ .../crud/bulkWrite-updateOne-sort.json | 255 ++++++++++ .../crud/bulkWrite-updateOne-sort.yml | 94 ++++ .../unified-test-format/crud/bulkWrite.yml | 448 ++++++++++++++++++ .../crud/count-collation.yml | 57 +++ .../unified-test-format/crud/count-empty.yml | 52 ++ .../unified-test-format/crud/count.yml | 95 ++++ .../crud/countDocuments-comment.yml | 92 ++++ .../db-aggregate-write-readPreference.yml | 138 ++++++ .../unified-test-format/crud/db-aggregate.yml | 70 +++ .../crud/deleteMany-collation.yml | 54 +++ .../crud/deleteMany-comment.yml | 97 ++++ .../crud/deleteMany-hint-clientError.yml | 84 ++++ .../crud/deleteMany-hint-serverError.yml | 104 ++++ .../crud/deleteMany-hint-unacknowledged.yml | 90 ++++ .../crud/deleteMany-hint.yml | 96 ++++ .../crud/deleteMany-let.yml | 93 ++++ .../unified-test-format/crud/deleteMany.yml | 63 +++ .../crud/deleteOne-collation.yml | 55 +++ .../crud/deleteOne-comment.yml | 98 ++++ .../crud/deleteOne-errorResponse.yml | 46 ++ .../crud/deleteOne-hint-clientError.yml | 77 +++ .../crud/deleteOne-hint-serverError.yml | 97 ++++ .../crud/deleteOne-hint-unacknowledged.yml | 89 ++++ .../crud/deleteOne-hint.yml | 92 ++++ .../crud/deleteOne-let.yml | 91 ++++ .../unified-test-format/crud/deleteOne.yml | 76 +++ .../crud/distinct-collation.yml | 48 ++ .../crud/distinct-comment.yml | 98 ++++ .../unified-test-format/crud/distinct.yml | 54 +++ .../crud/estimatedDocumentCount-comment.yml | 95 ++++ .../crud/estimatedDocumentCount.yml | 181 +++++++ .../crud/find-allowdiskuse-clientError.yml | 52 ++ .../crud/find-allowdiskuse-serverError.yml | 65 +++ .../crud/find-allowdiskuse.yml | 76 +++ .../crud/find-collation.yml | 46 ++ .../unified-test-format/crud/find-comment.yml | 166 +++++++ .../unified-test-format/crud/find-let.yml | 71 +++ .../unified-test-format/crud/find.yml | 107 +++++ .../crud/findOneAndDelete-collation.yml | 56 +++ .../crud/findOneAndDelete-comment.yml | 96 ++++ .../findOneAndDelete-hint-clientError.yml | 88 ++++ .../findOneAndDelete-hint-serverError.yml | 104 ++++ .../findOneAndDelete-hint-unacknowledged.yml | 88 ++++ .../crud/findOneAndDelete-hint.yml | 99 ++++ .../crud/findOneAndDelete-let.yml | 86 ++++ .../crud/findOneAndDelete.yml | 84 ++++ .../crud/findOneAndReplace-collation.yml | 57 +++ .../crud/findOneAndReplace-comment.yml | 101 ++++ .../findOneAndReplace-dots_and_dollars.yml | 140 ++++++ .../findOneAndReplace-hint-clientError.yml | 80 ++++ .../findOneAndReplace-hint-serverError.yml | 96 ++++ .../findOneAndReplace-hint-unacknowledged.yml | 96 ++++ .../crud/findOneAndReplace-hint.yml | 95 ++++ .../crud/findOneAndReplace-let.yml | 94 ++++ .../crud/findOneAndReplace-upsert.yml | 127 +++++ .../crud/findOneAndReplace.yml | 152 ++++++ .../crud/findOneAndUpdate-arrayFilters.yml | 89 ++++ .../crud/findOneAndUpdate-collation.yml | 58 +++ .../crud/findOneAndUpdate-comment.yml | 95 ++++ .../findOneAndUpdate-dots_and_dollars.yml | 127 +++++ .../crud/findOneAndUpdate-errorResponse.yml | 69 +++ .../findOneAndUpdate-hint-clientError.yml | 81 ++++ .../findOneAndUpdate-hint-serverError.yml | 97 ++++ .../findOneAndUpdate-hint-unacknowledged.yml | 92 ++++ .../crud/findOneAndUpdate-hint.yml | 96 ++++ .../crud/findOneAndUpdate-let.yml | 96 ++++ .../crud/findOneAndUpdate.yml | 199 ++++++++ .../crud/insertMany-comment.yml | 93 ++++ .../crud/insertMany-dots_and_dollars.yml | 128 +++++ .../unified-test-format/crud/insertMany.yml | 118 +++++ .../crud/insertOne-comment.yml | 91 ++++ .../crud/insertOne-dots_and_dollars.yml | 238 ++++++++++ .../crud/insertOne-errorResponse.yml | 46 ++ .../unified-test-format/crud/insertOne.yml | 44 ++ .../crud/replaceOne-collation.yml | 57 +++ .../crud/replaceOne-comment.yml | 105 ++++ .../crud/replaceOne-dots_and_dollars.yml | 180 +++++++ .../crud/replaceOne-hint-unacknowledged.yml | 95 ++++ .../crud/replaceOne-hint.yml | 105 ++++ .../crud/replaceOne-let.yml | 98 ++++ .../crud/replaceOne-sort.json | 232 +++++++++ .../crud/replaceOne-sort.yml | 94 ++++ .../crud/replaceOne-validation.yml | 37 ++ .../unified-test-format/crud/replaceOne.yml | 138 ++++++ .../crud/updateMany-arrayFilters.yml | 98 ++++ .../crud/updateMany-collation.yml | 59 +++ .../crud/updateMany-comment.yml | 104 ++++ .../crud/updateMany-dots_and_dollars.yml | 138 ++++++ .../crud/updateMany-hint-clientError.yml | 88 ++++ .../crud/updateMany-hint-serverError.yml | 112 +++++ .../crud/updateMany-hint-unacknowledged.yml | 96 ++++ .../crud/updateMany-hint.yml | 112 +++++ .../crud/updateMany-let.yml | 107 +++++ .../crud/updateMany-validation.yml | 39 ++ .../unified-test-format/crud/updateMany.yml | 120 +++++ .../crud/updateOne-arrayFilters.yml | 150 ++++++ .../crud/updateOne-collation.yml | 57 +++ .../crud/updateOne-comment.yml | 104 ++++ .../crud/updateOne-dots_and_dollars.yml | 138 ++++++ .../crud/updateOne-errorResponse.yml | 47 ++ .../crud/updateOne-hint-clientError.yml | 82 ++++ .../crud/updateOne-hint-serverError.yml | 106 +++++ .../crud/updateOne-hint-unacknowledged.yml | 95 ++++ .../crud/updateOne-hint.yml | 106 +++++ .../crud/updateOne-let.yml | 102 ++++ .../crud/updateOne-sort.json | 240 ++++++++++ .../crud/updateOne-sort.yml | 96 ++++ .../crud/updateOne-validation.yml | 37 ++ .../unified-test-format/crud/updateOne.yml | 114 +++++ .../crud/updateWithPipelines.yml | 296 ++++++++++++ .../client/unified/UnifiedCrudTest.java | 8 + 149 files changed, 16116 insertions(+), 28 deletions(-) create mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-allowdiskuse.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-collation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-merge-errorResponse.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-merge.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-out-readConcern.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-out.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-write-readPreference.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters-clientError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-collation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-clientError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-serverError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-hint-unacknowledged.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-hint-unacknowledged.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-errorResponse.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-insertOne-dots_and_dollars.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-dots_and_dollars.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-hint-unacknowledged.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-sort.json create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-sort.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-clientError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-serverError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-validation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-dots_and_dollars.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-hint-unacknowledged.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-dots_and_dollars.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-hint-unacknowledged.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-sort.json create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-sort.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/count-collation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/count-empty.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/count.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/countDocuments-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/db-aggregate-write-readPreference.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/db-aggregate.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-collation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-clientError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-serverError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-unacknowledged.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-collation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-errorResponse.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-clientError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-serverError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-unacknowledged.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/distinct-collation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/distinct-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/distinct.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-clientError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-serverError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/find-collation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/find-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/find-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/find.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-collation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-clientError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-serverError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-unacknowledged.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-collation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-dots_and_dollars.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-clientError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-serverError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-unacknowledged.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-upsert.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-arrayFilters.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-collation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-dots_and_dollars.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-errorResponse.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-clientError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-serverError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-unacknowledged.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertMany-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertMany-dots_and_dollars.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertMany.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertOne-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertOne-dots_and_dollars.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertOne-errorResponse.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertOne.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-collation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-dots_and_dollars.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint-unacknowledged.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-sort.json create mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-sort.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-validation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-arrayFilters.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-collation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-dots_and_dollars.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-clientError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-serverError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-unacknowledged.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-hint.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-validation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-arrayFilters.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-collation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-comment.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-dots_and_dollars.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-errorResponse.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-clientError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-serverError.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-unacknowledged.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-hint.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-let.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-sort.json create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-sort.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-validation.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne.yml create mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateWithPipelines.yml diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-allowdiskuse.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-allowdiskuse.yml new file mode 100644 index 00000000000..d9d25562052 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/aggregate-allowdiskuse.yml @@ -0,0 +1,75 @@ +description: aggregate-allowdiskuse + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: [] + +tests: + - description: 'Aggregate does not send allowDiskUse when value is not specified' + operations: + - object: *collection0 + name: aggregate + arguments: + pipeline: &pipeline [ { $match: {} } ] + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *pipeline + allowDiskUse: { $$exists: false } + commandName: aggregate + databaseName: *database0Name + + - description: 'Aggregate sends allowDiskUse false when false is specified' + operations: + - object: *collection0 + name: aggregate + arguments: + pipeline: *pipeline + allowDiskUse: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *pipeline + allowDiskUse: false + commandName: aggregate + databaseName: *database0Name + + - description: 'Aggregate sends allowDiskUse true when true is specified' + operations: + - object: *collection0 + name: aggregate + arguments: + pipeline: *pipeline + allowDiskUse: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *pipeline + allowDiskUse: true + commandName: aggregate + databaseName: *database0Name diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-collation.yml new file mode 100644 index 00000000000..088dc5705b2 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/aggregate-collation.yml @@ -0,0 +1,48 @@ +description: aggregate-collation + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '3.4' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: ping } + +tests: + - + description: 'Aggregate with collation' + operations: + - + object: *collection0 + name: aggregate + arguments: + pipeline: + - { $match: { x: PING } } + # https://www.mongodb.com/docs/manual/reference/collation/#collation-document + collation: + locale: en_US + strength: 2 + expectResult: + - { _id: 1, x: ping } diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-let.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-let.yml new file mode 100644 index 00000000000..7fa1f9b798e --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/aggregate-let.yml @@ -0,0 +1,138 @@ +description: "aggregate-let" + +schemaVersion: "1.4" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + - collection: + id: &collection1 collection1 + database: *database0 + collectionName: &collection1Name coll1 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - collectionName: *collection1Name + databaseName: *database0Name + documents: [ ] + +tests: + - description: "Aggregate with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: aggregate + object: *collection0 + arguments: + pipeline: &pipeline0 + # $match takes a query expression, so $expr is necessary to utilize + # an aggregate expression context and access "let" variables. + - $match: { $expr: { $eq: ["$_id", "$$id"] } } + - $project: { _id: 0, x: "$$x", y: "$$y", rand: "$$rand" } + # Values in "let" must be constant or closed expressions that do not + # depend on document values. This test demonstrates a basic constant + # value, a value wrapped with $literal (to avoid expression parsing), + # and a closed expression (e.g. $rand). + let: &let0 + id: 1 + x: foo + y: { $literal: "$bar" } + rand: { $rand: {} } + expectResult: + - { x: "foo", y: "$bar", rand: { $$type: "double" } } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *pipeline0 + let: *let0 + + - description: "Aggregate with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "2.6.0" + maxServerVersion: "4.4.99" + operations: + - name: aggregate + object: *collection0 + arguments: + pipeline: &pipeline1 + - $match: { _id: 1 } + let: &let1 + x: foo + expectError: + # Older server versions may not report an error code, but the error + # message is consistent between 2.6.x and 4.4.x server versions. + errorContains: "unrecognized field 'let'" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *pipeline1 + let: *let1 + + - description: "Aggregate to collection with let option" + runOnRequirements: + - minServerVersion: "5.0" + serverless: "forbid" + operations: + - name: aggregate + object: *collection0 + arguments: + pipeline: &pipeline2 + - $match: { $expr: { $eq: ["$_id", "$$id"] } } + - $project: { _id: 1 } + - $out: *collection1Name + let: &let2 + id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *pipeline2 + let: *let2 + outcome: + - collectionName: *collection1Name + databaseName: *database0Name + documents: + - { _id: 1 } + + - description: "Aggregate to collection with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "2.6.0" + maxServerVersion: "4.4.99" + operations: + - name: aggregate + object: *collection0 + arguments: + pipeline: *pipeline2 + let: *let2 + expectError: + errorContains: "unrecognized field 'let'" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *pipeline2 + let: *let2 diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-merge-errorResponse.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-merge-errorResponse.yml new file mode 100644 index 00000000000..5fd679bffb2 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/aggregate-merge-errorResponse.yml @@ -0,0 +1,42 @@ +description: "aggregate-merge-errorResponse" + +schemaVersion: "1.12" + +createEntities: + - client: + id: &client0 client0 + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name test + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 1 } + - { _id: 2, x: 1 } + +tests: + - description: "aggregate $merge DuplicateKey error is accessible" + runOnRequirements: + - minServerVersion: "5.1" # SERVER-59097 + # Exclude sharded topologies since the aggregate command fails with + # IllegalOperation(20) instead of DuplicateKey(11000) + topologies: [ single, replicaset ] + operations: + - name: aggregate + object: *database0 + arguments: + pipeline: + - { $documents: [ { _id: 2, x: 1 } ] } + - { $merge: { into: *collection0Name, whenMatched: "fail" } } + expectError: + errorCode: 11000 # DuplicateKey + errorResponse: + keyPattern: { _id: 1 } + keyValue: { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-merge.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-merge.yml new file mode 100644 index 00000000000..48dd54d1bd2 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/aggregate-merge.yml @@ -0,0 +1,182 @@ +description: aggregate-merge +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.1.11 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_aggregate_merge + - + collection: + id: &collection_readConcern_majority collection_readConcern_majority + database: database0 + collectionName: *collection_name + collectionOptions: + readConcern: { level: "majority" } + - + collection: + id: &collection_readConcern_local collection_readConcern_local + database: database0 + collectionName: *collection_name + collectionOptions: + readConcern: { level: "local" } + - + collection: + id: &collection_readConcern_available collection_readConcern_available + database: database0 + collectionName: *collection_name + collectionOptions: + readConcern: { level: "available" } +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 +tests: + - + description: 'Aggregate with $merge' + operations: + - + object: *collection0 + name: aggregate + arguments: &arguments + pipeline: &pipeline + - + $sort: + x: 1 + - + $match: + _id: + $gt: 1 + - + $merge: + into: &output_collection other_test_collection + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: *pipeline + outcome: &outcome + - + collectionName: *output_collection + databaseName: *database_name + documents: + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + description: 'Aggregate with $merge and batch size of 0' + operations: + - + object: *collection0 + name: aggregate + arguments: + pipeline: &pipeline + - + $sort: + x: 1 + - + $match: + _id: + $gt: 1 + - + $merge: + into: &output_collection other_test_collection + batchSize: 0 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: *pipeline + cursor: { } + outcome: *outcome + - + description: 'Aggregate with $merge and majority readConcern' + operations: + - + object: *collection_readConcern_majority + name: aggregate + arguments: *arguments + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: *pipeline + readConcern: + level: majority + outcome: *outcome + - + description: 'Aggregate with $merge and local readConcern' + operations: + - + object: *collection_readConcern_local + name: aggregate + arguments: *arguments + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: *pipeline + readConcern: + level: local + outcome: *outcome + - + description: 'Aggregate with $merge and available readConcern' + operations: + - + object: *collection_readConcern_available + name: aggregate + arguments: *arguments + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: *pipeline + readConcern: + level: available + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-out-readConcern.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-out-readConcern.yml new file mode 100644 index 00000000000..67bdee676a5 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/aggregate-out-readConcern.yml @@ -0,0 +1,168 @@ +description: aggregate-out-readConcern +schemaVersion: '1.4' +runOnRequirements: + - + minServerVersion: 4.1.0 + topologies: + - replicaset + - sharded + serverless: "forbid" +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_aggregate_out_readconcern + - + collection: + id: &collection_readConcern_majority collection_readConcern_majority + database: database0 + collectionName: *collection_name + collectionOptions: + readConcern: { level: "majority" } + - + collection: + id: &collection_readConcern_local collection_readConcern_local + database: database0 + collectionName: *collection_name + collectionOptions: + readConcern: { level: "local" } + - + collection: + id: &collection_readConcern_available collection_readConcern_available + database: database0 + collectionName: *collection_name + collectionOptions: + readConcern: { level: "available" } + - + collection: + id: &collection_readConcern_linearizable collection_readConcern_linearizable + database: database0 + collectionName: *collection_name + collectionOptions: + readConcern: { level: "linearizable" } +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 +tests: + - + description: 'readConcern majority with out stage' + operations: + - + object: *collection_readConcern_majority + name: aggregate + arguments: &arguments + pipeline: + - + $sort: + x: 1 + - + $match: + _id: + $gt: 1 + - + $out: &output_collection other_test_collection + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: &pipeline + - { $sort: { x: 1 } } + - { $match: { _id: { $gt: 1 } } } + - { $out: other_test_collection } + readConcern: + level: majority + outcome: &outcome + - + collectionName: *output_collection + databaseName: *database_name + documents: + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + description: 'readConcern local with out stage' + operations: + - + object: *collection_readConcern_local + name: aggregate + arguments: *arguments + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: *pipeline + readConcern: + level: local + outcome: *outcome + - + description: 'readConcern available with out stage' + operations: + - + object: *collection_readConcern_available + name: aggregate + arguments: *arguments + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: *pipeline + readConcern: + level: available + outcome: *outcome + - + description: 'readConcern linearizable with out stage' + operations: + - + object: *collection_readConcern_linearizable + name: aggregate + arguments: *arguments + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: *pipeline + readConcern: + level: linearizable diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-out.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-out.yml new file mode 100644 index 00000000000..a85eed03220 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/aggregate-out.yml @@ -0,0 +1,72 @@ +description: aggregate-out + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '2.6' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - + description: 'Aggregate with $out' + operations: + - + object: *collection0 + name: aggregate + arguments: + pipeline: + - { $sort: { x: 1 } } + - { $match: { _id: { $gt: 1 } } } + - { $out: other_test_collection } + batchSize: 2 + outcome: + - + collectionName: other_test_collection + databaseName: *database_name + documents: + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - + description: 'Aggregate with $out and batch size of 0' + operations: + - + object: *collection0 + name: aggregate + arguments: + pipeline: + - { $sort: { x: 1 } } + - { $match: { _id: { $gt: 1 } } } + - { $out: other_test_collection } + batchSize: 0 + outcome: + - + collectionName: other_test_collection + databaseName: *database_name + documents: + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-write-readPreference.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-write-readPreference.yml new file mode 100644 index 00000000000..16f1035752d --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/aggregate-write-readPreference.yml @@ -0,0 +1,143 @@ +description: aggregate-write-readPreference + +schemaVersion: '1.4' + +runOnRequirements: + # 3.6+ non-standalone is needed to utilize $readPreference in OP_MSG + - minServerVersion: "3.6" + topologies: [ replicaset, sharded, load-balanced ] + +_yamlAnchors: + readConcern: &readConcern + level: &readConcernLevel "local" + writeConcern: &writeConcern + w: &writeConcernW 1 + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + # Used to test that read and write concerns are still inherited + uriOptions: + readConcernLevel: *readConcernLevel + w: *writeConcernW + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + readPreference: &readPreference + # secondaryPreferred is specified for compatibility with clusters that + # may not have a secondary (e.g. each shard is only a primary). + mode: secondaryPreferred + # maxStalenessSeconds is specified to ensure that drivers forward the + # read preference to mongos or a load balancer. That would not be the + # case with only secondaryPreferred. + maxStalenessSeconds: 600 + - collection: + id: &collection1 collection1 + database: *database0 + collectionName: &collection1Name coll1 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: "Aggregate with $out includes read preference for 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + serverless: "forbid" + operations: + - object: *collection0 + name: aggregate + arguments: + pipeline: &outPipeline + - { $match: { _id: { $gt: 1 } } } + - { $sort: { x: 1 } } + - { $out: *collection1Name } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *outPipeline + $readPreference: *readPreference + readConcern: *readConcern + writeConcern: *writeConcern + + - description: "Aggregate with $out omits read preference for pre-5.0 server" + runOnRequirements: + # MongoDB 4.2 introduced support for read concerns and write stages. + # Pre-4.2 servers may allow a "local" read concern anyway, but some + # drivers may avoid inheriting a client-level read concern for pre-4.2. + - minServerVersion: "4.2" + maxServerVersion: "4.4.99" + serverless: "forbid" + operations: + - object: *collection0 + name: aggregate + arguments: + pipeline: *outPipeline + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *outPipeline + $readPreference: { $$exists: false } + readConcern: *readConcern + writeConcern: *writeConcern + + - description: "Aggregate with $merge includes read preference for 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - object: *collection0 + name: aggregate + arguments: + pipeline: &mergePipeline + - { $match: { _id: { $gt: 1 } } } + - { $sort: { x: 1 } } + - { $merge: { into: *collection1Name } } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *mergePipeline + $readPreference: *readPreference + readConcern: *readConcern + writeConcern: *writeConcern + + - description: "Aggregate with $merge omits read preference for pre-5.0 server" + runOnRequirements: + - minServerVersion: "4.2" + maxServerVersion: "4.4.99" + operations: + - object: *collection0 + name: aggregate + arguments: + pipeline: *mergePipeline + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *mergePipeline + $readPreference: { $$exists: false } + readConcern: *readConcern + writeConcern: *writeConcern diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate.yml new file mode 100644 index 00000000000..6f99aaf0fe5 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/aggregate.yml @@ -0,0 +1,232 @@ +description: "aggregate" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: true # ensure cursors pin to a single server + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name aggregate-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - { _id: 5, x: 55 } + - { _id: 6, x: 66 } + +tests: + - description: "aggregate with multiple batches works" + operations: + - name: aggregate + arguments: + pipeline: [ { $match: { _id: { $gt: 1 } }} ] + batchSize: 2 + object: *collection0 + expectResult: + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - { _id: 5, x: 55 } + - { _id: 6, x: 66 } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: [ { $match: { _id: { $gt: 1 } }} ] + cursor: { batchSize: 2 } + commandName: aggregate + databaseName: *database0Name + - commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection0Name + batchSize: 2 + commandName: getMore + databaseName: *database0Name + - commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection0Name + batchSize: 2 + commandName: getMore + databaseName: *database0Name + + - description: "aggregate with a string comment" + runOnRequirements: + - minServerVersion: "3.6.0" + operations: + - name: aggregate + arguments: + pipeline: [ { $match: { _id: { $gt: 1 } }} ] + comment: "comment" + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: [ { $match: { _id: { $gt: 1 } } } ] + comment: "comment" + + - description: "aggregate with a document comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: aggregate + arguments: + pipeline: [ { $match: { _id: { $gt: 1 } }} ] + comment: &comment0 { content: "test" } + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: [ { $match: { _id: { $gt: 1 } } } ] + comment: *comment0 + + - description: "aggregate with a document comment - pre 4.4" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.2.99" + operations: + - name: aggregate + object: *collection0 + arguments: + pipeline: [ { $match: { _id: { $gt: 1 } }} ] + comment: *comment0 + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: [ { $match: { _id: { $gt: 1 } }} ] + comment: *comment0 + commandName: aggregate + databaseName: *database0Name + + - description: "aggregate with comment sets comment on getMore" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - name: aggregate + arguments: + pipeline: [ { $match: { _id: { $gt: 1 } }} ] + batchSize: 2 + comment: *comment0 + object: *collection0 + expectResult: + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - { _id: 5, x: 55 } + - { _id: 6, x: 66 } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: [ { $match: { _id: { $gt: 1 } }} ] + cursor: { batchSize: 2 } + comment: *comment0 + commandName: aggregate + databaseName: *database0Name + - commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection0Name + batchSize: 2 + comment: *comment0 + commandName: getMore + databaseName: *database0Name + - commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection0Name + batchSize: 2 + comment: *comment0 + commandName: getMore + databaseName: *database0Name + + - description: "aggregate with comment does not set comment on getMore - pre 4.4" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.3.99" + operations: + - name: aggregate + arguments: + pipeline: [ { $match: { _id: { $gt: 1 } }} ] + batchSize: 2 + comment: "comment" + object: *collection0 + expectResult: + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - { _id: 5, x: 55 } + - { _id: 6, x: 66 } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: [ { $match: { _id: { $gt: 1 } }} ] + cursor: { batchSize: 2 } + comment: "comment" + commandName: aggregate + databaseName: *database0Name + - commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection0Name + batchSize: 2 + comment: { $$exists: false } + commandName: getMore + databaseName: *database0Name + - commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection0Name + batchSize: 2 + comment: { $$exists: false } + commandName: getMore + databaseName: *database0Name + - + description: 'Aggregate with multiple stages' + operations: + - + object: *collection0 + name: aggregate + arguments: + pipeline: + - { $sort: { x: 1 } } + - { $match: { _id: { $gt: 1 } } } + batchSize: 2 + expectResult: + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - { _id: 5, x: 55 } + - { _id: 6, x: 66 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters-clientError.yml new file mode 100644 index 00000000000..12bc84c704e --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters-clientError.yml @@ -0,0 +1,95 @@ +description: bulkWrite-arrayFilters-clientError +schemaVersion: '1.0' +runOnRequirements: + - + maxServerVersion: 3.5.5 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name crud-v2 +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + 'y': + - + b: 3 + - + b: 1 + - + _id: 2 + 'y': + - + b: 0 + - + b: 1 +tests: + - + description: 'BulkWrite on server that doesn''t support arrayFilters' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + updateOne: + filter: { } + update: + $set: + y.0.b: 2 + arrayFilters: + - + i.b: 1 + ordered: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + - + description: 'BulkWrite on server that doesn''t support arrayFilters with arrayFilters on second op' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + updateOne: + filter: { } + update: + $set: + y.0.b: 2 + - + updateMany: + filter: { } + update: + $set: + 'y.$[i].b': 2 + arrayFilters: + - + i.b: 1 + ordered: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters.yml new file mode 100644 index 00000000000..9db833581f7 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters.yml @@ -0,0 +1,210 @@ +description: bulkWrite-arrayFilters +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 3.5.6 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-tests + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + 'y': + - + b: 3 + - + b: 1 + - + _id: 2 + 'y': + - + b: 0 + - + b: 1 +tests: + - + description: 'BulkWrite updateOne with arrayFilters' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + updateOne: + filter: { } + update: + $set: + 'y.$[i].b': 2 + arrayFilters: + - + i.b: 3 + ordered: true + expectResult: + deletedCount: 0 + insertedCount: 0 + insertedIds: { $$unsetOrMatches: {} } + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + upsertedIds: { } + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { } + u: + $set: { 'y.$[i].b': 2 } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + arrayFilters: + - { i.b: 3 } + ordered: true + commandName: update + databaseName: *database_name + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + 'y': + - + b: 2 + - + b: 1 + - + _id: 2 + 'y': + - + b: 0 + - + b: 1 + - + description: 'BulkWrite updateMany with arrayFilters' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + updateMany: + filter: { } + update: + $set: + 'y.$[i].b': 2 + arrayFilters: + - + i.b: 1 + ordered: true + expectResult: + deletedCount: 0 + insertedCount: 0 + insertedIds: { $$unsetOrMatches: {} } + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + upsertedIds: { } + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { } + u: + $set: { 'y.$[i].b': 2 } + multi: true + upsert: { $$unsetOrMatches: false } + arrayFilters: + - { i.b: 1 } + ordered: true + commandName: update + databaseName: *database_name + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + 'y': + - + b: 3 + - + b: 2 + - + _id: 2 + 'y': + - + b: 0 + - + b: 2 + - + description: 'BulkWrite with arrayFilters' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + # UpdateOne when one document matches arrayFilters + updateOne: + filter: { } + update: { $set: { 'y.$[i].b': 2 } } + arrayFilters: + - { i.b: 3 } + - + # UpdateMany when multiple documents match arrayFilters + updateMany: + filter: { } + update: { $set: { 'y.$[i].b': 2 } } + arrayFilters: + - { i.b: 1 } + ordered: true + expectResult: + deletedCount: 0 + insertedCount: 0 + insertedIds: + $$unsetOrMatches: { } + matchedCount: 3 + modifiedCount: 3 + upsertedCount: 0 + upsertedIds: { } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 2 }, { b: 2 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 2 } ] } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-collation.yml new file mode 100644 index 00000000000..b9b3fc4fe92 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-collation.yml @@ -0,0 +1,130 @@ +description: bulkWrite-collation + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '3.4' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: ping } + - { _id: 3, x: pINg } + - { _id: 4, x: pong } + - { _id: 5, x: pONg } + +# See: https://www.mongodb.com/docs/manual/reference/collation/#collation-document +tests: + - + description: 'BulkWrite with delete operations and collation' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + # matches two documents but deletes one + deleteOne: + filter: { x: "PING" } + collation: { locale: "en_US", strength: 2 } + - + # matches the remaining document and deletes it + deleteOne: + filter: { x: "PING" } + collation: { locale: "en_US", strength: 2 } + - + # matches two documents and deletes them + deleteMany: + filter: { x: "PONG" } + collation: { locale: "en_US", strength: 2 } + ordered: true + expectResult: + deletedCount: 4 + insertedCount: 0 + insertedIds: + $$unsetOrMatches: { } + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + upsertedIds: { } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - + description: 'BulkWrite with update operations and collation' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + # matches only one document due to strength and updates + updateMany: + filter: { x: "ping" } + update: { $set: { x: "PONG" } } + collation: { locale: "en_US", strength: 3 } + - + # matches one document and updates + updateOne: + filter: { x: "ping" } + update: { $set: { x: "PONG" } } + collation: { locale: "en_US", strength: 2 } + - + # matches no document due to strength and upserts + replaceOne: + filter: { x: "ping" } + replacement: { _id: 6, x: "ping" } + upsert: true + collation: { locale: "en_US", strength: 3 } + - + # matches two documents and updates + updateMany: + filter: { x: "pong" } + update: { $set: { x: "PONG" } } + collation: { locale: "en_US", strength: 2 } + ordered: true + expectResult: + deletedCount: 0 + insertedCount: 0 + insertedIds: + $$unsetOrMatches: { } + matchedCount: 6 + modifiedCount: 4 + upsertedCount: 1 + upsertedIds: { '2': 6 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - {_id: 1, x: 11 } + - {_id: 2, x: "PONG" } + - {_id: 3, x: "PONG" } + - {_id: 4, x: "PONG" } + - {_id: 5, x: "PONG" } + - {_id: 6, x: "ping" } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.json b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.json index d88ffb7a33e..0b2addc8505 100644 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.json +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.json @@ -122,7 +122,6 @@ "expectEvents": [ { "client": "client0", - "note": "Events split due to : JAVA-4537 ", "events": [ { "commandStartedEvent": { @@ -158,18 +157,7 @@ "upsert": { "$$unsetOrMatches": false } - } - ], - "ordered": true, - "comment": "comment" - } - } - }, - { - "commandStartedEvent": { - "command": { - "update": "BulkWrite_comment", - "updates": [ + }, { "q": { "_id": 2 @@ -311,7 +299,6 @@ "expectEvents": [ { "client": "client0", - "note": "Events split due to : JAVA-4537 ", "events": [ { "commandStartedEvent": { @@ -349,20 +336,7 @@ "upsert": { "$$unsetOrMatches": false } - } - ], - "ordered": true, - "comment": { - "key": "value" - } - } - } - }, - { - "commandStartedEvent": { - "command": { - "update": "BulkWrite_comment", - "updates": [ + }, { "q": { "_id": 2 diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.yml new file mode 100644 index 00000000000..965a0b8384b --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.yml @@ -0,0 +1,175 @@ +description: bulkWrite-comment +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name BulkWrite_comment + +initialData: &initial_data + - collectionName: *collection_name + databaseName: *database_name + documents: + - _id: 1 + x: 11 + - _id: 2 + x: 22 + - _id: 3 + x: 33 + - _id: 4 + x: 44 + +tests: + - description: 'BulkWrite with string comment' + runOnRequirements: + - minServerVersion: "4.4" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: &requests + - insertOne: + document: &inserted_document + _id: 5 + x: "inserted" + - replaceOne: + filter: &replaceOne_filter + _id: 1 + replacement: &replacement { _id: 1, x: "replaced" } + - updateOne: + filter: &updateOne_filter + _id: 2 + update: &update { $set: {x: "updated"} } + - deleteOne: + filter: &deleteOne_filter + _id: 3 + comment: &string_comment "comment" + expectResult: &expect_results + deletedCount: 1 + insertedCount: 1 + insertedIds: { $$unsetOrMatches: { 0: 5} } + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + upsertedIds: { } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection_name + documents: + - *inserted_document + ordered: true + comment: *string_comment + - commandStartedEvent: + command: + update: *collection_name + updates: + - q: *replaceOne_filter + u: *replacement + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + - q: *updateOne_filter + u: *update + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + ordered: true + comment: *string_comment + - commandStartedEvent: + command: + delete: *collection_name + deletes: + - q: *deleteOne_filter + limit: 1 + ordered: true + comment: *string_comment + outcome: &outcome + - collectionName: *collection_name + databaseName: *database_name + documents: + - _id: 1 + x: "replaced" + - _id: 2 + x: "updated" + - _id: 4 + x: 44 + - _id: 5 + x: "inserted" + + - description: 'BulkWrite with document comment' + runOnRequirements: + - minServerVersion: "4.4" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: *requests + comment: &document_comment { key: "value" } + expectResult: *expect_results + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection_name + documents: + - *inserted_document + ordered: true + comment: *document_comment + - commandStartedEvent: + command: + update: *collection_name + updates: + - q: *replaceOne_filter + u: *replacement + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + - q: *updateOne_filter + u: *update + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + ordered: true + comment: *document_comment + - commandStartedEvent: + command: + delete: *collection_name + deletes: + - q: *deleteOne_filter + limit: 1 + ordered: true + comment: *document_comment + outcome: *outcome + + - description: 'BulkWrite with comment - pre 4.4' + runOnRequirements: + - minServerVersion: "3.4.0" + maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: *requests + comment: "comment" + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection_name + documents: + - *inserted_document + ordered: true + comment: "comment" + outcome: *initial_data diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-clientError.yml new file mode 100644 index 00000000000..5c172610046 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-clientError.yml @@ -0,0 +1,110 @@ +description: bulkWrite-delete-hint-clientError +schemaVersion: '1.0' +runOnRequirements: + - + maxServerVersion: 3.3.99 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name BulkWrite_delete_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 +tests: + - + description: 'BulkWrite deleteOne with hints unsupported (client-side error)' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + deleteOne: + filter: &deleteOne_filter1 + _id: 1 + hint: &hint_string _id_ + - + deleteOne: + filter: &deleteOne_filter2 + _id: 2 + hint: &hint_doc + _id: 1 + ordered: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 + - + description: 'BulkWrite deleteMany with hints unsupported (client-side error)' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + deleteMany: + filter: &deleteMany_filter1 + _id: + $lt: 3 + hint: *hint_string + - + deleteMany: + filter: &deleteMany_filter2 + _id: + $gte: 4 + hint: *hint_doc + ordered: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-serverError.yml new file mode 100644 index 00000000000..06ad7787a7a --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-serverError.yml @@ -0,0 +1,139 @@ +description: bulkWrite-delete-hint-serverError +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 3.4.0 + maxServerVersion: 4.3.3 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name BulkWrite_delete_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 +tests: + - + description: 'BulkWrite deleteOne with hints unsupported (server-side error)' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + deleteOne: + filter: &deleteOne_filter1 + _id: 1 + hint: &hint_string _id_ + - + deleteOne: + filter: &deleteOne_filter2 + _id: 2 + hint: &hint_doc + _id: 1 + ordered: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: *deleteOne_filter1 + hint: *hint_string + limit: 1 + - + q: *deleteOne_filter2 + hint: *hint_doc + limit: 1 + ordered: true + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 + - + description: 'BulkWrite deleteMany with hints unsupported (server-side error)' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + deleteMany: + filter: &deleteMany_filter1 + _id: + $lt: 3 + hint: *hint_string + - + deleteMany: + filter: &deleteMany_filter2 + _id: + $gte: 4 + hint: *hint_doc + ordered: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: *deleteMany_filter1 + hint: *hint_string + limit: 0 + - + q: *deleteMany_filter2 + hint: *hint_doc + limit: 0 + ordered: true + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint.yml new file mode 100644 index 00000000000..ac451bfc466 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint.yml @@ -0,0 +1,151 @@ +description: bulkWrite-delete-hint +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.3.4 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name BulkWrite_delete_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 +tests: + - + description: 'BulkWrite deleteOne with hints' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + deleteOne: + filter: &deleteOne_filter1 + _id: 1 + hint: &hint_string _id_ + - + deleteOne: + filter: &deleteOne_filter2 + _id: 2 + hint: &hint_doc + _id: 1 + ordered: true + expectResult: + deletedCount: 2 + insertedCount: 0 + insertedIds: { $$unsetOrMatches: {} } + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + upsertedIds: { } + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: *deleteOne_filter1 + hint: *hint_string + limit: 1 + - + q: *deleteOne_filter2 + hint: *hint_doc + limit: 1 + ordered: true + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 + - + description: 'BulkWrite deleteMany with hints' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + deleteMany: + filter: &deleteMany_filter1 + _id: + $lt: 3 + hint: *hint_string + - + deleteMany: + filter: &deleteMany_filter2 + _id: + $gte: 4 + hint: *hint_doc + ordered: true + expectResult: + deletedCount: 3 + insertedCount: 0 + insertedIds: { $$unsetOrMatches: {} } + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + upsertedIds: { } + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: *deleteMany_filter1 + hint: *hint_string + limit: 0 + - + q: *deleteMany_filter2 + hint: *hint_doc + limit: 0 + ordered: true + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 3 + x: 33 diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-hint-unacknowledged.yml new file mode 100644 index 00000000000..aa2cdbce922 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-hint-unacknowledged.yml @@ -0,0 +1,98 @@ +description: bulkWrite-deleteMany-hint-unacknowledged + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + writeConcern: { w: 0 } + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: &documents + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: "Unacknowledged deleteMany with hint string fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteMany: + filter: &filter { _id: { $gt: 1 } } + hint: _id_ + expectError: + isClientError: true + expectEvents: &noEvents + - client: *client0 + events: [] + + - description: "Unacknowledged deleteMany with hint document fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteMany: + filter: *filter + hint: { _id: 1 } + expectError: + isClientError: true + expectEvents: *noEvents + + - description: "Unacknowledged deleteMany with hint string on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteMany: + filter: *filter + hint: _id_ + expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } + expectEvents: &events + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + hint: { $$type: [ string, object ]} + limit: 0 + writeConcern: { w: 0 } + + - description: "Unacknowledged deleteMany with hint document on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteMany: + filter: *filter + hint: { _id: 1 } + expectResult: *unacknowledgedResult + expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-let.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-let.yml new file mode 100644 index 00000000000..48b3a06d2e7 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-let.yml @@ -0,0 +1,86 @@ +description: "BulkWrite deleteMany-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "BulkWrite deleteMany with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteMany: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + let: &let + id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 0 + let: *let + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 2 } + + - description: "BulkWrite deleteMany with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.4.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteOne: + filter: *filter + let: *let + expectError: + errorContains: "'delete.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 1 + let: *let + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-hint-unacknowledged.yml new file mode 100644 index 00000000000..820697008e5 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-hint-unacknowledged.yml @@ -0,0 +1,97 @@ +description: bulkWrite-deleteOne-hint-unacknowledged + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + writeConcern: { w: 0 } + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: &documents + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + +tests: + - description: "Unacknowledged deleteOne with hint string fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteOne: + filter: &filter { _id: { $gt: 1 } } + hint: _id_ + expectError: + isClientError: true + expectEvents: &noEvents + - client: *client0 + events: [] + + - description: "Unacknowledged deleteOne with hint document fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteOne: + filter: *filter + hint: { _id: 1 } + expectError: + isClientError: true + expectEvents: *noEvents + + - description: "Unacknowledged deleteOne with hint string on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteOne: + filter: *filter + hint: _id_ + expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } + expectEvents: &events + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + hint: { $$type: [ string, object ]} + limit: 1 + writeConcern: { w: 0 } + + - description: "Unacknowledged deleteOne with hint document on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteOne: + filter: *filter + hint: { _id: 1 } + expectResult: *unacknowledgedResult + expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-let.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-let.yml new file mode 100644 index 00000000000..128d74a4415 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-let.yml @@ -0,0 +1,86 @@ +description: "BulkWrite deleteOne-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "BulkWrite deleteOne with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteOne: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + let: &let + id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 1 + let: *let + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 2 } + + - description: "BulkWrite deleteOne with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.9" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteOne: + filter: *filter + let: *let + expectError: + errorContains: "'delete.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 1 + let: *let + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-errorResponse.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-errorResponse.yml new file mode 100644 index 00000000000..d4f335dfd33 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-errorResponse.yml @@ -0,0 +1,50 @@ +description: "bulkWrite-errorResponse" + +schemaVersion: "1.12" + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name test + +tests: + # This test intentionally executes only a single insert operation in the bulk + # write to make the error code and response assertions less ambiguous. That + # said, some drivers may still need to skip this test because the CRUD spec + # does not prescribe how drivers should formulate a BulkWriteException beyond + # collecting write and write concern errors. + - description: "bulkWrite operations support errorResponse assertions" + runOnRequirements: + - minServerVersion: "4.0.0" + topologies: [ single, replicaset ] + - minServerVersion: "4.2.0" + topologies: [ sharded ] + operations: + - name: failPoint + object: testRunner + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: [ insert ] + errorCode: &errorCode 8 # UnknownError + - name: bulkWrite + object: *collection0 + arguments: + requests: + - insertOne: + document: { _id: 1 } + expectError: + errorCode: *errorCode + errorResponse: + code: *errorCode diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-insertOne-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-insertOne-dots_and_dollars.yml new file mode 100644 index 00000000000..de3885ac8ce --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-insertOne-dots_and_dollars.yml @@ -0,0 +1,138 @@ +description: "bulkWrite-insertOne-dots_and_dollars" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: [] + +tests: + - description: "Inserting document with top-level dollar-prefixed key on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - insertOne: + document: &dollarPrefixedKey { _id: 1, $a: 1 } + expectResult: &bulkWriteResult + deletedCount: 0 + insertedCount: 1 + insertedIds: { $$unsetOrMatches: { 0: 1 } } + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + upsertedIds: { } + expectEvents: &expectEventsDollarPrefixedKey + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dollarPrefixedKey + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dollarPrefixedKey + + - description: "Inserting document with top-level dollar-prefixed key on pre-5.0 server yields server-side error" + runOnRequirements: + - maxServerVersion: "4.99" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - insertOne: + document: *dollarPrefixedKey + expectError: + isClientError: false + expectEvents: *expectEventsDollarPrefixedKey + outcome: *initialData + + - description: "Inserting document with top-level dotted key" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - insertOne: + document: &dottedKey { _id: 1, a.b: 1 } + expectResult: *bulkWriteResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dottedKey + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dottedKey + + - description: "Inserting document with dollar-prefixed key in embedded doc" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - insertOne: + document: &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } } + expectResult: *bulkWriteResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dollarPrefixedKeyInEmbedded + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dollarPrefixedKeyInEmbedded + + - description: "Inserting document with dotted key in embedded doc" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - insertOne: + document: &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } } + expectResult: *bulkWriteResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dottedKeyInEmbedded + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dottedKeyInEmbedded diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-dots_and_dollars.yml new file mode 100644 index 00000000000..65c414c1d6d --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-dots_and_dollars.yml @@ -0,0 +1,165 @@ +description: "bulkWrite-replaceOne-dots_and_dollars" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + +tests: + - description: "Replacing document with top-level dotted key on 3.6+ server" + runOnRequirements: + - minServerVersion: "3.6" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - replaceOne: + filter: { _id: 1 } + replacement: &dottedKey { _id: 1, a.b: 1 } + expectResult: &bulkWriteResult + deletedCount: 0 + insertedCount: 0 + insertedIds: { $$unsetOrMatches: { } } + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + upsertedIds: { } + expectEvents: &expectEventsDottedKey + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dottedKey + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dottedKey + + - description: "Replacing document with top-level dotted key on pre-3.6 server yields server-side error" + runOnRequirements: + - maxServerVersion: "3.4.99" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - replaceOne: + filter: { _id: 1 } + replacement: *dottedKey + expectError: + isClientError: false + expectEvents: *expectEventsDottedKey + outcome: *initialData + + - description: "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - replaceOne: + filter: { _id: 1 } + replacement: &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } } + expectResult: *bulkWriteResult + expectEvents: &expectEventsDollarPrefixedKeyInEmbedded + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dollarPrefixedKeyInEmbedded + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dollarPrefixedKeyInEmbedded + + - description: "Replacing document with dollar-prefixed key in embedded doc on pre-5.0 server yields server-side error" + runOnRequirements: + - maxServerVersion: "4.99" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - replaceOne: + filter: { _id: 1 } + replacement: *dollarPrefixedKeyInEmbedded + expectError: + isClientError: false + expectEvents: *expectEventsDollarPrefixedKeyInEmbedded + outcome: *initialData + + - description: "Replacing document with dotted key in embedded doc on 3.6+ server" + runOnRequirements: + - minServerVersion: "3.6" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - replaceOne: + filter: { _id: 1 } + replacement: &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } } + expectResult: *bulkWriteResult + expectEvents: &expectEventsDottedKeyInEmbedded + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dottedKeyInEmbedded + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dottedKeyInEmbedded + + - description: "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error" + runOnRequirements: + - maxServerVersion: "3.4.99" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - replaceOne: + filter: { _id: 1 } + replacement: *dottedKeyInEmbedded + expectError: + isClientError: false + expectEvents: *expectEventsDottedKeyInEmbedded + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-hint-unacknowledged.yml new file mode 100644 index 00000000000..d656c5fc6b6 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-hint-unacknowledged.yml @@ -0,0 +1,103 @@ +description: bulkWrite-replaceOne-hint-unacknowledged + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + writeConcern: { w: 0 } + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: &documents + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + +tests: + - description: "Unacknowledged replaceOne with hint string fails with client-side error on pre-4.2 server" + runOnRequirements: + - maxServerVersion: "4.0.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - replaceOne: + filter: &filter { _id: { $gt: 1 } } + replacement: &replacement { x: 111 } + hint: _id_ + expectError: + isClientError: true + expectEvents: &noEvents + - client: *client0 + events: [] + + - description: "Unacknowledged replaceOne with hint document fails with client-side error on pre-4.2 server" + runOnRequirements: + - maxServerVersion: "4.0.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - replaceOne: + filter: *filter + replacement: *replacement + hint: { _id: 1 } + expectError: + isClientError: true + expectEvents: *noEvents + + - description: "Unacknowledged replaceOne with hint string on 4.2+ server" + runOnRequirements: + - minServerVersion: "4.2.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - replaceOne: + filter: *filter + replacement: *replacement + hint: _id_ + expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } + expectEvents: &events + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *replacement + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + hint: { $$type: [ string, object ]} + writeConcern: { w: 0 } + + - description: "Unacknowledged replaceOne with hint document on 4.2+ server" + runOnRequirements: + - minServerVersion: "4.2.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - replaceOne: + filter: *filter + replacement: *replacement + hint: { _id: 1 } + expectResult: *unacknowledgedResult + expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-let.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-let.yml new file mode 100644 index 00000000000..5453868ba4c --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-let.yml @@ -0,0 +1,93 @@ +description: "BulkWrite replaceOne-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "BulkWrite replaceOne with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - replaceOne: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + replacement: &replacement {"x": 3} + let: &let + id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *replacement + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + let: *let + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 3 } + - { _id: 2 } + + - description: "BulkWrite replaceOne with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "4.2" + maxServerVersion: "4.9" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - replaceOne: + filter: *filter + replacement: *replacement + let: *let + expectError: + errorContains: "'update.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *replacement + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + let: *let + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-sort.json b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-sort.json new file mode 100644 index 00000000000..c0bd3835142 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-sort.json @@ -0,0 +1,239 @@ +{ + "description": "BulkWrite replaceOne-sort", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent", + "commandSucceededEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ], + "tests": [ + { + "description": "BulkWrite replaceOne with sort option", + "runOnRequirements": [ + { + "minServerVersion": "8.0" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "replaceOne": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "sort": { + "_id": -1 + }, + "replacement": { + "x": 1 + } + } + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": { + "$gt": 1 + } + }, + "u": { + "x": 1 + }, + "sort": { + "_id": -1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + } + } + }, + { + "commandSucceededEvent": { + "reply": { + "ok": 1, + "n": 1 + }, + "commandName": "update" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 1 + } + ] + } + ] + }, + { + "description": "BulkWrite replaceOne with sort option unsupported (server-side error)", + "runOnRequirements": [ + { + "maxServerVersion": "7.99" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "replaceOne": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "sort": { + "_id": -1 + }, + "replacement": { + "x": 1 + } + } + } + ] + }, + "expectError": { + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": { + "$gt": 1 + } + }, + "u": { + "x": 1 + }, + "sort": { + "_id": -1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + } + ] +} diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-sort.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-sort.yml new file mode 100644 index 00000000000..6f326fe043c --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-sort.yml @@ -0,0 +1,94 @@ +description: BulkWrite replaceOne-sort + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent, commandSucceededEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: BulkWrite replaceOne with sort option + runOnRequirements: + - minServerVersion: "8.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - replaceOne: + filter: { _id: { $gt: 1 } } + sort: { _id: -1 } + replacement: { x: 1 } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: { $gt: 1 } } + u: { x: 1 } + sort: { _id: -1 } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + - commandSucceededEvent: + reply: { ok: 1, n: 1 } + commandName: update + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 1 } + + - description: BulkWrite replaceOne with sort option unsupported (server-side error) + runOnRequirements: + - maxServerVersion: "7.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - replaceOne: + filter: { _id: { $gt: 1 } } + sort: { _id: -1 } + replacement: { x: 1 } + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: { $gt: 1 } } + u: { x: 1 } + sort: { _id: -1 } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-clientError.yml new file mode 100644 index 00000000000..cf75a7c450f --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-clientError.yml @@ -0,0 +1,145 @@ +description: bulkWrite-update-hint-clientError +schemaVersion: '1.0' +runOnRequirements: + - + maxServerVersion: 3.3.99 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_bulkwrite_update_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 +tests: + - + description: 'BulkWrite updateOne with update hints unsupported (client-side error)' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + updateOne: + filter: &updateOne_filter + _id: 1 + update: &updateOne_update + $inc: + x: 1 + hint: &hint_string _id_ + - + updateOne: + filter: *updateOne_filter + update: *updateOne_update + hint: &hint_doc + _id: 1 + ordered: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 + - + description: 'BulkWrite updateMany with update hints unsupported (client-side error)' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + updateMany: + filter: &updateMany_filter + _id: + $lt: 3 + update: &updateMany_update + $inc: + x: 1 + hint: *hint_string + - + updateMany: + filter: *updateMany_filter + update: *updateMany_update + hint: *hint_doc + ordered: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: *outcome + - + description: 'BulkWrite replaceOne with update hints unsupported (client-side error)' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + replaceOne: + filter: + _id: 3 + replacement: + x: 333 + hint: *hint_string + - + replaceOne: + filter: + _id: 4 + replacement: + x: 444 + hint: *hint_doc + ordered: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-serverError.yml new file mode 100644 index 00000000000..64310a2eaff --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-serverError.yml @@ -0,0 +1,236 @@ +description: bulkWrite-update-hint-serverError +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 3.4.0 + maxServerVersion: 4.1.9 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_bulkwrite_update_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 +tests: + - + description: 'BulkWrite updateOne with update hints unsupported (server-side error)' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + updateOne: + filter: &updateOne_filter + _id: 1 + update: &updateOne_update + $inc: + x: 1 + hint: &hint_string _id_ + - + updateOne: + filter: *updateOne_filter + update: *updateOne_update + hint: &hint_doc + _id: 1 + ordered: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *updateOne_filter + u: *updateOne_update + hint: *hint_string + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + - + q: *updateOne_filter + u: *updateOne_update + hint: *hint_doc + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + ordered: true + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 + - + description: 'BulkWrite updateMany with update hints unsupported (server-side error)' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + updateMany: + filter: &updateMany_filter + _id: + $lt: 3 + update: &updateMany_update + $inc: + x: 1 + hint: *hint_string + - + updateMany: + filter: *updateMany_filter + update: *updateMany_update + hint: *hint_doc + ordered: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *updateMany_filter + u: *updateMany_update + multi: true + hint: *hint_string + upsert: { $$unsetOrMatches: false } + - + q: *updateMany_filter + u: *updateMany_update + multi: true + hint: *hint_doc + upsert: { $$unsetOrMatches: false } + ordered: true + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 + - + description: 'BulkWrite replaceOne with update hints unsupported (server-side error)' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + replaceOne: + filter: + _id: 3 + replacement: + x: 333 + hint: *hint_string + - + replaceOne: + filter: + _id: 4 + replacement: + x: 444 + hint: *hint_doc + ordered: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: + _id: 3 + u: + x: 333 + hint: *hint_string + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + - + q: + _id: 4 + u: + x: 444 + hint: *hint_doc + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + ordered: true + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint.yml new file mode 100644 index 00000000000..e739074ea26 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint.yml @@ -0,0 +1,253 @@ +description: bulkWrite-update-hint +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.2.0 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_bulkwrite_update_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 +tests: + - + description: 'BulkWrite updateOne with update hints' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + updateOne: + filter: &updateOne_filter + _id: 1 + update: &updateOne_update + $inc: + x: 1 + hint: &hint_string _id_ + - + updateOne: + filter: *updateOne_filter + update: *updateOne_update + hint: &hint_doc + _id: 1 + ordered: true + expectResult: + deletedCount: 0 + insertedCount: 0 + insertedIds: { $$unsetOrMatches: {} } + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + upsertedIds: { } + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *updateOne_filter + u: *updateOne_update + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + hint: *hint_string + - + q: *updateOne_filter + u: *updateOne_update + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + hint: *hint_doc + ordered: true + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 13 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 + - + description: 'BulkWrite updateMany with update hints' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + updateMany: + filter: &updateMany_filter + _id: + $lt: 3 + update: &updateMany_update + $inc: + x: 1 + hint: *hint_string + - + updateMany: + filter: *updateMany_filter + update: *updateMany_update + hint: *hint_doc + ordered: true + expectResult: + deletedCount: 0 + insertedCount: 0 + insertedIds: { $$unsetOrMatches: {} } + matchedCount: 4 + modifiedCount: 4 + upsertedCount: 0 + upsertedIds: { } + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *updateMany_filter + u: *updateMany_update + multi: true + upsert: { $$unsetOrMatches: false } + hint: *hint_string + - + q: *updateMany_filter + u: *updateMany_update + multi: true + upsert: { $$unsetOrMatches: false } + hint: *hint_doc + ordered: true + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 13 + - + _id: 2 + x: 24 + - + _id: 3 + x: 33 + - + _id: 4 + x: 44 + - + description: 'BulkWrite replaceOne with update hints' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + replaceOne: + filter: + _id: 3 + replacement: + x: 333 + hint: *hint_string + - + replaceOne: + filter: + _id: 4 + replacement: + x: 444 + hint: *hint_doc + ordered: true + expectResult: + deletedCount: 0 + insertedCount: 0 + insertedIds: { $$unsetOrMatches: {} } + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + upsertedIds: { } + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: + _id: 3 + u: + x: 333 + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + hint: *hint_string + - + q: + _id: 4 + u: + x: 444 + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + hint: *hint_doc + ordered: true + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 333 + - + _id: 4 + x: 444 diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-validation.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-validation.yml new file mode 100644 index 00000000000..57defd56a46 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-validation.yml @@ -0,0 +1,73 @@ +description: "bulkWrite-update-validation" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: "BulkWrite replaceOne prohibits atomic modifiers" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - replaceOne: + filter: { _id: 1 } + replacement: { $set: { x: 22 } } + expectError: + isClientError: true + expectEvents: + - client: *client0 + events: [] + outcome: *initialData + + - description: "BulkWrite updateOne requires atomic modifiers" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - updateOne: + filter: { _id: 1 } + update: { x: 22 } + expectError: + isClientError: true + expectEvents: + - client: *client0 + events: [] + outcome: *initialData + + - description: "BulkWrite updateMany requires atomic modifiers" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - updateMany: + filter: { _id: { $gt: 1 } } + update: { x: 44 } + expectError: + isClientError: true + expectEvents: + - client: *client0 + events: [] + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-dots_and_dollars.yml new file mode 100644 index 00000000000..68cebd09cf2 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-dots_and_dollars.yml @@ -0,0 +1,150 @@ +description: "bulkWrite-updateMany-dots_and_dollars" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {} } + +tests: + - description: "Updating document to set top-level dollar-prefixed key on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - updateMany: + filter: { _id: 1 } + update: &dollarPrefixedKey + - { $replaceWith: { $setField: { field: { $literal: $a }, value: 1, input: $$ROOT } } } + expectResult: &bulkWriteResult + deletedCount: 0 + insertedCount: 0 + insertedIds: { $$unsetOrMatches: { } } + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + upsertedIds: { } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dollarPrefixedKey + multi: true + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {}, $a: 1 } + + - description: "Updating document to set top-level dotted key on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - updateMany: + filter: { _id: 1 } + update: &dottedKey + - { $replaceWith: { $setField: { field: { $literal: a.b }, value: 1, input: $$ROOT } } } + expectResult: *bulkWriteResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dottedKey + multi: true + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {}, a.b: 1 } + + - description: "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - updateMany: + filter: { _id: 1 } + update: &dollarPrefixedKeyInEmbedded + - { $set: { foo: { $setField: { field: { $literal: $a }, value: 1, input: $foo } } } } + expectResult: *bulkWriteResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dollarPrefixedKeyInEmbedded + multi: true + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: { $a: 1 } } + + - description: "Updating document to set dotted key in embedded doc on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - updateMany: + filter: { _id: 1 } + update: &dottedKeyInEmbedded + - { $set: { foo: { $setField: { field: { $literal: a.b }, value: 1, input: $foo } } } } + expectResult: *bulkWriteResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dottedKeyInEmbedded + multi: true + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: { a.b: 1 } } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-hint-unacknowledged.yml new file mode 100644 index 00000000000..7cb376c90c0 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-hint-unacknowledged.yml @@ -0,0 +1,104 @@ +description: bulkWrite-updateMany-hint-unacknowledged + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + writeConcern: { w: 0 } + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: &documents + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: "Unacknowledged updateMany with hint string fails with client-side error on pre-4.2 server" + runOnRequirements: + - maxServerVersion: "4.0.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateMany: + filter: &filter { _id: { $gt: 1 } } + update: &update { $inc: { x: 1 } } + hint: _id_ + expectError: + isClientError: true + expectEvents: &noEvents + - client: *client0 + events: [] + + - description: "Unacknowledged updateMany with hint document fails with client-side error on pre-4.2 server" + runOnRequirements: + - maxServerVersion: "4.0.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateMany: + filter: *filter + update: *update + hint: { _id: 1 } + expectError: + isClientError: true + expectEvents: *noEvents + + - description: "Unacknowledged updateMany with hint string on 4.2+ server" + runOnRequirements: + - minServerVersion: "4.2.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateMany: + filter: *filter + update: *update + hint: _id_ + expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } + expectEvents: &events + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *update + multi: true + upsert: { $$unsetOrMatches: false } + hint: { $$type: [ string, object ]} + writeConcern: { w: 0 } + + - description: "Unacknowledged updateMany with hint document on 4.2+ server" + runOnRequirements: + - minServerVersion: "4.2.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateMany: + filter: *filter + update: *update + hint: { _id: 1 } + expectResult: *unacknowledgedResult + expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-let.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-let.yml new file mode 100644 index 00000000000..f67d000334a --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-let.yml @@ -0,0 +1,96 @@ +description: "BulkWrite updateMany-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 20 } + - { _id: 2, x: 21 } + +tests: + - description: "BulkWrite updateMany with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateMany: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + update: &update + - $set: + x: 21 + let: &let + id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *update + multi: true + upsert: { $$unsetOrMatches: false } + let: *let + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 21 } + - { _id: 2, x: 21 } + + - description: "BulkWrite updateMany with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "4.2.0" + maxServerVersion: "4.9" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateMany: + filter: *filter + update: *update + let: *let + expectError: + errorContains: "'update.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *update + multi: true + upsert: { $$unsetOrMatches: false } + let: *let + + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 20 } + - { _id: 2, x: 21 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-dots_and_dollars.yml new file mode 100644 index 00000000000..c5a1662db10 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-dots_and_dollars.yml @@ -0,0 +1,150 @@ +description: "bulkWrite-updateOne-dots_and_dollars" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {} } + +tests: + - description: "Updating document to set top-level dollar-prefixed key on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - updateOne: + filter: { _id: 1 } + update: &dollarPrefixedKey + - { $replaceWith: { $setField: { field: { $literal: $a }, value: 1, input: $$ROOT } } } + expectResult: &bulkWriteResult + deletedCount: 0 + insertedCount: 0 + insertedIds: { $$unsetOrMatches: { } } + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + upsertedIds: { } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dollarPrefixedKey + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {}, $a: 1 } + + - description: "Updating document to set top-level dotted key on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - updateOne: + filter: { _id: 1 } + update: &dottedKey + - { $replaceWith: { $setField: { field: { $literal: a.b }, value: 1, input: $$ROOT } } } + expectResult: *bulkWriteResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dottedKey + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {}, a.b: 1 } + + - description: "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - updateOne: + filter: { _id: 1 } + update: &dollarPrefixedKeyInEmbedded + - { $set: { foo: { $setField: { field: { $literal: $a }, value: 1, input: $foo } } } } + expectResult: *bulkWriteResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dollarPrefixedKeyInEmbedded + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: { $a: 1 } } + + - description: "Updating document to set dotted key in embedded doc on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: bulkWrite + object: *collection0 + arguments: + requests: + - updateOne: + filter: { _id: 1 } + update: &dottedKeyInEmbedded + - { $set: { foo: { $setField: { field: { $literal: a.b }, value: 1, input: $foo } } } } + expectResult: *bulkWriteResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dottedKeyInEmbedded + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: { a.b: 1 } } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-hint-unacknowledged.yml new file mode 100644 index 00000000000..5997c54c2b5 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-hint-unacknowledged.yml @@ -0,0 +1,103 @@ +description: bulkWrite-updateOne-hint-unacknowledged + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + writeConcern: { w: 0 } + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: &documents + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + +tests: + - description: "Unacknowledged updateOne with hint string fails with client-side error on pre-4.2 server" + runOnRequirements: + - maxServerVersion: "4.0.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateOne: + filter: &filter { _id: { $gt: 1 } } + update: &update { $inc: { x: 1 } } + hint: _id_ + expectError: + isClientError: true + expectEvents: &noEvents + - client: *client0 + events: [] + + - description: "Unacknowledged updateOne with hint document fails with client-side error on pre-4.2 server" + runOnRequirements: + - maxServerVersion: "4.0.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateOne: + filter: *filter + update: *update + hint: { _id: 1 } + expectError: + isClientError: true + expectEvents: *noEvents + + - description: "Unacknowledged updateOne with hint string on 4.2+ server" + runOnRequirements: + - minServerVersion: "4.2.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateOne: + filter: *filter + update: *update + hint: _id_ + expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } + expectEvents: &events + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *update + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + hint: { $$type: [ string, object ]} + writeConcern: { w: 0 } + + - description: "Unacknowledged updateOne with hint document on 4.2+ server" + runOnRequirements: + - minServerVersion: "4.2.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateOne: + filter: *filter + update: *update + hint: { _id: 1 } + expectResult: *unacknowledgedResult + expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-let.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-let.yml new file mode 100644 index 00000000000..dc3cd2b5999 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-let.yml @@ -0,0 +1,95 @@ +description: "BulkWrite updateOne-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 20 } + - { _id: 2, x: 21 } + +tests: + - description: "BulkWrite updateOne with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateOne: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + update: &update + - $set: + x: 22 + let: &let + id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *update + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + let: *let + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 22 } + - { _id: 2, x: 21 } + + - description: "BulkWrite updateOne with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "4.2.0" + maxServerVersion: "4.9" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateOne: + filter: *filter + update: *update + let: *let + expectError: + errorContains: "'update.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *update + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + let: *let + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 20 } + - { _id: 2, x: 21 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-sort.json b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-sort.json new file mode 100644 index 00000000000..f78bd3bf3e3 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-sort.json @@ -0,0 +1,255 @@ +{ + "description": "BulkWrite updateOne-sort", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent", + "commandSucceededEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ], + "tests": [ + { + "description": "BulkWrite updateOne with sort option", + "runOnRequirements": [ + { + "minServerVersion": "8.0" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "updateOne": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "sort": { + "_id": -1 + }, + "update": [ + { + "$set": { + "x": 1 + } + } + ] + } + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": { + "$gt": 1 + } + }, + "u": [ + { + "$set": { + "x": 1 + } + } + ], + "sort": { + "_id": -1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + } + } + }, + { + "commandSucceededEvent": { + "reply": { + "ok": 1, + "n": 1 + }, + "commandName": "update" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 1 + } + ] + } + ] + }, + { + "description": "BulkWrite updateOne with sort option unsupported (server-side error)", + "runOnRequirements": [ + { + "maxServerVersion": "7.99" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "updateOne": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "sort": { + "_id": -1 + }, + "update": [ + { + "$set": { + "x": 1 + } + } + ] + } + } + ] + }, + "expectError": { + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": { + "$gt": 1 + } + }, + "u": [ + { + "$set": { + "x": 1 + } + } + ], + "sort": { + "_id": -1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + } + ] +} diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-sort.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-sort.yml new file mode 100644 index 00000000000..72bc814d69e --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-sort.yml @@ -0,0 +1,94 @@ +description: BulkWrite updateOne-sort + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent, commandSucceededEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: BulkWrite updateOne with sort option + runOnRequirements: + - minServerVersion: "8.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateOne: + filter: { _id: { $gt: 1 } } + sort: { _id: -1 } + update: [ $set: { x: 1 } ] + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: { $gt: 1 } } + u: [ $set: { x: 1 } ] + sort: { _id: -1 } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + - commandSucceededEvent: + reply: { ok: 1, n: 1 } + commandName: update + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 1 } + + - description: BulkWrite updateOne with sort option unsupported (server-side error) + runOnRequirements: + - maxServerVersion: "7.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateOne: + filter: { _id: { $gt: 1 } } + sort: { _id: -1 } + update: [ $set: { x: 1 } ] + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: { $gt: 1 } } + u: [ $set: { x: 1 } ] + sort: { _id: -1 } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite.yml new file mode 100644 index 00000000000..677e6725c44 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite.yml @@ -0,0 +1,448 @@ +description: bulkWrite + +schemaVersion: '1.0' + +runOnRequirements: + - + minServerVersion: '2.6' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + +tests: + - + description: 'BulkWrite with deleteOne operations' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + # Note: as in the "DeleteOne when many documents match" test in + # deleteOne.yml, we omit a deleteOne operation that might match + # multiple documents as that would hinder our ability to assert the + # final state of the collection under test. + requests: + - + # does not match an existing document + deleteOne: + filter: { _id: 3 } + - + # deletes the matched document + deleteOne: + filter: { _id: 2 } + ordered: true + expectResult: + deletedCount: 1 + insertedCount: 0 + insertedIds: + $$unsetOrMatches: { } + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + upsertedIds: { } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - + description: 'BulkWrite with deleteMany operations' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + # does not match any existing documents + deleteMany: + filter: { x: { $lt: 11 } } + - + # deletes the matched documents + deleteMany: + filter: { x: { $lte: 22 } } + ordered: true + expectResult: + deletedCount: 2 + insertedCount: 0 + insertedIds: + $$unsetOrMatches: { } + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + upsertedIds: { } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'BulkWrite with insertOne operations' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + insertOne: + document: { _id: 3, x: 33 } + - + insertOne: + document: { _id: 4, x: 44 } + ordered: true + expectResult: + deletedCount: 0 + insertedCount: 2 + insertedIds: + $$unsetOrMatches: + '0': 3 + '1': 4 + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + upsertedIds: { } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - + description: 'BulkWrite with replaceOne operations' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + # Note: as in the "ReplaceOne when many documents match" test in + # replaceOne.yml, we omit a replaceOne operation that might match + # multiple documents as that would hinder our ability to assert the + # final state of the collection under test. + requests: + - + # does not match an existing document + replaceOne: + filter: { _id: 3 } + replacement: { x: 33 } + - + # modifies the matched document + replaceOne: + filter: { _id: 1 } + replacement: { x: 12 } + - + # does not match an existing document and upserts + replaceOne: + filter: { _id: 3 } + replacement: { x: 33 } + upsert: true + ordered: true + expectResult: + deletedCount: 0 + insertedCount: 0 + insertedIds: + $$unsetOrMatches: { } + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 1 + upsertedIds: { '2': 3 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 12 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - + description: 'BulkWrite with updateOne operations' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + # Note: as in the "UpdateOne when many documents match" test in + # updateOne.yml, we omit an updateOne operation that might match + # multiple documents as that would hinder our ability to assert the + # final state of the collection under test. + requests: + - + # does not match an existing document + updateOne: + filter: { _id: 0 } + update: { $set: { x: 0 } } + - + # does not modify the matched document + updateOne: + filter: { _id: 1 } + update: { $set: { x: 11 } } + - + # modifies the matched document + updateOne: + filter: { _id: 2 } + update: { $inc: { x: 1 } } + - + # does not match an existing document and upserts + updateOne: + filter: { _id: 3 } + update: { $set: { x: 33 } } + upsert: true + ordered: true + expectResult: + deletedCount: 0 + insertedCount: 0 + insertedIds: + $$unsetOrMatches: { } + matchedCount: 2 + modifiedCount: 1 + upsertedCount: 1 + upsertedIds: { '3': 3 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 23 } + - { _id: 3, x: 33 } + - + description: 'BulkWrite with updateMany operations' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + # does not match any existing documents + updateMany: + filter: { x: { $lt: 11 } } + update: { $set: { x: 0 } } + - + # does not modify the matched documents + updateMany: + filter: { x: { $lte: 22 } } + update: { $unset: { y: 1 } } + - + # modifies the matched documents + updateMany: + filter: { x: { $lte: 22 } } + update: { $inc: { x: 1 } } + - + # does not match any existing documents and upserts + updateMany: + filter: { _id: 3 } + update: { $set: { x: 33 } } + upsert: true + ordered: true + expectResult: + deletedCount: 0 + insertedCount: 0 + insertedIds: + $$unsetOrMatches: { } + matchedCount: 4 + modifiedCount: 2 + upsertedCount: 1 + upsertedIds: { '3': 3 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 12 } + - { _id: 2, x: 23 } + - { _id: 3, x: 33 } + - + description: 'BulkWrite with mixed ordered operations' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + insertOne: + document: { _id: 3, x: 33 } + - + updateOne: + filter: { _id: 2 } + update: { $inc: { x: 1 } } + - + updateMany: + filter: { _id: { $gt: 1 } } + update: { $inc: { x: 1 } } + - + insertOne: + document: { _id: 4, x: 44 } + - + deleteMany: + filter: { x: { $nin: [ 24, 34 ] } } + - + replaceOne: + filter: { _id: 4 } + replacement: { _id: 4, x: 44 } + upsert: true + ordered: true + expectResult: + deletedCount: 2 + insertedCount: 2 + insertedIds: + $$unsetOrMatches: + '0': 3 + '3': 4 + matchedCount: 3 + modifiedCount: 3 + upsertedCount: 1 + upsertedIds: { '5': 4 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 2, x: 24 } + - { _id: 3, x: 34 } + - { _id: 4, x: 44 } + - + description: 'BulkWrite with mixed unordered operations' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + # We omit inserting multiple documents and updating documents that may + # not exist at the start of this test as we cannot assume the order in + # which the operations will execute. + requests: + - + replaceOne: + filter: { _id: 3 } + replacement: { _id: 3, x: 33 } + upsert: true + - + deleteOne: + filter: { _id: 1 } + - + updateOne: + filter: { _id: 2 } + update: { $inc: { x: 1 } } + ordered: false + expectResult: + deletedCount: 1 + insertedCount: 0 + insertedIds: + $$unsetOrMatches: { } + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 1 + upsertedIds: { '0': 3 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 2, x: 23 } + - { _id: 3, x: 33 } + - + description: 'BulkWrite continue-on-error behavior with unordered (preexisting duplicate key)' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + insertOne: + document: { _id: 2, x: 22 } + - + insertOne: + document: { _id: 3, x: 33 } + - + insertOne: + document: { _id: 4, x: 44 } + ordered: false + expectError: + isError: true + expectResult: + deletedCount: 0 + insertedCount: 2 + # Since the map of insertedIds is generated before execution it + # could indicate inserts that did not actually succeed. We omit this + # field rather than expect drivers to provide an accurate map + # filtered by write errors. + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + upsertedIds: { } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - + description: 'BulkWrite continue-on-error behavior with unordered (duplicate key in requests)' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + insertOne: + document: { _id: 3, x: 33 } + - + insertOne: + document: { _id: 3, x: 33 } + - + insertOne: + document: { _id: 4, x: 44 } + ordered: false + expectError: + isError: true + expectResult: + deletedCount: 0 + insertedCount: 2 + # Since the map of insertedIds is generated before execution it + # could indicate inserts that did not actually succeed. We omit this + # field rather than expect drivers to provide an accurate map + # filtered by write errors. + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + upsertedIds: { } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/count-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/count-collation.yml new file mode 100644 index 00000000000..692a3c69880 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/count-collation.yml @@ -0,0 +1,57 @@ +description: count-collation + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '3.4' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: ping } + +tests: + - + description: 'Count documents with collation' + operations: + - + object: *collection0 + name: countDocuments + arguments: + filter: { x: ping } + # https://www.mongodb.com/docs/manual/reference/collation/#collation-document + collation: + locale: en_US + strength: 2 + expectResult: 1 + - + description: 'Deprecated count with collation' + operations: + - + object: *collection0 + name: count + arguments: + filter: { x: ping } + collation: + locale: en_US + strength: 2 + expectResult: 1 diff --git a/driver-core/src/test/resources/unified-test-format/crud/count-empty.yml b/driver-core/src/test/resources/unified-test-format/crud/count-empty.yml new file mode 100644 index 00000000000..a5d5ae35b7c --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/count-empty.yml @@ -0,0 +1,52 @@ +description: count-empty + +schemaVersion: '1.0' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'Estimated document count with empty collection' + operations: + - + object: *collection0 + name: estimatedDocumentCount + arguments: { } + expectResult: 0 + - + description: 'Count documents with empty collection' + operations: + - + object: *collection0 + name: countDocuments + arguments: + filter: { } + expectResult: 0 + - + description: 'Deprecated count with empty collection' + operations: + - + object: *collection0 + name: count + arguments: + filter: { } + expectResult: 0 diff --git a/driver-core/src/test/resources/unified-test-format/crud/count.yml b/driver-core/src/test/resources/unified-test-format/crud/count.yml new file mode 100644 index 00000000000..5f9fbb76338 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/count.yml @@ -0,0 +1,95 @@ +description: count + +schemaVersion: '1.0' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - + description: 'Estimated document count' + operations: + - + object: *collection0 + name: estimatedDocumentCount + arguments: { } + expectResult: 3 + - + description: 'Count documents without a filter' + operations: + - + object: *collection0 + name: countDocuments + arguments: + filter: { } + expectResult: 3 + - + description: 'Count documents with a filter' + operations: + - + object: *collection0 + name: countDocuments + arguments: + filter: { _id: { $gt: 1 } } + expectResult: 2 + - + description: 'Count documents with skip and limit' + operations: + - + object: *collection0 + name: countDocuments + arguments: + filter: { } + skip: 1 + limit: 3 + expectResult: 2 + - + description: 'Deprecated count without a filter' + operations: + - + object: *collection0 + name: count + arguments: + filter: { } + expectResult: 3 + - + description: 'Deprecated count with a filter' + operations: + - + object: *collection0 + name: count + arguments: + filter: { _id: { $gt: 1 } } + expectResult: 2 + - + description: 'Deprecated count with skip and limit' + operations: + - + object: *collection0 + name: count + arguments: + filter: { } + skip: 1 + limit: 3 + expectResult: 2 diff --git a/driver-core/src/test/resources/unified-test-format/crud/countDocuments-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/countDocuments-comment.yml new file mode 100644 index 00000000000..8f1f7bc4b4d --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/countDocuments-comment.yml @@ -0,0 +1,92 @@ +description: "countDocuments-comment" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name countDocuments-comments-test + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: "countDocuments with document comment" + runOnRequirements: + - minServerVersion: 4.4.0 + operations: + - name: countDocuments + object: *collection0 + arguments: + filter: {} + comment: &documentComment { key: "value" } + expectResult: 3 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: &pipeline + - $match: {} + - $group: { _id: 1, n: { $sum: 1 } } + comment: *documentComment + commandName: aggregate + databaseName: *database0Name + + - description: "countDocuments with string comment" + runOnRequirements: + - minServerVersion: 3.6.0 + operations: + - name: countDocuments + object: *collection0 + arguments: + filter: {} + comment: &stringComment "comment" + expectResult: 3 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *pipeline + comment: *stringComment + commandName: aggregate + databaseName: *database0Name + + - description: "countDocuments with document comment on less than 4.4.0 - server error" + runOnRequirements: + - minServerVersion: 3.6.0 + maxServerVersion: 4.3.99 + operations: + - name: countDocuments + object: *collection0 + arguments: + filter: {} + comment: *documentComment + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *pipeline + comment: *documentComment + commandName: aggregate + databaseName: *database0Name diff --git a/driver-core/src/test/resources/unified-test-format/crud/db-aggregate-write-readPreference.yml b/driver-core/src/test/resources/unified-test-format/crud/db-aggregate-write-readPreference.yml new file mode 100644 index 00000000000..03fcd35aa35 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/db-aggregate-write-readPreference.yml @@ -0,0 +1,138 @@ +description: db-aggregate-write-readPreference + +schemaVersion: '1.4' + +runOnRequirements: + # 3.6+ non-standalone is needed to utilize $readPreference in OP_MSG. + # Serverless does not support $listLocalSessions and $currentOp stages, and + # mongos does not allow combining them with $out or $merge. + - minServerVersion: "3.6" + topologies: [ replicaset ] + serverless: forbid + +_yamlAnchors: + readConcern: &readConcern + level: &readConcernLevel "local" + writeConcern: &writeConcern + w: &writeConcernW 1 + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + # Used to test that read and write concerns are still inherited + uriOptions: + readConcernLevel: *readConcernLevel + w: *writeConcernW + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + databaseOptions: + readPreference: &readPreference + # secondaryPreferred is specified for compatibility with clusters that + # may not have a secondary (e.g. each shard is only a primary). + mode: secondaryPreferred + # maxStalenessSeconds is specified to ensure that drivers forward the + # read preference to mongos or a load balancer. That would not be the + # case with only secondaryPreferred. + maxStalenessSeconds: 600 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "Database-level aggregate with $out includes read preference for 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + serverless: "forbid" + operations: + - object: *database0 + name: aggregate + arguments: + pipeline: &outPipeline + - { $listLocalSessions: {} } + - { $limit: 1 } + - { $addFields: { _id: 1 } } + - { $project: { _id: 1 } } + - { $out: *collection0Name } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: 1 + pipeline: *outPipeline + $readPreference: *readPreference + readConcern: *readConcern + writeConcern: *writeConcern + + - description: "Database-level aggregate with $out omits read preference for pre-5.0 server" + runOnRequirements: + # MongoDB 4.2 introduced support for read concerns and write stages. + # Pre-4.2 servers may allow a "local" read concern anyway, but some + # drivers may avoid inheriting a client-level read concern for pre-4.2. + - minServerVersion: "4.2" + maxServerVersion: "4.4.99" + serverless: "forbid" + operations: + - object: *database0 + name: aggregate + arguments: + pipeline: *outPipeline + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: 1 + pipeline: *outPipeline + $readPreference: { $$exists: false } + readConcern: *readConcern + writeConcern: *writeConcern + + - description: "Database-level aggregate with $merge includes read preference for 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - object: *database0 + name: aggregate + arguments: + pipeline: &mergePipeline + - { $listLocalSessions: {} } + - { $limit: 1 } + - { $addFields: { _id: 1 } } + - { $project: { _id: 1 } } + - { $merge: { into: *collection0Name } } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: 1 + pipeline: *mergePipeline + $readPreference: *readPreference + readConcern: *readConcern + writeConcern: *writeConcern + + - description: "Database-level aggregate with $merge omits read preference for pre-5.0 server" + runOnRequirements: + - minServerVersion: "4.2" + maxServerVersion: "4.4.99" + operations: + - object: *database0 + name: aggregate + arguments: + pipeline: *mergePipeline + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: 1 + pipeline: *mergePipeline + $readPreference: { $$exists: false } + readConcern: *readConcern + writeConcern: *writeConcern diff --git a/driver-core/src/test/resources/unified-test-format/crud/db-aggregate.yml b/driver-core/src/test/resources/unified-test-format/crud/db-aggregate.yml new file mode 100644 index 00000000000..df82c32b059 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/db-aggregate.yml @@ -0,0 +1,70 @@ +description: db-aggregate +schemaVersion: '1.4' +runOnRequirements: + - + minServerVersion: 3.6.0 + # serverless does not support either of the current database-level aggregation stages ($listLocalSessions and + # $currentOp) + serverless: forbid +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name admin + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name crud-v2 +tests: + - + description: 'Aggregate with $listLocalSessions' + operations: + - + object: *database0 + name: aggregate + arguments: + pipeline: + - + $listLocalSessions: { } + - + $limit: 1 + - + $addFields: + dummy: 'dummy field' + - + $project: + _id: 0 + dummy: 1 + expectResult: + - + dummy: 'dummy field' + - + description: 'Aggregate with $listLocalSessions and allowDiskUse' + operations: + - + object: *database0 + name: aggregate + arguments: + pipeline: + - + $listLocalSessions: { } + - + $limit: 1 + - + $addFields: + dummy: 'dummy field' + - + $project: + _id: 0 + dummy: 1 + allowDiskUse: true + expectResult: + - + dummy: 'dummy field' diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-collation.yml new file mode 100644 index 00000000000..b7caab67dd0 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-collation.yml @@ -0,0 +1,54 @@ +description: deleteMany-collation + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '3.4' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: ping } + - { _id: 3, x: pINg } + +tests: + - + description: 'DeleteMany when many documents match with collation' + operations: + - + object: *collection0 + name: deleteMany + arguments: + filter: { x: PING } + # https://www.mongodb.com/docs/manual/reference/collation/#collation-document + collation: + locale: en_US + strength: 2 + expectResult: + deletedCount: 2 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-comment.yml new file mode 100644 index 00000000000..8f1b3522a76 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-comment.yml @@ -0,0 +1,97 @@ +description: "deleteMany-comment" +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2, name: "name2" } + - { _id: 3, name: "name3" } + +tests: + - description: "deleteMany with string comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: deleteMany + object: *collection0 + arguments: + filter: &filter { _id: { $gt: 1 } } + comment: "comment" + expectResult: &expect_result + deletedCount: 2 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 0 + comment: "comment" + outcome: &outcome + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + + - description: "deleteMany with document comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: deleteMany + object: *collection0 + arguments: + filter: *filter + comment: &comment { key: "value" } + expectResult: *expect_result + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 0 + comment: *comment + outcome: *outcome + + - description: "deleteMany with comment - pre 4.4" + runOnRequirements: + - minServerVersion: "3.4.0" + maxServerVersion: "4.2.99" + operations: + - name: deleteMany + object: *collection0 + arguments: + filter: *filter + comment: "comment" + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 0 + comment: "comment" + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-clientError.yml new file mode 100644 index 00000000000..c04d7507e33 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-clientError.yml @@ -0,0 +1,84 @@ +description: deleteMany-hint-clientError +schemaVersion: '1.0' +runOnRequirements: + - + maxServerVersion: 3.3.99 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name DeleteMany_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 +tests: + - + description: 'DeleteMany with hint string unsupported (client-side error)' + operations: + - + object: *collection0 + name: deleteMany + arguments: + filter: &filter + _id: + $gt: 1 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + description: 'DeleteMany with hint document unsupported (client-side error)' + operations: + - + object: *collection0 + name: deleteMany + arguments: + filter: *filter + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-serverError.yml new file mode 100644 index 00000000000..24260e2611a --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-serverError.yml @@ -0,0 +1,104 @@ +description: deleteMany-hint-serverError +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 3.4.0 + maxServerVersion: 4.3.3 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name DeleteMany_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 +tests: + - + description: 'DeleteMany with hint string unsupported (server-side error)' + operations: + - + object: *collection0 + name: deleteMany + arguments: + filter: &filter + _id: + $gt: 1 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: *filter + hint: _id_ + limit: 0 + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + description: 'DeleteMany with hint document unsupported (server-side error)' + operations: + - + object: *collection0 + name: deleteMany + arguments: + filter: *filter + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: *filter + hint: + _id: 1 + limit: 0 + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-unacknowledged.yml new file mode 100644 index 00000000000..827618d174f --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-unacknowledged.yml @@ -0,0 +1,90 @@ +description: deleteMany-hint-unacknowledged + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + writeConcern: { w: 0 } + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: &documents + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: "Unacknowledged deleteMany with hint string fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: deleteMany + arguments: + filter: &filter { _id: { $gt: 1 } } + hint: _id_ + expectError: + isClientError: true + expectEvents: &noEvents + - client: *client0 + events: [] + + - description: "Unacknowledged deleteMany with hint document fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: deleteMany + arguments: + filter: *filter + hint: { _id: 1 } + expectError: + isClientError: true + expectEvents: *noEvents + + - description: "Unacknowledged deleteMany with hint string on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: deleteMany + arguments: + filter: *filter + hint: _id_ + expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } + expectEvents: &events + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + hint: { $$type: [ string, object ]} + limit: 0 + writeConcern: { w: 0 } + + - description: "Unacknowledged deleteMany with hint document on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: deleteMany + arguments: + filter: *filter + hint: { _id: 1 } + expectResult: *unacknowledgedResult + expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint.yml new file mode 100644 index 00000000000..ce5f0a058d3 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint.yml @@ -0,0 +1,96 @@ +description: deleteMany-hint +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.3.4 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name DeleteMany_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 +tests: + - + description: 'DeleteMany with hint string' + operations: + - + object: *collection0 + name: deleteMany + arguments: + filter: &filter + _id: + $gt: 1 + hint: _id_ + expectResult: &result + deletedCount: 2 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: *filter + hint: _id_ + limit: 0 + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + description: 'DeleteMany with hint document' + operations: + - + object: *collection0 + name: deleteMany + arguments: + filter: *filter + hint: + _id: 1 + expectResult: *result + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: *filter + hint: + _id: 1 + limit: 0 + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-let.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-let.yml new file mode 100644 index 00000000000..723985aa8c0 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-let.yml @@ -0,0 +1,93 @@ +description: "deleteMany-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2, name: "name" } + - { _id: 3, name: "name" } + +tests: + - description: "deleteMany with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: deleteMany + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$name", "$$name" ] + let: &let0 + name: "name" + expectResult: + deletedCount: 2 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - + q: *filter + limit: 0 + let: *let0 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + + - description: "deleteMany with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.4.99" + operations: + - name: deleteMany + object: *collection0 + arguments: + filter: &filter1 + $expr: + $eq: [ "$name", "$$name" ] + let: &let1 + name: "name" + expectError: + errorContains: "'delete.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - + q: *filter1 + limit: 0 + let: *let1 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2, name: "name" } + - { _id: 3, name: "name" } diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany.yml new file mode 100644 index 00000000000..832201ed51a --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteMany.yml @@ -0,0 +1,63 @@ +description: deleteMany + +schemaVersion: '1.0' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - + description: 'DeleteMany when many documents match' + operations: + - + object: *collection0 + name: deleteMany + arguments: + filter: { _id: { $gt: 1 } } + expectResult: + deletedCount: 2 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - + description: 'DeleteMany when no document matches' + operations: + - + object: *collection0 + name: deleteMany + arguments: + filter: { _id: 4 } + expectResult: + deletedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-collation.yml new file mode 100644 index 00000000000..2ec971550ac --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-collation.yml @@ -0,0 +1,55 @@ +description: deleteOne-collation + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '3.4' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: ping } + - { _id: 3, x: pINg } + +tests: + - + description: 'DeleteOne when many documents matches with collation' + operations: + - + object: *collection0 + name: deleteOne + arguments: + filter: { x: PING } + # https://www.mongodb.com/docs/manual/reference/collation/#collation-document + collation: + locale: en_US + strength: 2 + expectResult: + deletedCount: 1 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 3, x: pINg } diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-comment.yml new file mode 100644 index 00000000000..1e52298f397 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-comment.yml @@ -0,0 +1,98 @@ +description: "deleteOne-comment" +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2, name: "name" } + - { _id: 3, name: "name" } + +tests: + - description: "deleteOne with string comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: deleteOne + object: *collection0 + arguments: + filter: &filter { _id: 1 } + comment: "comment" + expectResult: &expect_result + deletedCount: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 1 + comment: "comment" + outcome: &outcome + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 2, name: "name" } + - { _id: 3, name: "name" } + + - description: "deleteOne with document comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: deleteOne + object: *collection0 + arguments: + filter: *filter + comment: &comment { key: "value" } + expectResult: *expect_result + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 1 + comment: *comment + outcome: *outcome + + - description: "deleteOne with comment - pre 4.4" + runOnRequirements: + - minServerVersion: "3.4.0" + maxServerVersion: "4.2.99" + operations: + - name: deleteOne + object: *collection0 + arguments: + filter: *filter + comment: "comment" + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 1 + comment: "comment" + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-errorResponse.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-errorResponse.yml new file mode 100644 index 00000000000..dcf013060e9 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-errorResponse.yml @@ -0,0 +1,46 @@ +description: "deleteOne-errorResponse" + +schemaVersion: "1.12" + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name test + +tests: + # Some drivers may still need to skip this test because the CRUD spec does not + # prescribe how drivers should formulate a WriteException beyond collecting a + # write or write concern error. + - description: "delete operations support errorResponse assertions" + runOnRequirements: + - minServerVersion: "4.0.0" + topologies: [ single, replicaset ] + - minServerVersion: "4.2.0" + topologies: [ sharded ] + operations: + - name: failPoint + object: testRunner + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: [ delete ] + errorCode: &errorCode 8 # UnknownError + - name: deleteOne + object: *collection0 + arguments: + filter: { _id: 1 } + expectError: + errorCode: *errorCode + errorResponse: + code: *errorCode diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-clientError.yml new file mode 100644 index 00000000000..7ff6f8d9615 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-clientError.yml @@ -0,0 +1,77 @@ +description: deleteOne-hint-clientError +schemaVersion: '1.0' +runOnRequirements: + - + maxServerVersion: 3.3.99 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name DeleteOne_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'DeleteOne with hint string unsupported (client-side error)' + operations: + - + object: *collection0 + name: deleteOne + arguments: + filter: &filter + _id: 1 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + description: 'DeleteOne with hint document unsupported (client-side error)' + operations: + - + object: *collection0 + name: deleteOne + arguments: + filter: *filter + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-serverError.yml new file mode 100644 index 00000000000..191d96aeaf4 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-serverError.yml @@ -0,0 +1,97 @@ +description: deleteOne-hint-serverError +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 3.4.0 + maxServerVersion: 4.3.3 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name DeleteOne_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'DeleteOne with hint string unsupported (server-side error)' + operations: + - + object: *collection0 + name: deleteOne + arguments: + filter: &filter + _id: 1 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: *filter + hint: _id_ + limit: 1 + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + description: 'DeleteOne with hint document unsupported (server-side error)' + operations: + - + object: *collection0 + name: deleteOne + arguments: + filter: *filter + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: *filter + hint: + _id: 1 + limit: 1 + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-unacknowledged.yml new file mode 100644 index 00000000000..4ccbe13d60f --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-unacknowledged.yml @@ -0,0 +1,89 @@ +description: deleteOne-hint-unacknowledged + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + writeConcern: { w: 0 } + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: &documents + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + +tests: + - description: "Unacknowledged deleteOne with hint string fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: deleteOne + arguments: + filter: &filter { _id: { $gt: 1 } } + hint: _id_ + expectError: + isClientError: true + expectEvents: &noEvents + - client: *client0 + events: [] + + - description: "Unacknowledged deleteOne with hint document fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: deleteOne + arguments: + filter: *filter + hint: { _id: 1 } + expectError: + isClientError: true + expectEvents: *noEvents + + - description: "Unacknowledged deleteOne with hint string on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: deleteOne + arguments: + filter: *filter + hint: _id_ + expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } + expectEvents: &events + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + hint: { $$type: [ string, object ]} + limit: 1 + writeConcern: { w: 0 } + + - description: "Unacknowledged deleteOne with hint document on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: deleteOne + arguments: + filter: *filter + hint: { _id: 1 } + expectResult: *unacknowledgedResult + expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint.yml new file mode 100644 index 00000000000..ce23b8a9870 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint.yml @@ -0,0 +1,92 @@ +description: deleteOne-hint +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.3.4 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name DeleteOne_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'DeleteOne with hint string' + operations: + - + object: *collection0 + name: deleteOne + arguments: + filter: &filter + _id: 1 + hint: _id_ + expectResult: &result + deletedCount: 1 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: *filter + hint: _id_ + limit: 1 + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 2 + x: 22 + - + description: 'deleteOne with hint document' + operations: + - + object: *collection0 + name: deleteOne + arguments: + filter: *filter + hint: + _id: 1 + expectResult: *result + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: *filter + hint: + _id: 1 + limit: 1 + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-let.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-let.yml new file mode 100644 index 00000000000..c52d98b99d4 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-let.yml @@ -0,0 +1,91 @@ +description: "deleteOne-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "deleteOne with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: deleteOne + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + let: &let0 + id: 1 + expectResult: + deletedCount: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - + q: *filter + limit: 1 + let: *let0 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 2 } + + - description: "deleteOne with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.4.99" + operations: + - name: deleteOne + object: *collection0 + arguments: + filter: &filter1 + $expr: + $eq: [ "$_id", "$$id" ] + let: &let1 + id: 1 + expectError: + errorContains: "'delete.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - + q: *filter1 + limit: 1 + let: *let1 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne.yml new file mode 100644 index 00000000000..6c7dc951910 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/deleteOne.yml @@ -0,0 +1,76 @@ +description: deleteOne + +schemaVersion: '1.0' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - + # This test doesn't verify the output collection because we cannot assume + # which document gets deleted. + description: 'DeleteOne when many documents match' + operations: + - + object: *collection0 + name: deleteOne + arguments: + filter: { _id: { $gt: 1 } } + expectResult: + deletedCount: 1 + - + description: 'DeleteOne when one document matches' + operations: + - + object: *collection0 + name: deleteOne + arguments: + filter: { _id: 2 } + expectResult: + deletedCount: 1 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 3, x: 33 } + - + description: 'DeleteOne when no documents match' + operations: + - + object: *collection0 + name: deleteOne + arguments: + filter: { _id: 4 } + expectResult: + deletedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/distinct-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/distinct-collation.yml new file mode 100644 index 00000000000..74cf1bae35a --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/distinct-collation.yml @@ -0,0 +1,48 @@ +description: distinct-collation + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '3.4' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - {_id: 1, string: 'PING'} + - {_id: 2, string: 'ping'} + +tests: + - + description: 'Distinct with a collation' + operations: + - + object: *collection0 + name: distinct + arguments: + fieldName: string + filter: { } + # https://www.mongodb.com/docs/manual/reference/collation/#collation-document + collation: + locale: en_US + strength: 2 + expectResult: + - PING diff --git a/driver-core/src/test/resources/unified-test-format/crud/distinct-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/distinct-comment.yml new file mode 100644 index 00000000000..c0820099431 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/distinct-comment.yml @@ -0,0 +1,98 @@ +description: "distinct-comment" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name distinct-comment-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: "distinct with document comment" + runOnRequirements: + # https://jira.mongodb.org/browse/SERVER-44847 + # Server supports distinct with comment of any type for comment starting from 4.4.14. + - minServerVersion: "4.4.14" + operations: + - name: distinct + object: *collection0 + arguments: + fieldName: &fieldName x + filter: &filter {} + comment: &documentComment { key: "value"} + expectResult: [ 11, 22, 33 ] + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + distinct: *collection0Name + key: *fieldName + query: *filter + comment: *documentComment + commandName: distinct + databaseName: *database0Name + + - description: "distinct with string comment" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - name: distinct + object: *collection0 + arguments: + fieldName: *fieldName + filter: *filter + comment: &stringComment "comment" + expectResult: [ 11, 22, 33 ] + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + distinct: *collection0Name + key: *fieldName + query: *filter + comment: *stringComment + commandName: distinct + databaseName: *database0Name + + - description: "distinct with document comment - pre 4.4, server error" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.4.13" + operations: + - name: distinct + object: *collection0 + arguments: + fieldName: *fieldName + filter: *filter + comment: *documentComment + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + distinct: *collection0Name + key: *fieldName + query: *filter + comment: *documentComment + commandName: distinct + databaseName: *database0Name diff --git a/driver-core/src/test/resources/unified-test-format/crud/distinct.yml b/driver-core/src/test/resources/unified-test-format/crud/distinct.yml new file mode 100644 index 00000000000..c554a7671b4 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/distinct.yml @@ -0,0 +1,54 @@ +description: distinct + +schemaVersion: '1.0' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - + description: 'Distinct without a filter' + operations: + - + object: *collection0 + name: distinct + arguments: + fieldName: x + filter: { } + expectResult: + - 11 + - 22 + - 33 + - + description: 'Distinct with a filter' + operations: + - + object: *collection0 + name: distinct + arguments: + fieldName: x + filter: { _id: { $gt: 1 } } + expectResult: + - 22 + - 33 diff --git a/driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount-comment.yml new file mode 100644 index 00000000000..b7853151048 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount-comment.yml @@ -0,0 +1,95 @@ +description: "estimatedDocumentCount-comment" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name edc-comment-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: "estimatedDocumentCount with document comment" + runOnRequirements: + # https://jira.mongodb.org/browse/SERVER-63315 + # Server supports count with comment of any type for comment starting from 4.4.14. + - minServerVersion: "4.4.14" + operations: + - name: estimatedDocumentCount + object: *collection0 + arguments: + comment: &documentComment { key: "value"} + expectResult: 3 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + count: *collection0Name + comment: *documentComment + commandName: count + databaseName: *database0Name + + - description: "estimatedDocumentCount with string comment" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - name: estimatedDocumentCount + object: *collection0 + arguments: + comment: &stringComment "comment" + expectResult: 3 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + count: *collection0Name + comment: *stringComment + commandName: count + databaseName: *database0Name + + - description: "estimatedDocumentCount with document comment - pre 4.4.14, server error" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.4.13" + # Server does not raise an error if topology is sharded. + # https://jira.mongodb.org/browse/SERVER-65954 + topologies: [ single, replicaset ] + operations: + - name: estimatedDocumentCount + object: *collection0 + arguments: + # Even though according to the docs count command does not support any + # comment for server version less than 4.4, no error is raised by such + # servers. Therefore, we have only one test with a document comment + # to test server errors. + # https://jira.mongodb.org/browse/SERVER-63315 + # Server supports count with comment of any type for comment starting from 4.4.14. + comment: *documentComment + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + count: *collection0Name + comment: *documentComment + commandName: count + databaseName: *database0Name diff --git a/driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount.yml b/driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount.yml new file mode 100644 index 00000000000..12f33cc7e51 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount.yml @@ -0,0 +1,181 @@ +description: "estimatedDocumentCount" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false # Avoid setting fail points with multiple mongoses + uriOptions: { retryReads: false } # Avoid retrying fail points with closeConnection + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name edc-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + - collection: + # Nonexistent collection intentionally omitted from initialData + id: &collection1 collection1 + database: *database0 + collectionName: &collection1Name coll1 + - collection: + id: &collection0View collection0View + database: *database0 + collectionName: &collection0ViewName coll0view + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: "estimatedDocumentCount always uses count" + operations: + - name: estimatedDocumentCount + object: *collection0 + expectResult: 3 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + count: *collection0Name + commandName: count + databaseName: *database0Name + + - description: "estimatedDocumentCount with maxTimeMS" + operations: + - name: estimatedDocumentCount + object: *collection0 + arguments: + maxTimeMS: 6000 + expectResult: 3 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + count: *collection0Name + maxTimeMS: 6000 + commandName: count + databaseName: *database0Name + + - description: "estimatedDocumentCount on non-existent collection" + operations: + - name: estimatedDocumentCount + object: *collection1 + expectResult: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + count: *collection1Name + commandName: count + databaseName: *database0Name + + - description: "estimatedDocumentCount errors correctly--command error" + runOnRequirements: + - minServerVersion: "4.0.0" + topologies: [ single, replicaset ] + - minServerVersion: "4.2.0" + topologies: [ sharded ] + operations: + - name: failPoint + object: testRunner + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: [ count ] + errorCode: 8 # UnknownError + - name: estimatedDocumentCount + object: *collection0 + expectError: + errorCode: 8 # UnknownError + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + count: *collection0Name + commandName: count + databaseName: *database0Name + + - description: "estimatedDocumentCount errors correctly--socket error" + runOnRequirements: + - minServerVersion: "4.0.0" + topologies: [ single, replicaset ] + - minServerVersion: "4.2.0" + topologies: [ sharded ] + operations: + - name: failPoint + object: testRunner + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: [ count ] + closeConnection: true + - name: estimatedDocumentCount + object: *collection0 + expectError: + isError: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + count: *collection0Name + commandName: count + databaseName: *database0Name + + - description: "estimatedDocumentCount works correctly on views" + # viewOn option was added to the create command in 3.4 + runOnRequirements: + - minServerVersion: "3.4.0" + operations: + - name: dropCollection + object: *database0 + arguments: + collection: *collection0ViewName + - name: createCollection + object: *database0 + arguments: + collection: *collection0ViewName + viewOn: *collection0Name + pipeline: &pipeline + - { $match: { _id: { $gt: 1 } } } + - name: estimatedDocumentCount + object: *collection0View + expectResult: 2 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + drop: *collection0ViewName + commandName: drop + databaseName: *database0Name + - commandStartedEvent: + command: + create: *collection0ViewName + viewOn: *collection0Name + pipeline: *pipeline + commandName: create + databaseName: *database0Name + - commandStartedEvent: + command: + count: *collection0ViewName + commandName: count + databaseName: *database0Name diff --git a/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-clientError.yml new file mode 100644 index 00000000000..da7f6365f1f --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-clientError.yml @@ -0,0 +1,52 @@ +description: find-allowdiskuse-clientError +schemaVersion: '1.0' +runOnRequirements: + - + maxServerVersion: 3.0.99 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_find_allowdiskuse_clienterror +tests: + - + description: 'Find fails when allowDiskUse true is specified against pre 3.2 server' + operations: + - + object: *collection0 + name: find + arguments: + filter: { } + allowDiskUse: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + - + description: 'Find fails when allowDiskUse false is specified against pre 3.2 server' + operations: + - + object: *collection0 + name: find + arguments: + filter: { } + allowDiskUse: false + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] diff --git a/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-serverError.yml new file mode 100644 index 00000000000..86f48d18e58 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-serverError.yml @@ -0,0 +1,65 @@ +description: find-allowdiskuse-serverError +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: '3.2' + maxServerVersion: 4.3.0 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_find_allowdiskuse_servererror +tests: + - + description: 'Find fails when allowDiskUse true is specified against pre 4.4 server (server-side error)' + operations: + - + object: *collection0 + name: find + arguments: + filter: &filter { } + allowDiskUse: true + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + find: *collection_name + filter: *filter + allowDiskUse: true + - + description: 'Find fails when allowDiskUse false is specified against pre 4.4 server (server-side error)' + operations: + - + object: *collection0 + name: find + arguments: + filter: *filter + allowDiskUse: false + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + find: *collection_name + filter: *filter + allowDiskUse: false diff --git a/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse.yml b/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse.yml new file mode 100644 index 00000000000..2f4190b9c31 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse.yml @@ -0,0 +1,76 @@ +description: find-allowdiskuse +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.3.1 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_find_allowdiskuse +tests: + - + description: 'Find does not send allowDiskUse when value is not specified' + operations: + - + object: *collection0 + name: find + arguments: + filter: { } + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + find: *collection_name + allowDiskUse: + $$exists: false + - + description: 'Find sends allowDiskUse false when false is specified' + operations: + - + object: *collection0 + name: find + arguments: + filter: { } + allowDiskUse: false + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + find: *collection_name + allowDiskUse: false + - + description: 'Find sends allowDiskUse true when true is specified' + operations: + - + object: *collection0 + name: find + arguments: + filter: { } + allowDiskUse: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + find: *collection_name + allowDiskUse: true diff --git a/driver-core/src/test/resources/unified-test-format/crud/find-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/find-collation.yml new file mode 100644 index 00000000000..9810b609708 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/find-collation.yml @@ -0,0 +1,46 @@ +description: find-collation + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '3.4' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: ping } + +tests: + - + description: 'Find with a collation' + operations: + - + object: *collection0 + name: find + arguments: + filter: { x: PING } + # https://www.mongodb.com/docs/manual/reference/collation/#collation-document + collation: + locale: en_US + strength: 2 + expectResult: + - { _id: 1, x: ping } diff --git a/driver-core/src/test/resources/unified-test-format/crud/find-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/find-comment.yml new file mode 100644 index 00000000000..905241ad0e9 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/find-comment.yml @@ -0,0 +1,166 @@ +description: "find-comment" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - { _id: 5, x: 55 } + - { _id: 6, x: 66 } + +tests: + - description: "find with string comment" + runOnRequirements: + - minServerVersion: "3.6" + operations: + - name: find + object: *collection0 + arguments: + filter: &filter + _id: 1 + comment: "comment" + expectResult: &expect_result + - { _id: 1 } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + comment: "comment" + + - description: "find with document comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: find + object: *collection0 + arguments: + filter: *filter + comment: &comment { key: "value"} + expectResult: *expect_result + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + comment: *comment + + - description: "find with document comment - pre 4.4" + runOnRequirements: + - maxServerVersion: "4.2.99" + minServerVersion: "3.6" + operations: + - name: find + object: *collection0 + arguments: + filter: *filter + comment: *comment + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + comment: *comment + + - description: "find with comment sets comment on getMore" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - name: find + object: *collection0 + arguments: + filter: &filter_get_more { _id: { $gt: 1 } } + batchSize: 2 + comment: *comment + expectResult: + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - { _id: 5, x: 55 } + - { _id: 6, x: 66 } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: { _id: { $gt: 1 } } + batchSize: 2 + comment: *comment + - commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection0Name + batchSize: 2 + comment: *comment + - commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection0Name + batchSize: 2 + comment: *comment + + - description: "find with comment does not set comment on getMore - pre 4.4" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.3.99" + operations: + - name: find + object: *collection0 + arguments: + filter: &filter_get_more { _id: { $gt: 1 } } + batchSize: 2 + comment: "comment" + expectResult: + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - { _id: 5, x: 55 } + - { _id: 6, x: 66 } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: { _id: { $gt: 1 } } + batchSize: 2 + comment: "comment" + - commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection0Name + batchSize: 2 + comment: { $$exists: false } + - commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection0Name + batchSize: 2 + comment: { $$exists: false } diff --git a/driver-core/src/test/resources/unified-test-format/crud/find-let.yml b/driver-core/src/test/resources/unified-test-format/crud/find-let.yml new file mode 100644 index 00000000000..20afe85c879 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/find-let.yml @@ -0,0 +1,71 @@ +description: "find-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "Find with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: find + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + let: &let0 + id: 1 + expectResult: + - { _id: 1 } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + let: *let0 + + - description: "Find with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.4.99" + operations: + - name: find + object: *collection0 + arguments: + filter: &filter1 + _id: 1 + let: &let1 + x: 1 + expectError: + errorContains: "Unrecognized field 'let'" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter1 + let: *let1 diff --git a/driver-core/src/test/resources/unified-test-format/crud/find.yml b/driver-core/src/test/resources/unified-test-format/crud/find.yml new file mode 100644 index 00000000000..76676900fad --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/find.yml @@ -0,0 +1,107 @@ +description: "find" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: true # ensure cursors pin to a single server + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name find-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - { _id: 5, x: 55 } + - { _id: 6, x: 66 } + +tests: + - description: "find with multiple batches works" + operations: + - name: find + arguments: + filter: { _id: { $gt: 1 } } + batchSize: 2 + object: *collection0 + expectResult: + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - { _id: 5, x: 55 } + - { _id: 6, x: 66 } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: { _id: { $gt: 1 } } + batchSize: 2 + commandName: find + databaseName: *database0Name + - commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection0Name + batchSize: 2 + commandName: getMore + databaseName: *database0Name + - commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection0Name + batchSize: 2 + commandName: getMore + databaseName: *database0Name + - + description: 'Find with filter' + operations: + - + object: *collection0 + name: find + arguments: + filter: { _id: 1 } + expectResult: + - { _id: 1, x: 11 } + - + description: 'Find with filter, sort, skip, and limit' + operations: + - + object: *collection0 + name: find + arguments: + filter: { _id: { $gt: 2 } } + sort: { _id: 1 } + skip: 2 + limit: 2 + expectResult: + - { _id: 5, x: 55 } + - { _id: 6, x: 66 } + - + description: 'Find with limit, sort, and batchsize' + operations: + - + object: *collection0 + name: find + arguments: + filter: { } + sort: { _id: 1 } + limit: 4 + batchSize: 2 + expectResult: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-collation.yml new file mode 100644 index 00000000000..2e6de9b08ef --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-collation.yml @@ -0,0 +1,56 @@ +description: findOneAndDelete-collation + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '3.4' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: ping } + - { _id: 3, x: pINg } + +tests: + - + description: 'FindOneAndDelete when one document matches with collation' + operations: + - + object: *collection0 + name: findOneAndDelete + arguments: + filter: { _id: 2, x: PING } + projection: { x: 1, _id: 0 } + sort: { x: 1 } + # https://www.mongodb.com/docs/manual/reference/collation/#collation-document + collation: + locale: en_US + strength: 2 + expectResult: { x: ping } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 3, x: pINg } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-comment.yml new file mode 100644 index 00000000000..dfa7ff2ce0a --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-comment.yml @@ -0,0 +1,96 @@ +description: "findOneAndDelete-comment" +schemaVersion: "1.0" + + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "findOneAndDelete with string comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: findOneAndDelete + object: *collection0 + arguments: + filter: &filter + _id: 1 + comment: "comment" + expectResult: + _id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + remove: true + comment: "comment" + outcome: &outcome + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 2 } + + - description: "findOneAndDelete with document comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: findOneAndDelete + object: *collection0 + arguments: + filter: *filter + comment: &comment { key: "value"} + expectResult: + _id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + remove: true + comment: *comment + outcome: *outcome + + - description: "findOneAndDelete with comment - pre 4.4" + runOnRequirements: + - minServerVersion: "4.2.0" # findAndModify option validation was introduced in 4.2 + maxServerVersion: "4.2.99" + operations: + - name: findOneAndDelete + object: *collection0 + arguments: + filter: *filter + comment: "comment" + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + remove: true + comment: "comment" + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-clientError.yml new file mode 100644 index 00000000000..46c7521ad8c --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-clientError.yml @@ -0,0 +1,88 @@ +description: findOneAndDelete-hint-clientError +schemaVersion: '1.0' +runOnRequirements: + - + maxServerVersion: 4.0.99 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name findOneAndDelete_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'FindOneAndDelete with hint string unsupported (client-side error)' + operations: + - + object: *collection0 + name: findOneAndDelete + arguments: + filter: &filter + _id: 1 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + description: 'FindOneAndDelete with hint document' + operations: + - + object: *collection0 + name: findOneAndDelete + arguments: + filter: &filter + _id: 1 + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-serverError.yml new file mode 100644 index 00000000000..db75131545f --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-serverError.yml @@ -0,0 +1,104 @@ +description: findOneAndDelete-hint-serverError +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.2.0 + maxServerVersion: 4.3.3 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name findOneAndDelete_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'FindOneAndDelete with hint string unsupported (server-side error)' + operations: + - + object: *collection0 + name: findOneAndDelete + arguments: + filter: &filter + _id: 1 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: *filter + hint: _id_ + remove: true + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + description: 'FindOneAndDelete with hint document unsupported (server-side error)' + operations: + - + object: *collection0 + name: findOneAndDelete + arguments: + filter: &filter + _id: 1 + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: *filter + hint: + _id: 1 + remove: true + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-unacknowledged.yml new file mode 100644 index 00000000000..2b29a4923ea --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-unacknowledged.yml @@ -0,0 +1,88 @@ +description: findOneAndDelete-hint-unacknowledged + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + writeConcern: { w: 0 } + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: &documents + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + +tests: + - description: "Unacknowledged findOneAndDelete with hint string fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: findOneAndDelete + arguments: + filter: &filter { _id: { $gt: 1 } } + hint: _id_ + expectError: + isClientError: true + expectEvents: &noEvents + - client: *client0 + events: [] + + - description: "Unacknowledged findOneAndDelete with hint document fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: findOneAndDelete + arguments: + filter: *filter + hint: { _id: 1 } + expectError: + isClientError: true + expectEvents: *noEvents + + - description: "Unacknowledged findOneAndDelete with hint string on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: findOneAndDelete + arguments: + filter: *filter + hint: _id_ + expectResult: &unacknowledgedResult { $$unsetOrMatches: null } + expectEvents: &events + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + remove: true + hint: { $$type: [ string, object ]} + writeConcern: { w: 0 } + + - description: "Unacknowledged findOneAndDelete with hint document on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: findOneAndDelete + arguments: + filter: *filter + hint: { _id: 1 } + expectResult: *unacknowledgedResult + expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint.yml new file mode 100644 index 00000000000..90907798310 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint.yml @@ -0,0 +1,99 @@ +description: findOneAndDelete-hint +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.3.4 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name findOneAndDelete_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'FindOneAndDelete with hint string' + operations: + - + object: *collection0 + name: findOneAndDelete + arguments: + filter: &filter + _id: 1 + hint: _id_ + expectResult: &result + _id: 1 + x: 11 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: *filter + hint: _id_ + remove: true + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 2 + x: 22 + - + description: 'FindOneAndDelete with hint document' + operations: + - + object: *collection0 + name: findOneAndDelete + arguments: + filter: &filter + _id: 1 + hint: + _id: 1 + expectResult: &result + _id: 1 + x: 11 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: *filter + hint: + _id: 1 + remove: true + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 2 + x: 22 diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-let.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-let.yml new file mode 100644 index 00000000000..0174af0a2b3 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-let.yml @@ -0,0 +1,86 @@ +description: "findOneAndDelete-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "findOneAndDelete with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: findOneAndDelete + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + let: &let0 + id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + remove: true + let: *let0 + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 2 } + + - description: "findOneAndDelete with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "4.2.0" + maxServerVersion: "4.4.99" + operations: + - name: findOneAndDelete + object: *collection0 + arguments: + filter: &filter1 + $expr: + $eq: [ "$_id", "$$id" ] + let: &let1 + id: 1 + expectError: + # This error message is consistent between 4.2.x and 4.4.x servers. + # Older servers return a different error message. + errorContains: "field 'let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter1 + remove: true + let: *let1 + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete.yml new file mode 100644 index 00000000000..6bb3a1ccca1 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete.yml @@ -0,0 +1,84 @@ +description: findOneAndDelete + +schemaVersion: '1.0' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - + description: 'FindOneAndDelete when many documents match' + operations: + - + object: *collection0 + name: findOneAndDelete + arguments: + filter: { _id: { $gt: 1 } } + projection: { x: 1, _id: 0 } + sort: { x: 1 } + expectResult: { x: 22 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 3, x: 33 } + - + description: 'FindOneAndDelete when one document matches' + operations: + - + object: *collection0 + name: findOneAndDelete + arguments: + filter: { _id: 2 } + projection: { x: 1, _id: 0 } + sort: { x: 1 } + expectResult: { x: 22 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 3, x: 33 } + - + description: 'FindOneAndDelete when no documents match' + operations: + - + object: *collection0 + name: findOneAndDelete + arguments: + filter: { _id: 4 } + projection: { x: 1, _id: 0 } + sort: { x: 1 } + expectResult: null + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-collation.yml new file mode 100644 index 00000000000..c3d8a8e78fc --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-collation.yml @@ -0,0 +1,57 @@ +description: findOneAndReplace-collation + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '3.4' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: ping } + +tests: + - + description: 'FindOneAndReplace when one document matches with collation returning the document after modification' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: { x: PING } + replacement: { x: pong } + projection: { x: 1, _id: 0 } + returnDocument: After + sort: { x: 1 } + # https://www.mongodb.com/docs/manual/reference/collation/#collation-document + collation: + locale: en_US + strength: 2 + expectResult: { x: pong } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: pong } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-comment.yml new file mode 100644 index 00000000000..2c6aaef07ba --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-comment.yml @@ -0,0 +1,101 @@ +description: "findOneAndReplace-comment" +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "findOneAndReplace with string comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: &filter + _id: 1 + replacement: &replacement + x: 5 + comment: "comment" + expectResult: + _id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + update: *replacement + comment: "comment" + outcome: &outcome + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 5 } + - { _id: 2 } + + - description: "findOneAndReplace with document comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: *filter + replacement: *replacement + comment: &comment { key: "value"} + expectResult: + _id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + update: *replacement + comment: *comment + outcome: *outcome + + + - description: "findOneAndReplace with comment - pre 4.4" + runOnRequirements: + - minServerVersion: "4.2.0" # findAndModify option validation was introduced in 4.2 + maxServerVersion: "4.2.99" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: *filter + replacement: *replacement + comment: "comment" + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + update: *replacement + comment: "comment" + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-dots_and_dollars.yml new file mode 100644 index 00000000000..0823824cca6 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-dots_and_dollars.yml @@ -0,0 +1,140 @@ +description: "findOneAndReplace-dots_and_dollars" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - &initialDocument { _id: 1 } + +tests: + - description: "Replacing document with top-level dotted key on 3.6+ server" + runOnRequirements: + - minServerVersion: "3.6" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: { _id: 1 } + replacement: &dottedKey { _id: 1, a.b: 1 } + expectResult: *initialDocument + expectEvents: &expectEventsDottedKey + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: { _id: 1 } + update: *dottedKey + new: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dottedKey + + - description: "Replacing document with top-level dotted key on pre-3.6 server yields server-side error" + runOnRequirements: + - maxServerVersion: "3.4.99" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: { _id: 1 } + replacement: *dottedKey + expectError: + isClientError: false + expectEvents: *expectEventsDottedKey + outcome: *initialData + + - description: "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: { _id: 1 } + replacement: &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } } + expectResult: *initialDocument + expectEvents: &expectEventsDollarPrefixedKeyInEmbedded + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: { _id: 1 } + update: *dollarPrefixedKeyInEmbedded + new: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dollarPrefixedKeyInEmbedded + + - description: "Replacing document with dollar-prefixed key in embedded doc on pre-5.0 server yields server-side error" + runOnRequirements: + - maxServerVersion: "4.99" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: { _id: 1 } + replacement: *dollarPrefixedKeyInEmbedded + expectError: + isClientError: false + expectEvents: *expectEventsDollarPrefixedKeyInEmbedded + outcome: *initialData + + - description: "Replacing document with dotted key in embedded doc on 3.6+ server" + runOnRequirements: + - minServerVersion: "3.6" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: { _id: 1 } + replacement: &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } } + expectResult: *initialDocument + expectEvents: &expectEventsDottedKeyInEmbedded + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: { _id: 1 } + update: *dottedKeyInEmbedded + new: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dottedKeyInEmbedded + + - description: "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error" + runOnRequirements: + - maxServerVersion: "3.4.99" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: { _id: 1 } + replacement: *dottedKeyInEmbedded + expectError: + isClientError: false + expectEvents: *expectEventsDottedKeyInEmbedded + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-clientError.yml new file mode 100644 index 00000000000..a0a8f94beba --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-clientError.yml @@ -0,0 +1,80 @@ +description: findOneAndReplace-hint-clientError +schemaVersion: '1.0' +runOnRequirements: + - + maxServerVersion: 4.0.99 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name findOneAndReplace_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'FindOneAndReplace with hint string unsupported (client-side error)' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: &filter + _id: 1 + replacement: &replacement + x: 33 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + description: 'FindOneAndReplace with hint document unsupported (client-side error)' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: *filter + replacement: *replacement + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-serverError.yml new file mode 100644 index 00000000000..1fea6f364b2 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-serverError.yml @@ -0,0 +1,96 @@ +description: findOneAndReplace-hint-serverError +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.2.0 + maxServerVersion: 4.3.0 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name findOneAndReplace_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'FindOneAndReplace with hint string unsupported (server-side error)' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: &filter + _id: 1 + replacement: &replacement + x: 33 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: *filter + update: *replacement + hint: _id_ + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + description: 'FindOneAndReplace with hint document unsupported (server-side error)' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: *filter + replacement: *replacement + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: *filter + update: *replacement + hint: + _id: 1 + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-unacknowledged.yml new file mode 100644 index 00000000000..20a2737de24 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-unacknowledged.yml @@ -0,0 +1,96 @@ +description: findOneAndReplace-hint-unacknowledged + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + writeConcern: { w: 0 } + - collection: + id: &collection1 collection1 + database: *database0 + collectionName: *collection0Name + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: &documents + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + +tests: + - description: "Unacknowledged findOneAndReplace with hint string fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: findOneAndReplace + arguments: + filter: &filter { _id: { $gt: 1 } } + replacement: &replacement { x: 111 } + hint: _id_ + expectError: + isClientError: true + expectEvents: &noEvents + - client: *client0 + events: [] + + - description: "Unacknowledged findOneAndReplace with hint document fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: findOneAndReplace + arguments: + filter: *filter + replacement: *replacement + hint: { _id: 1 } + expectError: + isClientError: true + expectEvents: *noEvents + + - description: "Unacknowledged findOneAndReplace with hint string on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: findOneAndReplace + arguments: + filter: *filter + replacement: *replacement + hint: _id_ + expectResult: &unacknowledgedResult { $$unsetOrMatches: null } + expectEvents: &events + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + update: *replacement + hint: { $$type: [ string, object ]} + writeConcern: { w: 0 } + + - description: "Unacknowledged findOneAndReplace with hint document on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: findOneAndReplace + arguments: + filter: *filter + replacement: *replacement + hint: { _id: 1 } + expectResult: *unacknowledgedResult + expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint.yml new file mode 100644 index 00000000000..67fbf2cb2bf --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint.yml @@ -0,0 +1,95 @@ +description: findOneAndReplace-hint +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.3.1 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name findOneAndReplace_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'FindOneAndReplace with hint string' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: &filter + _id: 1 + replacement: &replacement + x: 33 + hint: _id_ + expectResult: &result + _id: 1 + x: 11 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: *filter + update: *replacement + hint: _id_ + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 33 + - + _id: 2 + x: 22 + - + description: 'FindOneAndReplace with hint document' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: *filter + replacement: *replacement + hint: + _id: 1 + expectResult: *result + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: *filter + update: *replacement + hint: + _id: 1 + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-let.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-let.yml new file mode 100644 index 00000000000..3ee1b7b672f --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-let.yml @@ -0,0 +1,94 @@ +description: "findOneAndReplace-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "findOneAndReplace with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + replacement: &replacement + x: "x" + let: &let0 + id: 1 + expectResult: + _id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + update: *replacement + let: *let0 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: "x" } + - { _id: 2 } + + - description: "findOneAndReplace with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "4.2.0" + maxServerVersion: "4.4.99" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: &filter1 + $expr: + $eq: [ "$_id", "$$id" ] + replacement: &replacement1 + x: "x" + let: &let1 + id: 1 + expectError: + # This error message is consistent between 4.2.x and 4.4.x servers. + # Older servers return a different error message. + errorContains: "field 'let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter1 + update: *replacement1 + let: *let1 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-upsert.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-upsert.yml new file mode 100644 index 00000000000..c52fdf11b17 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-upsert.yml @@ -0,0 +1,127 @@ +description: findOneAndReplace-upsert + +schemaVersion: '1.0' + +runOnRequirements: + - + minServerVersion: '2.6' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - + description: 'FindOneAndReplace when no documents match without id specified with upsert returning the document before modification' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: { _id: 4 } + replacement: { x: 44 } + projection: { x: 1, _id: 0 } + # Omit the sort option as it has no effect when no documents match and + # would only cause an inconsistent return value on pre-3.0 servers + # when combined with returnDocument "before" (see: SERVER-17650). + upsert: true + expectResult: null + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - + description: 'FindOneAndReplace when no documents match without id specified with upsert returning the document after modification' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: { _id: 4 } + replacement: { x: 44 } + projection: { x: 1, _id: 0 } + returnDocument: After + sort: { x: 1 } + upsert: true + expectResult: { x: 44 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - + description: 'FindOneAndReplace when no documents match with id specified with upsert returning the document before modification' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: { _id: 4 } + replacement: { _id: 4, x: 44 } + projection: { x: 1, _id: 0 } + # Omit the sort option as it has no effect when no documents match and + # would only cause an inconsistent return value on pre-3.0 servers + # when combined with returnDocument "before" (see: SERVER-17650). + upsert: true + expectResult: null + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } + - + description: 'FindOneAndReplace when no documents match with id specified with upsert returning the document after modification' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: { _id: 4 } + replacement: { _id: 4, x: 44 } + projection: { x: 1, _id: 0 } + returnDocument: After + sort: { x: 1 } + upsert: true + expectResult: { x: 44 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 44 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace.yml new file mode 100644 index 00000000000..ddfd533558d --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace.yml @@ -0,0 +1,152 @@ +description: findOneAndReplace + +schemaVersion: '1.0' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - + description: 'FindOneAndReplace when many documents match returning the document before modification' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: { _id: { $gt: 1 } } + replacement: { x: 32 } + projection: { x: 1, _id: 0 } + sort: { x: 1 } + expectResult: { x: 22 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 32 } + - { _id: 3, x: 33 } + - + description: 'FindOneAndReplace when many documents match returning the document after modification' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: { _id: { $gt: 1 } } + replacement: { x: 32 } + projection: { x: 1, _id: 0 } + returnDocument: After + sort: { x: 1 } + expectResult: { x: 32 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 32 } + - { _id: 3, x: 33 } + - + description: 'FindOneAndReplace when one document matches returning the document before modification' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: { _id: 2 } + replacement: { x: 32 } + projection: { x: 1, _id: 0 } + sort: { x: 1 } + expectResult: { x: 22 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 32 } + - { _id: 3, x: 33 } + - + description: 'FindOneAndReplace when one document matches returning the document after modification' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: { _id: 2 } + replacement: { x: 32 } + projection: { x: 1, _id: 0 } + returnDocument: After + sort: { x: 1 } + expectResult: { x: 32 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 32 } + - { _id: 3, x: 33 } + - + description: 'FindOneAndReplace when no documents match returning the document before modification' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: { _id: 4 } + replacement: { x: 44 } + projection: { x: 1, _id: 0 } + sort: { x: 1 } + expectResult: null + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - + description: 'FindOneAndReplace when no documents match returning the document after modification' + operations: + - + object: *collection0 + name: findOneAndReplace + arguments: + filter: { _id: 4 } + replacement: { x: 44 } + projection: { x: 1, _id: 0 } + returnDocument: After + sort: { x: 1 } + expectResult: null + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-arrayFilters.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-arrayFilters.yml new file mode 100644 index 00000000000..42e392c2c5c --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-arrayFilters.yml @@ -0,0 +1,89 @@ +description: findOneAndUpdate-arrayFilters + +schemaVersion: '1.0' + +runOnRequirements: + - + minServerVersion: 3.5.6 + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } + +tests: + - + description: 'FindOneAndUpdate when no document matches arrayFilters' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: { } + update: { $set: { 'y.$[i].b': 2 } } + arrayFilters: + - { i.b: 4 } + expectResult: { _id: 1, y: [ { b: 3 }, { b: 1 } ] } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } + - + description: 'FindOneAndUpdate when one document matches arrayFilters' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: { } + update: { $set: { 'y.$[i].b': 2 } } + arrayFilters: + - { i.b: 3 } + expectResult: { _id: 1, y: [ { b: 3 }, { b: 1 } ] } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 2 }, { b: 1 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } + - + description: 'FindOneAndUpdate when multiple documents match arrayFilters' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: { } + update: { $set: { 'y.$[i].b': 2 } } + arrayFilters: + - { i.b: 1 } + expectResult: { _id: 1, y: [ { b: 3 }, { b: 1 } ] } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 3 }, { b: 2 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-collation.yml new file mode 100644 index 00000000000..8b2048bc82c --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-collation.yml @@ -0,0 +1,58 @@ +description: findOneAndUpdate-collation + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '3.4' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: ping } + - { _id: 3, x: pINg } + +tests: + - + description: 'FindOneAndUpdate when many documents match with collation returning the document before modification' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: { x: PING } + update: { $set: { x: pong } } + projection: { x: 1, _id: 0 } + sort: { _id: 1 } + # https://www.mongodb.com/docs/manual/reference/collation/#collation-document + collation: + locale: en_US + strength: 2 + expectResult: { x: ping } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: pong } + - { _id: 3, x: pINg } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-comment.yml new file mode 100644 index 00000000000..66d2d099c1d --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-comment.yml @@ -0,0 +1,95 @@ +description: "findOneAndUpdate-comment" +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "findOneAndUpdate with string comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: &filter + _id: 1 + update: &update + - $set: {x: 5 } + comment: "comment" + expectResult: + _id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + update: *update + comment: "comment" + + - description: "findOneAndUpdate with document comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: &filter + _id: 1 + update: &update + - $set: {x: 5 } + comment: &comment { key: "value"} + expectResult: + _id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + update: *update + comment: *comment + + - description: "findOneAndUpdate with comment - pre 4.4" + runOnRequirements: + - minServerVersion: "4.2.0" # findAndModify option validation was introduced in 4.2 + maxServerVersion: "4.2.99" + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: *filter + update: *update + comment: "comment" + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + update: *update + comment: "comment" + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-dots_and_dollars.yml new file mode 100644 index 00000000000..69b46a15bc3 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-dots_and_dollars.yml @@ -0,0 +1,127 @@ +description: "findOneAndUpdate-dots_and_dollars" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - &initialDocument { _id: 1, foo: {} } + +tests: + - description: "Updating document to set top-level dollar-prefixed key on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: { _id: 1 } + update: &dollarPrefixedKey + - { $replaceWith: { $setField: { field: { $literal: $a }, value: 1, input: $$ROOT } } } + expectResult: *initialDocument + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: { _id: 1 } + update: *dollarPrefixedKey + new: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {}, $a: 1 } + + - description: "Updating document to set top-level dotted key on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: { _id: 1 } + update: &dottedKey + - { $replaceWith: { $setField: { field: { $literal: a.b }, value: 1, input: $$ROOT } } } + expectResult: *initialDocument + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: { _id: 1 } + update: *dottedKey + new: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {}, a.b: 1 } + + - description: "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: { _id: 1 } + update: &dollarPrefixedKeyInEmbedded + - { $set: { foo: { $setField: { field: { $literal: $a }, value: 1, input: $foo } } } } + expectResult: *initialDocument + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: { _id: 1 } + update: *dollarPrefixedKeyInEmbedded + new: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: { $a: 1 } } + + - description: "Updating document to set dotted key in embedded doc on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: { _id: 1 } + update: &dottedKeyInEmbedded + - { $set: { foo: { $setField: { field: { $literal: a.b }, value: 1, input: $foo } } } } + expectResult: *initialDocument + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: { _id: 1 } + update: *dottedKeyInEmbedded + new: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: { a.b: 1 } } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-errorResponse.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-errorResponse.yml new file mode 100644 index 00000000000..8faed768097 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-errorResponse.yml @@ -0,0 +1,69 @@ +description: "findOneAndUpdate-errorResponse" + +schemaVersion: "1.12" + +createEntities: + - client: + id: &client0 client0 + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name test + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: "foo" } + +tests: + - description: "findOneAndUpdate DuplicateKey error is accessible" + runOnRequirements: + - minServerVersion: "4.2" # SERVER-37124 + operations: + - name: createIndex + object: *collection0 + arguments: + keys: { x: 1 } + unique: true + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: { _id: 2 } + update: { $set: { x: "foo" } } + upsert: true + expectError: + errorCode: 11000 # DuplicateKey + errorResponse: + keyPattern: { x: 1 } + keyValue: { x: "foo" } + + - description: "findOneAndUpdate document validation errInfo is accessible" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: modifyCollection + object: *database0 + arguments: + collection: *collection0Name + validator: + x: { $type: "string" } + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: { _id: 1 } + update: { $set: { x: 1 } } + expectError: + errorCode: 121 # DocumentValidationFailure + errorResponse: + # Avoid asserting the exact contents of errInfo as it may vary by + # server version. Likewise, this is why drivers do not model the + # document. The following is sufficient to test that validation + # details are accessible. See SERVER-20547 for more context. + errInfo: + failingDocumentId: 1 + details: { $$type: "object" } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-clientError.yml new file mode 100644 index 00000000000..77b41a165c7 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-clientError.yml @@ -0,0 +1,81 @@ +description: findOneAndUpdate-hint-clientError +schemaVersion: '1.0' +runOnRequirements: + - + maxServerVersion: 4.0.99 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name findOneAndUpdate_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'FindOneAndUpdate with hint string unsupported (client-side error)' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: &filter + _id: 1 + update: &update + $inc: + x: 1 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + description: 'FindOneAndUpdate with hint document unsupported (client-side error)' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: *filter + update: *update + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-serverError.yml new file mode 100644 index 00000000000..13abba5f5cc --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-serverError.yml @@ -0,0 +1,97 @@ +description: findOneAndUpdate-hint-serverError +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.2.0 + maxServerVersion: 4.3.0 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name findOneAndUpdate_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'FindOneAndUpdate with hint string unsupported (server-side error)' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: &filter + _id: 1 + update: &update + $inc: + x: 1 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: *filter + update: *update + hint: _id_ + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + description: 'FindOneAndUpdate with hint document unsupported (server-side error)' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: *filter + update: *update + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: *filter + update: *update + hint: + _id: 1 + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-unacknowledged.yml new file mode 100644 index 00000000000..ec576375a6f --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-unacknowledged.yml @@ -0,0 +1,92 @@ +description: findOneAndUpdate-hint-unacknowledged + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + writeConcern: { w: 0 } + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: &documents + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + +tests: + - description: "Unacknowledged findOneAndUpdate with hint string fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: findOneAndUpdate + arguments: + filter: &filter { _id: { $gt: 1 } } + update: &update { $inc: { x: 1 } } + hint: _id_ + expectError: + isClientError: true + expectEvents: &noEvents + - client: *client0 + events: [] + + - description: "Unacknowledged findOneAndUpdate with hint document fails with client-side error on pre-4.4 server" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - object: *collection0 + name: findOneAndUpdate + arguments: + filter: *filter + update: *update + hint: { _id: 1 } + expectError: + isClientError: true + expectEvents: *noEvents + + - description: "Unacknowledged findOneAndUpdate with hint string on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: findOneAndUpdate + arguments: + filter: *filter + update: *update + hint: _id_ + expectResult: &unacknowledgedResult { $$unsetOrMatches: null } + expectEvents: &events + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + update: *update + hint: { $$type: [ string, object ]} + writeConcern: { w: 0 } + + - description: "Unacknowledged findOneAndUpdate with hint document on 4.4+ server" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - object: *collection0 + name: findOneAndUpdate + arguments: + filter: *filter + update: *update + hint: { _id: 1 } + expectResult: *unacknowledgedResult + expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint.yml new file mode 100644 index 00000000000..f7a3c33f083 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint.yml @@ -0,0 +1,96 @@ +description: findOneAndUpdate-hint +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.3.1 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name findOneAndUpdate_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'FindOneAndUpdate with hint string' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: &filter + _id: 1 + update: &update + $inc: + x: 1 + hint: _id_ + expectResult: &result + _id: 1 + x: 11 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: *filter + update: *update + hint: _id_ + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 12 + - + _id: 2 + x: 22 + - + description: 'FindOneAndUpdate with hint document' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: *filter + update: *update + hint: + _id: 1 + expectResult: *result + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: *filter + update: *update + hint: + _id: 1 + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-let.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-let.yml new file mode 100644 index 00000000000..761001db9ef --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-let.yml @@ -0,0 +1,96 @@ +description: "findOneAndUpdate-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "findOneAndUpdate with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + update: &update + - $set: {x: "$$x" } + let: &let0 + id: 1 + x: "foo" + expectResult: + _id: 1 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter + update: *update + let: *let0 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: "foo" } + - { _id: 2 } + + - description: "findOneAndUpdate with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "4.2.0" + maxServerVersion: "4.4.99" + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: &filter1 + $expr: + $eq: [ "$_id", "$$id" ] + update: &update1 + - $set: {x: "$$x"} + let: &let1 + id: 1 + x: "foo" + expectError: + # This error message is consistent between 4.2.x and 4.4.x servers. + # Older servers return a different error message. + errorContains: "field 'let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: *filter1 + update: *update1 + let: *let1 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate.yml new file mode 100644 index 00000000000..181c6b8b546 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate.yml @@ -0,0 +1,199 @@ +description: findOneAndUpdate + +schemaVersion: '1.0' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - + description: 'FindOneAndUpdate when many documents match returning the document before modification' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: { _id: { $gt: 1 } } + update: { $inc: { x: 1 } } + projection: { x: 1, _id: 0 } + sort: { x: 1 } + expectResult: { x: 22 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 23 } + - { _id: 3, x: 33 } + - + description: 'FindOneAndUpdate when many documents match returning the document after modification' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: { _id: { $gt: 1 } } + update: { $inc: { x: 1 } } + projection: { x: 1, _id: 0 } + returnDocument: After + sort: { x: 1 } + expectResult: { x: 23 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 23 } + - { _id: 3, x: 33 } + - + description: 'FindOneAndUpdate when one document matches returning the document before modification' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: { _id: 2 } + update: { $inc: { x: 1 } } + projection: { x: 1, _id: 0 } + sort: { x: 1 } + expectResult: { x: 22 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 23 } + - { _id: 3, x: 33 } + - + description: 'FindOneAndUpdate when one document matches returning the document after modification' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: { _id: 2 } + update: { $inc: { x: 1 } } + projection: { x: 1, _id: 0 } + returnDocument: After + sort: { x: 1 } + expectResult: { x: 23 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 23 } + - { _id: 3, x: 33 } + - + description: 'FindOneAndUpdate when no documents match returning the document before modification' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: { _id: 4 } + update: { $inc: { x: 1 } } + projection: { x: 1, _id: 0 } + sort: { x: 1 } + expectResult: null + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - + description: 'FindOneAndUpdate when no documents match with upsert returning the document before modification' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: { _id: 4 } + update: { $inc: { x: 1 } } + projection: { x: 1, _id: 0 } + # Omit the sort option as it has no effect when no documents match and + # would only cause an inconsistent return value on pre-3.0 servers + # when combined with returnDocument "before" (see: SERVER-17650). + upsert: true + expectResult: null + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 1 } + - + description: 'FindOneAndUpdate when no documents match returning the document after modification' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: { _id: 4 } + update: { $inc: { x: 1 } } + projection: { x: 1, _id: 0 } + returnDocument: After + sort: { x: 1 } + expectResult: null + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - + description: 'FindOneAndUpdate when no documents match with upsert returning the document after modification' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: { _id: 4 } + update: { $inc: { x: 1 } } + projection: { x: 1, _id: 0 } + returnDocument: After + sort: { x: 1 } + upsert: true + expectResult: { x: 1 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 1 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertMany-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/insertMany-comment.yml new file mode 100644 index 00000000000..4b51584df2b --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/insertMany-comment.yml @@ -0,0 +1,93 @@ +description: "insertMany-comment" +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + +tests: + - description: "insertMany with string comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: insertMany + object: *collection0 + arguments: + documents: + - &document { _id: 2, x: 22 } + comment: "comment" + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *document + comment: "comment" + outcome: &outcome + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + + - description: "insertMany with document comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: insertMany + object: *collection0 + arguments: + documents: + - *document + comment: &comment { key: "value" } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *document + comment: *comment + outcome: *outcome + + - description: "insertMany with comment - pre 4.4" + runOnRequirements: + - minServerVersion: "3.4.0" + maxServerVersion: "4.2.99" + operations: + - name: insertMany + object: *collection0 + arguments: + documents: + - *document + comment: "comment" + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *document + comment: "comment" + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertMany-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/insertMany-dots_and_dollars.yml new file mode 100644 index 00000000000..913a55e4c05 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/insertMany-dots_and_dollars.yml @@ -0,0 +1,128 @@ +description: "insertMany-dots_and_dollars" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: [] + +tests: + - description: "Inserting document with top-level dollar-prefixed key on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: insertMany + object: *collection0 + arguments: + documents: + - &dollarPrefixedKey { _id: 1, $a: 1 } + expectResult: &insertResult + # InsertManyResult is optional because all of its fields are optional + $$unsetOrMatches: { insertedIds: { $$unsetOrMatches: { 0: 1 } } } + expectEvents: &expectEventsDollarPrefixedKey + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dollarPrefixedKey + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dollarPrefixedKey + + - description: "Inserting document with top-level dollar-prefixed key on pre-5.0 server yields server-side error" + runOnRequirements: + - maxServerVersion: "4.99" + operations: + - name: insertMany + object: *collection0 + arguments: + documents: + - *dollarPrefixedKey + expectError: + isClientError: false + expectEvents: *expectEventsDollarPrefixedKey + outcome: *initialData + + - description: "Inserting document with top-level dotted key" + operations: + - name: insertMany + object: *collection0 + arguments: + documents: + - &dottedKey { _id: 1, a.b: 1 } + expectResult: *insertResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dottedKey + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dottedKey + + - description: "Inserting document with dollar-prefixed key in embedded doc" + operations: + - name: insertMany + object: *collection0 + arguments: + documents: + - &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } } + expectResult: *insertResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dollarPrefixedKeyInEmbedded + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dollarPrefixedKeyInEmbedded + + - description: "Inserting document with dotted key in embedded doc" + operations: + - name: insertMany + object: *collection0 + arguments: + documents: + - &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } } + expectResult: *insertResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dottedKeyInEmbedded + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dottedKeyInEmbedded diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertMany.yml b/driver-core/src/test/resources/unified-test-format/crud/insertMany.yml new file mode 100644 index 00000000000..ac4e868cc1d --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/insertMany.yml @@ -0,0 +1,118 @@ +description: insertMany + +schemaVersion: '1.0' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + +tests: + - + description: 'InsertMany with non-existing documents' + operations: + - + object: *collection0 + name: insertMany + arguments: + documents: + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + ordered: true + expectResult: + $$unsetOrMatches: + insertedIds: + $$unsetOrMatches: + '0': 2 + '1': 3 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - + description: 'InsertMany continue-on-error behavior with unordered (preexisting duplicate key)' + operations: + - + object: *collection0 + name: insertMany + arguments: + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + ordered: false + expectError: + isError: true + expectResult: + deletedCount: 0 + insertedCount: 2 + # Since the map of insertedIds is generated before execution it + # could indicate inserts that did not actually succeed. We omit this + # field rather than expect drivers to provide an accurate map + # filtered by write errors. + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + upsertedIds: { } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - + description: 'InsertMany continue-on-error behavior with unordered (duplicate key in requests)' + operations: + - + object: *collection0 + name: insertMany + arguments: + documents: + - { _id: 2, x: 22 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + ordered: false + expectError: + isError: true + expectResult: + deletedCount: 0 + insertedCount: 2 + # Since the map of insertedIds is generated before execution it + # could indicate inserts that did not actually succeed. We omit this + # field rather than expect drivers to provide an accurate map + # filtered by write errors. + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + upsertedIds: { } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertOne-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/insertOne-comment.yml new file mode 100644 index 00000000000..f8cb60ce85a --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/insertOne-comment.yml @@ -0,0 +1,91 @@ +description: "insertOne-comment" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + +tests: + - description: "insertOne with string comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: insertOne + object: *collection0 + arguments: + document: &document { _id: 2, x: 22 } + comment: "comment" + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *document + comment: "comment" + outcome: &outcome + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + + - description: "insertOne with document comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: insertOne + object: *collection0 + arguments: + document: *document + comment: &comment { key: "value" } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *document + comment: *comment + outcome: *outcome + + - description: "insertOne with comment - pre 4.4" + runOnRequirements: + - minServerVersion: "3.4.0" + maxServerVersion: "4.2.99" + operations: + - name: insertOne + object: *collection0 + arguments: + document: *document + comment: "comment" + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *document + comment: "comment" + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertOne-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/insertOne-dots_and_dollars.yml new file mode 100644 index 00000000000..fcfcfc71c6f --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/insertOne-dots_and_dollars.yml @@ -0,0 +1,238 @@ +description: "insertOne-dots_and_dollars" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + - collection: + id: &collection1 collection1 + database: *database0 + collectionName: &collection1Name coll1 + collectionOptions: + writeConcern: { w: 0 } + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: [] + +tests: + - description: "Inserting document with top-level dollar-prefixed key on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: insertOne + object: *collection0 + arguments: + document: &dollarPrefixedKey { _id: 1, $a: 1 } + expectResult: &insertResult + # InsertOneResult is optional because all of its fields are optional + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + expectEvents: &expectEventsDollarPrefixedKey + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dollarPrefixedKey + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dollarPrefixedKey + + - description: "Inserting document with top-level dollar-prefixed key on pre-5.0 server yields server-side error" + runOnRequirements: + - maxServerVersion: "4.99" + operations: + - name: insertOne + object: *collection0 + arguments: + document: *dollarPrefixedKey + expectError: + isClientError: false + expectEvents: *expectEventsDollarPrefixedKey + outcome: *initialData + + - description: "Inserting document with top-level dotted key" + operations: + - name: insertOne + object: *collection0 + arguments: + document: &dottedKey { _id: 1, a.b: 1 } + expectResult: *insertResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dottedKey + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dottedKey + + - description: "Inserting document with dollar-prefixed key in embedded doc" + operations: + - name: insertOne + object: *collection0 + arguments: + document: &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } } + expectResult: *insertResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dollarPrefixedKeyInEmbedded + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dollarPrefixedKeyInEmbedded + + - description: "Inserting document with dotted key in embedded doc" + operations: + - name: insertOne + object: *collection0 + arguments: + document: &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } } + expectResult: *insertResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dottedKeyInEmbedded + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dottedKeyInEmbedded + + - description: "Inserting document with dollar-prefixed key in _id yields server-side error" + # Note: 5.0+ did not remove restrictions on dollar-prefixed keys in _id documents + operations: + - name: insertOne + object: *collection0 + arguments: + document: &dollarPrefixedKeyInId { _id: { $a: 1 } } + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dollarPrefixedKeyInId + outcome: *initialData + + - description: "Inserting document with dotted key in _id on 3.6+ server" + runOnRequirements: + - minServerVersion: "3.6" + operations: + - name: insertOne + object: *collection0 + arguments: + document: &dottedKeyInId { _id: { a.b: 1 } } + expectResult: + # InsertOneResult is optional because all of its fields are optional + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: { a.b: 1 } } } + expectEvents: &expectEventsDottedKeyInId + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dottedKeyInId + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dottedKeyInId + + - description: "Inserting document with dotted key in _id on pre-3.6 server yields server-side error" + runOnRequirements: + - maxServerVersion: "3.4.99" + operations: + - name: insertOne + object: *collection0 + arguments: + document: *dottedKeyInId + expectError: + isClientError: false + expectEvents: *expectEventsDottedKeyInId + outcome: *initialData + + - description: "Inserting document with DBRef-like keys" + operations: + - name: insertOne + object: *collection0 + arguments: + # Note: an incomplete DBRef document may cause issues loading the test + # file with an Extended JSON parser, since the presence of one DBRef + # key may cause the parser to require others and/or enforce expected + # types (e.g. $ref and $db must be strings). + # + # Using "$db" here works for libmongoc so long as it's a string type; + # however, neither $ref nor $id would be accepted on their own. + # + # See https://github.com/mongodb/specifications/blob/master/source/extended-json.md#parsers + document: &dbrefLikeKey { _id: 1, a: { $db: "foo" } } + expectResult: *insertResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: + - *dbrefLikeKey + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dbrefLikeKey + + - description: "Unacknowledged write using dollar-prefixed or dotted keys may be silently rejected on pre-5.0 server" + runOnRequirements: + - maxServerVersion: "4.99" + operations: + - name: insertOne + object: *collection1 + arguments: + document: *dollarPrefixedKeyInId + expectResult: + # InsertOneResult is optional because all of its fields are optional + $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection1Name + documents: + - *dollarPrefixedKeyInId + writeConcern: { w: 0 } + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertOne-errorResponse.yml b/driver-core/src/test/resources/unified-test-format/crud/insertOne-errorResponse.yml new file mode 100644 index 00000000000..b14caa1737f --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/insertOne-errorResponse.yml @@ -0,0 +1,46 @@ +description: "insertOne-errorResponse" + +schemaVersion: "1.12" + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name test + +tests: + # Some drivers may still need to skip this test because the CRUD spec does not + # prescribe how drivers should formulate a WriteException beyond collecting a + # write or write concern error. + - description: "insert operations support errorResponse assertions" + runOnRequirements: + - minServerVersion: "4.0.0" + topologies: [ single, replicaset ] + - minServerVersion: "4.2.0" + topologies: [ sharded ] + operations: + - name: failPoint + object: testRunner + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: [ insert ] + errorCode: &errorCode 8 # UnknownError + - name: insertOne + object: *collection0 + arguments: + document: { _id: 1 } + expectError: + errorCode: *errorCode + errorResponse: + code: *errorCode diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertOne.yml b/driver-core/src/test/resources/unified-test-format/crud/insertOne.yml new file mode 100644 index 00000000000..85ab7fe9e0c --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/insertOne.yml @@ -0,0 +1,44 @@ +description: insertOne + +schemaVersion: '1.0' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + +tests: + - + description: 'InsertOne with a non-existing document' + operations: + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 2, x: 22 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-collation.yml new file mode 100644 index 00000000000..68eddcff91f --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-collation.yml @@ -0,0 +1,57 @@ +description: replaceOne-collation + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '3.4' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: ping } + +tests: + - + description: 'ReplaceOne when one document matches with collation' + operations: + - + object: *collection0 + name: replaceOne + arguments: + filter: { x: PING } + replacement: { _id: 2, x: pong } + # https://www.mongodb.com/docs/manual/reference/collation/#collation-document + collation: + locale: en_US + strength: 2 + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: pong } diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-comment.yml new file mode 100644 index 00000000000..2c22b287572 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-comment.yml @@ -0,0 +1,105 @@ +description: "replaceOne-comment" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + +tests: + - description: "ReplaceOne with string comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: &filter { _id: 1 } + replacement: &replacement { x: 22 } + comment: "comment" + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *replacement + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + comment: "comment" + outcome: &outcome + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 22 } + + - description: "ReplaceOne with document comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: *filter + replacement: *replacement + comment: &comment { key: "value" } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *replacement + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + comment: *comment + outcome: *outcome + + - description: "ReplaceOne with comment - pre 4.4" + runOnRequirements: + - minServerVersion: "3.4.0" + maxServerVersion: "4.2.99" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: *filter + replacement: *replacement + comment: "comment" + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *replacement + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + comment: "comment" + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-dots_and_dollars.yml new file mode 100644 index 00000000000..b834e222055 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-dots_and_dollars.yml @@ -0,0 +1,180 @@ +description: "replaceOne-dots_and_dollars" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + - collection: + id: &collection1 collection1 + database: *database0 + collectionName: &collection1Name coll1 + collectionOptions: + writeConcern: { w: 0 } + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + +tests: + - description: "Replacing document with top-level dotted key on 3.6+ server" + runOnRequirements: + - minServerVersion: "3.6" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: { _id: 1 } + replacement: &dottedKey { _id: 1, a.b: 1 } + expectResult: &replaceResult + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + expectEvents: &expectEventsDottedKey + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dottedKey + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dottedKey + + - description: "Replacing document with top-level dotted key on pre-3.6 server yields server-side error" + runOnRequirements: + - maxServerVersion: "3.4.99" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: { _id: 1 } + replacement: *dottedKey + expectError: + isClientError: false + expectEvents: *expectEventsDottedKey + outcome: *initialData + + - description: "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: { _id: 1 } + replacement: &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } } + expectResult: *replaceResult + expectEvents: &expectEventsDollarPrefixedKeyInEmbedded + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dollarPrefixedKeyInEmbedded + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dollarPrefixedKeyInEmbedded + + - description: "Replacing document with dollar-prefixed key in embedded doc on pre-5.0 server yields server-side error" + runOnRequirements: + - maxServerVersion: "4.99" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: { _id: 1 } + replacement: *dollarPrefixedKeyInEmbedded + expectError: + isClientError: false + expectEvents: *expectEventsDollarPrefixedKeyInEmbedded + outcome: *initialData + + - description: "Replacing document with dotted key in embedded doc on 3.6+ server" + runOnRequirements: + - minServerVersion: "3.6" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: { _id: 1 } + replacement: &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } } + expectResult: *replaceResult + expectEvents: &expectEventsDottedKeyInEmbedded + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dottedKeyInEmbedded + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - *dottedKeyInEmbedded + + - description: "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error" + runOnRequirements: + - maxServerVersion: "3.4.99" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: { _id: 1 } + replacement: *dottedKeyInEmbedded + expectError: + isClientError: false + expectEvents: *expectEventsDottedKeyInEmbedded + outcome: *initialData + + - description: "Unacknowledged write using dollar-prefixed or dotted keys may be silently rejected on pre-5.0 server" + runOnRequirements: + - maxServerVersion: "4.99" + operations: + - name: replaceOne + object: *collection1 + arguments: + filter: { _id: 1 } + replacement: *dollarPrefixedKeyInEmbedded + expectResult: + acknowledged: { $$unsetOrMatches: false } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection1Name + updates: + - q: { _id: 1 } + u: *dollarPrefixedKeyInEmbedded + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + writeConcern: { w: 0 } + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint-unacknowledged.yml new file mode 100644 index 00000000000..debb99b22ff --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint-unacknowledged.yml @@ -0,0 +1,95 @@ +description: replaceOne-hint-unacknowledged + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + writeConcern: { w: 0 } + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: &documents + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + +tests: + - description: "Unacknowledged replaceOne with hint string fails with client-side error on pre-4.2 server" + runOnRequirements: + - maxServerVersion: "4.0.99" + operations: + - object: *collection0 + name: replaceOne + arguments: + filter: &filter { _id: { $gt: 1 } } + replacement: &replacement { x: 111 } + hint: _id_ + expectError: + isClientError: true + expectEvents: &noEvents + - client: *client0 + events: [] + + - description: "Unacknowledged replaceOne with hint document fails with client-side error on pre-4.2 server" + runOnRequirements: + - maxServerVersion: "4.0.99" + operations: + - object: *collection0 + name: replaceOne + arguments: + filter: *filter + replacement: *replacement + hint: { _id: 1 } + expectError: + isClientError: true + expectEvents: *noEvents + + - description: "Unacknowledged replaceOne with hint string on 4.2+ server" + runOnRequirements: + - minServerVersion: "4.2.0" + operations: + - object: *collection0 + name: replaceOne + arguments: + filter: *filter + replacement: *replacement + hint: _id_ + expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } + expectEvents: &events + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *replacement + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + hint: { $$type: [ string, object ]} + writeConcern: { w: 0 } + + - description: "Unacknowledged replaceOne with hint document on 4.2+ server" + runOnRequirements: + - minServerVersion: "4.2.0" + operations: + - object: *collection0 + name: replaceOne + arguments: + filter: *filter + replacement: *replacement + hint: { _id: 1 } + expectResult: *unacknowledgedResult + expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint.yml new file mode 100644 index 00000000000..263e372170a --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint.yml @@ -0,0 +1,105 @@ +description: replaceOne-hint +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.2.0 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_replaceone_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'ReplaceOne with hint string' + operations: + - + object: *collection0 + name: replaceOne + arguments: + filter: &filter + _id: + $gt: 1 + replacement: &replacement + x: 111 + hint: _id_ + expectResult: &result + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *filter + u: *replacement + hint: _id_ + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 111 + - + description: 'ReplaceOne with hint document' + operations: + - + object: *collection0 + name: replaceOne + arguments: + filter: *filter + replacement: *replacement + hint: + _id: 1 + expectResult: *result + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *filter + u: *replacement + hint: + _id: 1 + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-let.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-let.yml new file mode 100644 index 00000000000..fda5bb67441 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-let.yml @@ -0,0 +1,98 @@ +description: "replaceOne-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "ReplaceOne with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + replacement: &replacement + x: "foo" + let: &let + id: 1 + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *replacement + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + let: *let + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: "foo" } + - { _id: 2 } + + - description: "ReplaceOne with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "3.6.0" + maxServerVersion: "4.4.99" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: *filter + replacement: *replacement + let: *let + expectError: + errorContains: "'update.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *replacement + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + let: *let + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-sort.json b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-sort.json new file mode 100644 index 00000000000..cf2271dda57 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-sort.json @@ -0,0 +1,232 @@ +{ + "description": "replaceOne-sort", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent", + "commandSucceededEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ], + "tests": [ + { + "description": "ReplaceOne with sort option", + "runOnRequirements": [ + { + "minServerVersion": "8.0" + } + ], + "operations": [ + { + "name": "replaceOne", + "object": "collection0", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "sort": { + "_id": -1 + }, + "replacement": { + "x": 1 + } + }, + "expectResult": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": { + "$gt": 1 + } + }, + "u": { + "x": 1 + }, + "sort": { + "_id": -1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + } + } + }, + { + "commandSucceededEvent": { + "reply": { + "ok": 1, + "n": 1 + }, + "commandName": "update" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 1 + } + ] + } + ] + }, + { + "description": "replaceOne with sort option unsupported (server-side error)", + "runOnRequirements": [ + { + "maxServerVersion": "7.99" + } + ], + "operations": [ + { + "name": "replaceOne", + "object": "collection0", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "sort": { + "_id": -1 + }, + "replacement": { + "x": 1 + } + }, + "expectError": { + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": { + "$gt": 1 + } + }, + "u": { + "x": 1 + }, + "sort": { + "_id": -1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + } + ] +} diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-sort.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-sort.yml new file mode 100644 index 00000000000..f4b10fbaf98 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-sort.yml @@ -0,0 +1,94 @@ +description: replaceOne-sort + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent, commandSucceededEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: ReplaceOne with sort option + runOnRequirements: + - minServerVersion: "8.0" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: { _id: { $gt: 1 } } + sort: { _id: -1 } + replacement: { x: 1 } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: { $gt: 1 } } + u: { x: 1 } + sort: { _id: -1 } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + - commandSucceededEvent: + reply: { ok: 1, n: 1 } + commandName: update + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 1 } + + - description: replaceOne with sort option unsupported (server-side error) + runOnRequirements: + - maxServerVersion: "7.99" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: { _id: { $gt: 1 } } + sort: { _id: -1 } + replacement: { x: 1 } + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: { $gt: 1 } } + u: { x: 1 } + sort: { _id: -1 } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-validation.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-validation.yml new file mode 100644 index 00000000000..db5a2a6666c --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-validation.yml @@ -0,0 +1,37 @@ +description: "replaceOne-validation" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + +tests: + - description: "ReplaceOne prohibits atomic modifiers" + operations: + - name: replaceOne + object: *collection0 + arguments: + filter: { _id: 1 } + replacement: { $set: { x: 22 } } + expectError: + isClientError: true + expectEvents: + - client: *client0 + events: [] + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne.yml new file mode 100644 index 00000000000..ebe0af933ec --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/replaceOne.yml @@ -0,0 +1,138 @@ +description: replaceOne + +schemaVersion: '1.0' + +runOnRequirements: + - + minServerVersion: '2.6' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - + # This test doesn't verify the output collection because we cannot assume + # which document gets replaced. + description: 'ReplaceOne when many documents match' + operations: + - + object: *collection0 + name: replaceOne + arguments: + filter: { _id: { $gt: 1 } } + replacement: { x: 111 } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + - + description: 'ReplaceOne when one document matches' + operations: + - + object: *collection0 + name: replaceOne + arguments: + filter: { _id: 1 } + replacement: { _id: 1, x: 111 } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 111 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - + description: 'ReplaceOne when no documents match' + operations: + - + object: *collection0 + name: replaceOne + arguments: + filter: { _id: 4 } + replacement: { _id: 4, x: 1 } + expectResult: + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - + description: 'ReplaceOne with upsert when no documents match without an id specified' + operations: + - + object: *collection0 + name: replaceOne + arguments: + filter: { _id: 4 } + replacement: { x: 1 } + upsert: true + expectResult: + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 1 + upsertedId: 4 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 1 } + - + description: 'ReplaceOne with upsert when no documents match with an id specified' + operations: + - + object: *collection0 + name: replaceOne + arguments: + filter: { _id: 4 } + replacement: { _id: 4, x: 1 } + upsert: true + expectResult: + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 1 + upsertedId: 4 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 1 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-arrayFilters.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-arrayFilters.yml new file mode 100644 index 00000000000..db5ec29c885 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateMany-arrayFilters.yml @@ -0,0 +1,98 @@ +description: updateMany-arrayFilters + +schemaVersion: '1.0' + +runOnRequirements: + - + minServerVersion: 3.5.6 + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } + +tests: + - + description: 'UpdateMany when no documents match arrayFilters' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: { } + update: { $set: { 'y.$[i].b': 2 } } + arrayFilters: + - { i.b: 4 } + expectResult: + matchedCount: 2 + modifiedCount: 0 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } + - + description: 'UpdateMany when one document matches arrayFilters' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: { } + update: { $set: { 'y.$[i].b': 2 } } + arrayFilters: + - { i.b: 3 } + expectResult: + matchedCount: 2 + modifiedCount: 1 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 2 }, { b: 1 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } + - + description: 'UpdateMany when multiple documents match arrayFilters' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: { } + update: { $set: { 'y.$[i].b': 2 } } + arrayFilters: + - { i.b: 1 } + expectResult: + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 3 }, { b: 2 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 2 } ] } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-collation.yml new file mode 100644 index 00000000000..af5221c02ed --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateMany-collation.yml @@ -0,0 +1,59 @@ +description: updateMany-collation + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '3.4' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: ping } + - { _id: 3, x: pINg } + +tests: + - + description: 'UpdateMany when many documents match with collation' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: { x: ping } + update: { $set: { x: pong } } + # https://www.mongodb.com/docs/manual/reference/collation/#collation-document + collation: + locale: en_US + strength: 2 + expectResult: + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: pong } + - { _id: 3, x: pong } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-comment.yml new file mode 100644 index 00000000000..4c6fbacd771 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateMany-comment.yml @@ -0,0 +1,104 @@ +description: "updateMany-comment" +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + +tests: + - description: "UpdateMany with string comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: &filter { _id: 1 } + update: &update { $set: {x: 22} } + comment: "comment" + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *update + multi: true + upsert: { $$unsetOrMatches: false } + comment: "comment" + outcome: &outcome + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 22 } + + - description: "UpdateMany with document comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: *filter + update: *update + comment: &comment { key: "value" } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *update + multi: true + upsert: { $$unsetOrMatches: false } + comment: *comment + outcome: *outcome + + - description: "UpdateMany with comment - pre 4.4" + runOnRequirements: + - minServerVersion: "3.4.0" + maxServerVersion: "4.2.99" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: *filter + update: *update + comment: "comment" + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *update + multi: true + upsert: { $$unsetOrMatches: false } + comment: "comment" + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-dots_and_dollars.yml new file mode 100644 index 00000000000..6c9da82a5ad --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateMany-dots_and_dollars.yml @@ -0,0 +1,138 @@ +description: "updateMany-dots_and_dollars" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {} } + +tests: + - description: "Updating document to set top-level dollar-prefixed key on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: { _id: 1 } + update: &dollarPrefixedKey + - { $replaceWith: { $setField: { field: { $literal: $a }, value: 1, input: $$ROOT } } } + expectResult: &updateResult + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dollarPrefixedKey + multi: true + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {}, $a: 1 } + + - description: "Updating document to set top-level dotted key on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: { _id: 1 } + update: &dottedKey + - { $replaceWith: { $setField: { field: { $literal: a.b }, value: 1, input: $$ROOT } } } + expectResult: *updateResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dottedKey + multi: true + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {}, a.b: 1 } + + - description: "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: { _id: 1 } + update: &dollarPrefixedKeyInEmbedded + - { $set: { foo: { $setField: { field: { $literal: $a }, value: 1, input: $foo } } } } + expectResult: *updateResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dollarPrefixedKeyInEmbedded + multi: true + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: { $a: 1 } } + + - description: "Updating document to set dotted key in embedded doc on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: { _id: 1 } + update: &dottedKeyInEmbedded + - { $set: { foo: { $setField: { field: { $literal: a.b }, value: 1, input: $foo } } } } + expectResult: *updateResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dottedKeyInEmbedded + multi: true + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: { a.b: 1 } } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-clientError.yml new file mode 100644 index 00000000000..163168ecfab --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-clientError.yml @@ -0,0 +1,88 @@ +description: updateMany-hint-clientError +schemaVersion: '1.0' +runOnRequirements: + - + maxServerVersion: 3.3.99 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_updatemany_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 +tests: + - + description: 'UpdateMany with hint string unsupported (client-side error)' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: &filter + _id: + $gt: 1 + update: &update + $inc: + x: 1 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + description: 'UpdateMany with hint document unsupported (client-side error)' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: *filter + update: *update + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-serverError.yml new file mode 100644 index 00000000000..61d7179fc03 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-serverError.yml @@ -0,0 +1,112 @@ +description: updateMany-hint-serverError +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 3.4.0 + maxServerVersion: 4.1.9 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_updatemany_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 +tests: + - + description: 'UpdateMany with hint string unsupported (server-side error)' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: &filter + _id: + $gt: 1 + update: &update + $inc: + x: 1 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *filter + u: *update + multi: true + hint: _id_ + upsert: { $$unsetOrMatches: false } + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 + - + description: 'UpdateMany with hint document unsupported (server-side error)' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: *filter + update: *update + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *filter + u: *update + multi: true + hint: + _id: 1 + upsert: { $$unsetOrMatches: false } + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-unacknowledged.yml new file mode 100644 index 00000000000..9f152973858 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-unacknowledged.yml @@ -0,0 +1,96 @@ +description: updateMany-hint-unacknowledged + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + writeConcern: { w: 0 } + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: &documents + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: "Unacknowledged updateMany with hint string fails with client-side error on pre-4.2 server" + runOnRequirements: + - maxServerVersion: "4.0.99" + operations: + - object: *collection0 + name: updateMany + arguments: + filter: &filter { _id: { $gt: 1 } } + update: &update { $inc: { x: 1 } } + hint: _id_ + expectError: + isClientError: true + expectEvents: &noEvents + - client: *client0 + events: [] + + - description: "Unacknowledged updateMany with hint document fails with client-side error on pre-4.2 server" + runOnRequirements: + - maxServerVersion: "4.0.99" + operations: + - object: *collection0 + name: updateMany + arguments: + filter: *filter + update: *update + hint: { _id: 1 } + expectError: + isClientError: true + expectEvents: *noEvents + + - description: "Unacknowledged updateMany with hint string on 4.2+ server" + runOnRequirements: + - minServerVersion: "4.2.0" + operations: + - object: *collection0 + name: updateMany + arguments: + filter: *filter + update: *update + hint: _id_ + expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } + expectEvents: &events + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *update + multi: true + upsert: { $$unsetOrMatches: false } + hint: { $$type: [ string, object ]} + writeConcern: { w: 0 } + + - description: "Unacknowledged updateMany with hint document on 4.2+ server" + runOnRequirements: + - minServerVersion: "4.2.0" + operations: + - object: *collection0 + name: updateMany + arguments: + filter: *filter + update: *update + hint: { _id: 1 } + expectResult: *unacknowledgedResult + expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint.yml new file mode 100644 index 00000000000..e5950309236 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint.yml @@ -0,0 +1,112 @@ +description: updateMany-hint +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.2.0 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_updatemany_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + _id: 3 + x: 33 +tests: + - + description: 'UpdateMany with hint string' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: &filter + _id: + $gt: 1 + update: &update + $inc: + x: 1 + hint: _id_ + expectResult: &result + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *filter + u: *update + multi: true + hint: _id_ + upsert: { $$unsetOrMatches: false } + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 23 + - + _id: 3 + x: 34 + - + description: 'UpdateMany with hint document' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: *filter + update: *update + hint: + _id: 1 + expectResult: *result + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *filter + u: *update + multi: true + hint: + _id: 1 + upsert: { $$unsetOrMatches: false } + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-let.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-let.yml new file mode 100644 index 00000000000..402000967bf --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateMany-let.yml @@ -0,0 +1,107 @@ +description: "updateMany-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2, name: "name" } + - { _id: 3, name: "name" } + + +tests: + - description: "updateMany with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$name", "$$name" ] + update: &update + - $set: {x: "$$x", y: "$$y" } + let: &let0 + name: name + x: foo + y: { $literal: "bar" } + expectResult: + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *update + multi: true + upsert: { $$unsetOrMatches: false } + let: *let0 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2, name: "name", x: "foo", y: "bar" } + - { _id: 3, name: "name", x: "foo", y: "bar" } + + - description: "updateMany with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "4.2.0" + maxServerVersion: "4.4.99" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: &filter1 + _id: 1 + update: &update1 + - $set: {x: "$$x"} + let: &let1 + x: foo + expectError: + errorContains: "'update.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter1 + u: *update1 + multi: true + upsert: { $$unsetOrMatches: false } + let: *let1 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2, name: "name" } + - { _id: 3, name: "name" } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-validation.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-validation.yml new file mode 100644 index 00000000000..4e86eff1f37 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateMany-validation.yml @@ -0,0 +1,39 @@ +description: "updateMany-validation" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: "UpdateMany requires atomic modifiers" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: { _id: { $gt: 1 } } + update: { x: 44 } + expectError: + isClientError: true + expectEvents: + - client: *client0 + events: [] + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany.yml new file mode 100644 index 00000000000..98f29d45e85 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateMany.yml @@ -0,0 +1,120 @@ +description: updateMany + +schemaVersion: '1.0' + +runOnRequirements: + - + minServerVersion: '2.6' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - + description: 'UpdateMany when many documents match' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: { _id: { $gt: 1 } } + update: { $inc: { x: 1 } } + expectResult: + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 23 } + - { _id: 3, x: 34 } + - + description: 'UpdateMany when one document matches' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: { _id: 1 } + update: { $inc: { x: 1 } } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 12 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - + description: 'UpdateMany when no documents match' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: { _id: 4 } + update: { $inc: { x: 1 } } + expectResult: + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - + description: 'UpdateMany with upsert when no documents match' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: { _id: 4 } + update: { $inc: { x: 1 } } + upsert: true + expectResult: + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 1 + upsertedId: 4 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 1 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-arrayFilters.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-arrayFilters.yml new file mode 100644 index 00000000000..8d5b238befb --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne-arrayFilters.yml @@ -0,0 +1,150 @@ +description: updateOne-arrayFilters + +schemaVersion: '1.0' + +runOnRequirements: + - + minServerVersion: 3.5.6 + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } + - { _id: 3, y: [ { b: 5, c: [ { d: 2 }, { d: 1 } ] } ] } + +tests: + - + description: 'UpdateOne when no document matches arrayFilters' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: { } + update: { $set: { 'y.$[i].b': 2 } } + arrayFilters: + - { i.b: 4 } + expectResult: + matchedCount: 1 + modifiedCount: 0 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } + - { _id: 3, y: [ { b: 5, c: [ { d: 2 }, { d: 1 } ] } ] } + - + description: 'UpdateOne when one document matches arrayFilters' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: { } + update: { $set: { 'y.$[i].b': 2 } } + arrayFilters: + - { i.b: 3 } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 2 }, { b: 1 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } + - { _id: 3, y: [ { b: 5, c: [ { d: 2 }, { d: 1 } ] } ] } + - + description: 'UpdateOne when multiple documents match arrayFilters' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: { } + update: { $set: { 'y.$[i].b': 2 } } + arrayFilters: + - { i.b: 1 } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 3 }, { b: 2 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } + - { _id: 3, y: [ { b: 5, c: [ { d: 2 }, { d: 1 } ] } ] } + - + description: 'UpdateOne when no documents match multiple arrayFilters' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: { _id: 3 } + update: { $set: { 'y.$[i].c.$[j].d': 0 } } + arrayFilters: + - { i.b: 5 } + - { j.d: 3 } + expectResult: + matchedCount: 1 + modifiedCount: 0 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } + - { _id: 3, y: [ { b: 5, c: [ { d: 2 }, { d: 1 } ] } ] } + - + description: 'UpdateOne when one document matches multiple arrayFilters' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: { _id: 3 } + update: { $set: { 'y.$[i].c.$[j].d': 0 } } + arrayFilters: + - { i.b: 5 } + - { j.d: 1 } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } + - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } + - { _id: 3, y: [ { b: 5, c: [ { d: 2 }, { d: 0 } ] } ] } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-collation.yml new file mode 100644 index 00000000000..85c2b552959 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne-collation.yml @@ -0,0 +1,57 @@ +description: updateOne-collation + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '3.4' + serverless: forbid + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: ping } + +tests: + - + description: 'UpdateOne when one document matches with collation' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: { x: PING } + update: { $set: { x: pong } } + # https://www.mongodb.com/docs/manual/reference/collation/#collation-document + collation: + locale: en_US + strength: 2 + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: pong } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-comment.yml new file mode 100644 index 00000000000..a176d620ebd --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne-comment.yml @@ -0,0 +1,104 @@ +description: "updateOne-comment" +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + +tests: + - description: "UpdateOne with string comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: &filter { _id: 1 } + update: &update { $set: {x: 22} } + comment: "comment" + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *update + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + comment: "comment" + outcome: &outcome + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 22 } + + - description: "UpdateOne with document comment" + runOnRequirements: + - minServerVersion: "4.4" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: *filter + update: *update + comment: &comment { key: "value" } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *update + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + comment: *comment + outcome: *outcome + + - description: "UpdateOne with comment - pre 4.4" + runOnRequirements: + - minServerVersion: "3.4.0" + maxServerVersion: "4.2.99" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: *filter + update: *update + comment: "comment" + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *update + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + comment: "comment" + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-dots_and_dollars.yml new file mode 100644 index 00000000000..9ff8a38d736 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne-dots_and_dollars.yml @@ -0,0 +1,138 @@ +description: "updateOne-dots_and_dollars" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {} } + +tests: + - description: "Updating document to set top-level dollar-prefixed key on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: { _id: 1 } + update: &dollarPrefixedKey + - { $replaceWith: { $setField: { field: { $literal: $a }, value: 1, input: $$ROOT } } } + expectResult: &updateResult + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dollarPrefixedKey + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {}, $a: 1 } + + - description: "Updating document to set top-level dotted key on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: { _id: 1 } + update: &dottedKey + - { $replaceWith: { $setField: { field: { $literal: a.b }, value: 1, input: $$ROOT } } } + expectResult: *updateResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dottedKey + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: {}, a.b: 1 } + + - description: "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: { _id: 1 } + update: &dollarPrefixedKeyInEmbedded + - { $set: { foo: { $setField: { field: { $literal: $a }, value: 1, input: $foo } } } } + expectResult: *updateResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dollarPrefixedKeyInEmbedded + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: { $a: 1 } } + + - description: "Updating document to set dotted key in embedded doc on 5.0+ server" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: { _id: 1 } + update: &dottedKeyInEmbedded + - { $set: { foo: { $setField: { field: { $literal: a.b }, value: 1, input: $foo } } } } + expectResult: *updateResult + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: 1 } + u: *dottedKeyInEmbedded + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, foo: { a.b: 1 } } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-errorResponse.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-errorResponse.yml new file mode 100644 index 00000000000..6d42195b0bc --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne-errorResponse.yml @@ -0,0 +1,47 @@ +description: "updateOne-errorResponse" + +schemaVersion: "1.12" + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name test + +tests: + # Some drivers may still need to skip this test because the CRUD spec does not + # prescribe how drivers should formulate a WriteException beyond collecting a + # write or write concern error. + - description: "update operations support errorResponse assertions" + runOnRequirements: + - minServerVersion: "4.0.0" + topologies: [ single, replicaset ] + - minServerVersion: "4.2.0" + topologies: [ sharded ] + operations: + - name: failPoint + object: testRunner + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: [ update ] + errorCode: &errorCode 8 # UnknownError + - name: updateOne + object: *collection0 + arguments: + filter: { _id: 1 } + update: { $set: { x: 1 } } + expectError: + errorCode: *errorCode + errorResponse: + code: *errorCode diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-clientError.yml new file mode 100644 index 00000000000..5107b5f4b50 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-clientError.yml @@ -0,0 +1,82 @@ +description: updateOne-hint-clientError +schemaVersion: '1.0' +runOnRequirements: + - + maxServerVersion: 3.3.99 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_updateone_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'UpdateOne with hint string unsupported (client-side error)' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: &filter + _id: + $gt: 1 + update: &update + $inc: + x: 1 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + description: 'UpdateOne with hint document unsupported (client-side error)' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: *filter + update: *update + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: [] + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-serverError.yml new file mode 100644 index 00000000000..f9681ab8257 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-serverError.yml @@ -0,0 +1,106 @@ +description: updateOne-hint-serverError +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 3.4.0 + maxServerVersion: 4.1.9 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_updateone_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'UpdateOne with hint string unsupported (server-side error)' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: &filter + _id: + $gt: 1 + update: &update + $inc: + x: 1 + hint: _id_ + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *filter + u: *update + hint: _id_ + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 + - + description: 'UpdateOne with hint document unsupported (server-side error)' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: *filter + update: *update + hint: + _id: 1 + expectError: + isError: true + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *filter + u: *update + hint: + _id: 1 + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-unacknowledged.yml new file mode 100644 index 00000000000..77802db0012 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-unacknowledged.yml @@ -0,0 +1,95 @@ +description: updateOne-hint-unacknowledged + +schemaVersion: '1.0' + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name db0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + collectionOptions: + writeConcern: { w: 0 } + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: &documents + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + +tests: + - description: "Unacknowledged updateOne with hint string fails with client-side error on pre-4.2 server" + runOnRequirements: + - maxServerVersion: "4.0.99" + operations: + - object: *collection0 + name: updateOne + arguments: + filter: &filter { _id: { $gt: 1 } } + update: &update { $inc: { x: 1 } } + hint: _id_ + expectError: + isClientError: true + expectEvents: &noEvents + - client: *client0 + events: [] + + - description: "Unacknowledged updateOne with hint document fails with client-side error on pre-4.2 server" + runOnRequirements: + - maxServerVersion: "4.0.99" + operations: + - object: *collection0 + name: updateOne + arguments: + filter: *filter + update: *update + hint: { _id: 1 } + expectError: + isClientError: true + expectEvents: *noEvents + + - description: "Unacknowledged updateOne with hint string on 4.2+ server" + runOnRequirements: + - minServerVersion: "4.2.0" + operations: + - object: *collection0 + name: updateOne + arguments: + filter: *filter + update: *update + hint: _id_ + expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } + expectEvents: &events + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *update + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + hint: { $$type: [ string, object ]} + writeConcern: { w: 0 } + + - description: "Unacknowledged updateOne with hint document on 4.2+ server" + runOnRequirements: + - minServerVersion: "4.2.0" + operations: + - object: *collection0 + name: updateOne + arguments: + filter: *filter + update: *update + hint: { _id: 1 } + expectResult: *unacknowledgedResult + expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint.yml new file mode 100644 index 00000000000..bd60cd7a199 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint.yml @@ -0,0 +1,106 @@ +description: updateOne-hint +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.2.0 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v2 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test_updateone_hint +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 22 +tests: + - + description: 'UpdateOne with hint string' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: &filter + _id: + $gt: 1 + update: &update + $inc: + x: 1 + hint: _id_ + expectResult: &result + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *filter + u: *update + hint: _id_ + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 11 + - + _id: 2 + x: 23 + - + description: 'UpdateOne with hint document' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: *filter + update: *update + hint: + _id: 1 + expectResult: *result + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: *filter + u: *update + hint: + _id: 1 + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-let.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-let.yml new file mode 100644 index 00000000000..0044fdac66d --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne-let.yml @@ -0,0 +1,102 @@ +description: "updateOne-let" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } + +tests: + - description: "UpdateOne with let option" + runOnRequirements: + - minServerVersion: "5.0" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: &filter + $expr: + $eq: [ "$_id", "$$id" ] + update: &update + - $set: {x: "$$x" } + let: &let0 + id: 1 + x: "foo" + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter + u: *update + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + let: *let0 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: "foo" } + - { _id: 2 } + + - description: "UpdateOne with let option unsupported (server-side error)" + runOnRequirements: + - minServerVersion: "4.2.0" + maxServerVersion: "4.4.99" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: &filter1 + _id: 1 + update: &update1 + - $set: {x: "$$x"} + let: &let1 + x: foo + expectError: + errorContains: "'update.let' is an unknown field" + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - + q: *filter1 + u: *update1 + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + let: *let1 + outcome: + - + collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1 } + - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-sort.json b/driver-core/src/test/resources/unified-test-format/crud/updateOne-sort.json new file mode 100644 index 00000000000..8fe4f50b94f --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne-sort.json @@ -0,0 +1,240 @@ +{ + "description": "updateOne-sort", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent", + "commandSucceededEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ], + "tests": [ + { + "description": "UpdateOne with sort option", + "runOnRequirements": [ + { + "minServerVersion": "8.0" + } + ], + "operations": [ + { + "name": "updateOne", + "object": "collection0", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "sort": { + "_id": -1 + }, + "update": { + "$inc": { + "x": 1 + } + } + }, + "expectResult": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": { + "$gt": 1 + } + }, + "u": { + "$inc": { + "x": 1 + } + }, + "sort": { + "_id": -1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + } + } + }, + { + "commandSucceededEvent": { + "reply": { + "ok": 1, + "n": 1 + }, + "commandName": "update" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 34 + } + ] + } + ] + }, + { + "description": "updateOne with sort option unsupported (server-side error)", + "runOnRequirements": [ + { + "maxServerVersion": "7.99" + } + ], + "operations": [ + { + "name": "updateOne", + "object": "collection0", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "sort": { + "_id": -1 + }, + "update": { + "$inc": { + "x": 1 + } + } + }, + "expectError": { + "isClientError": false + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": { + "_id": { + "$gt": 1 + } + }, + "u": { + "$inc": { + "x": 1 + } + }, + "sort": { + "_id": -1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + } + ] +} diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-sort.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-sort.yml new file mode 100644 index 00000000000..a14e1df1d2b --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne-sort.yml @@ -0,0 +1,96 @@ +description: updateOne-sort + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - commandSucceededEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - description: UpdateOne with sort option + runOnRequirements: + - minServerVersion: "8.0" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: { _id: { $gt: 1 } } + sort: { _id: -1 } + update: { $inc: { x: 1 } } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: { $gt: 1 } } + u: { $inc: { x: 1 } } + sort: { _id: -1 } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + - commandSucceededEvent: + reply: { ok: 1, n: 1 } + commandName: update + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 34 } + + - description: updateOne with sort option unsupported (server-side error) + runOnRequirements: + - maxServerVersion: "7.99" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: { _id: { $gt: 1 } } + sort: { _id: -1 } + update: { $inc: { x: 1 } } + expectError: + isClientError: false + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: { _id: { $gt: 1 } } + u: { $inc: { x: 1 } } + sort: { _id: -1 } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + outcome: + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-validation.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-validation.yml new file mode 100644 index 00000000000..b6f49a65683 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne-validation.yml @@ -0,0 +1,37 @@ +description: "updateOne-validation" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +initialData: &initialData + - collectionName: *collection0Name + databaseName: *database0Name + documents: + - { _id: 1, x: 11 } + +tests: + - description: "UpdateOne requires atomic modifiers" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: { _id: 1 } + update: { x: 22 } + expectError: + isClientError: true + expectEvents: + - client: *client0 + events: [] + outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne.yml new file mode 100644 index 00000000000..2f8f6a91815 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateOne.yml @@ -0,0 +1,114 @@ +description: updateOne + +schemaVersion: '1.0' + +runOnRequirements: + - + minServerVersion: '2.6' + +createEntities: + - + client: + id: &client0 client0 + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-v1 + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name coll + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + +tests: + - + # This test doesn't verify the output collection because we cannot assume + # which document gets updated. + description: 'UpdateOne when many documents match' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: { _id: { $gt: 1 } } + update: { $inc: { x: 1 } } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + - + description: 'UpdateOne when one document matches' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: { _id: 1 } + update: { $inc: { x: 1 } } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 12 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - + description: 'UpdateOne when no documents match' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: { _id: 4 } + update: { $inc: { x: 1 } } + expectResult: + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - + description: 'UpdateOne with upsert when no documents match' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: { _id: 4 } + update: { $inc: { x: 1 } } + upsert: true + expectResult: + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 1 + upsertedId: 4 + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, x: 11 } + - { _id: 2, x: 22 } + - { _id: 3, x: 33 } + - { _id: 4, x: 1 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateWithPipelines.yml b/driver-core/src/test/resources/unified-test-format/crud/updateWithPipelines.yml new file mode 100644 index 00000000000..e0b580c0ef7 --- /dev/null +++ b/driver-core/src/test/resources/unified-test-format/crud/updateWithPipelines.yml @@ -0,0 +1,296 @@ +description: updateWithPipelines +schemaVersion: '1.0' +runOnRequirements: + - + minServerVersion: 4.1.11 +createEntities: + - + client: + id: &client0 client0 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: client0 + databaseName: &database_name crud-tests + - + collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection_name test +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 1 + 'y': 1 + t: + u: + v: 1 + - + _id: 2 + x: 2 + 'y': 1 +tests: + - + description: 'UpdateOne using pipelines' + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: + _id: 1 + update: + - + $replaceRoot: + newRoot: $t + - + $addFields: + foo: 1 + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: + _id: 1 + u: + - { $replaceRoot: { newRoot: $t } } + - { $addFields: { foo: 1 } } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + commandName: update + databaseName: *database_name + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + u: + v: 1 + foo: 1 + - + _id: 2 + x: 2 + 'y': 1 + - + description: 'UpdateMany using pipelines' + operations: + - + object: *collection0 + name: updateMany + arguments: + filter: { } + update: + - + $project: + x: 1 + - + $addFields: + foo: 1 + expectResult: + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { } + u: + - { $project: { x: 1 } } + - { $addFields: { foo: 1 } } + multi: true + upsert: { $$unsetOrMatches: false } + commandName: update + databaseName: *database_name + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 1 + foo: 1 + - + _id: 2 + x: 2 + foo: 1 + - + description: 'FindOneAndUpdate using pipelines' + operations: + - + object: *collection0 + name: findOneAndUpdate + arguments: + filter: + _id: 1 + update: + - + $project: + x: 1 + - + $addFields: + foo: 1 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + update: + - + $project: + x: 1 + - + $addFields: + foo: 1 + commandName: findAndModify + databaseName: *database_name + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 1 + foo: 1 + - + _id: 2 + x: 2 + 'y': 1 + - + description: 'UpdateOne in bulk write using pipelines' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + updateOne: + filter: + _id: 1 + update: + - + $replaceRoot: + newRoot: $t + - + $addFields: + foo: 1 + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: + _id: 1 + u: + - { $replaceRoot: { newRoot: $t } } + - { $addFields: { foo: 1 } } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + commandName: update + databaseName: *database_name + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + u: + v: 1 + foo: 1 + - + _id: 2 + x: 2 + 'y': 1 + - + description: 'UpdateMany in bulk write using pipelines' + operations: + - + object: *collection0 + name: bulkWrite + arguments: + requests: + - + updateMany: + filter: { } + update: + - + $project: + x: 1 + - + $addFields: + foo: 1 + expectResult: + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { } + u: + - { $project: { x: 1 } } + - { $addFields: { foo: 1 } } + multi: true + upsert: { $$unsetOrMatches: false } + commandName: update + databaseName: *database_name + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - + _id: 1 + x: 1 + foo: 1 + - + _id: 2 + x: 2 + foo: 1 diff --git a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java index 5c494452823..56385e9c6f5 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java @@ -43,6 +43,14 @@ public static void doSkips(final String fileDescription, final String testDescri assumeFalse(testDescription.equals("Aggregate with $out includes read preference for 5.0+ server")); assumeFalse(testDescription.equals("Database-level aggregate with $out includes read preference for 5.0+ server")); } + assumeFalse(testDescription.endsWith("updateOne with sort option unsupported (server-side error)"), "Skipping until JAVA-5622 is " + + "implemented"); + assumeFalse(testDescription.endsWith("replaceOne with sort option unsupported (server-side error)"), "Skipping until " + + "JAVA-5622 is implemented"); + assumeFalse(testDescription.equals("BulkWrite with string comment"), "Skipping until we decide " + + "whether to update the spec or test https://mongodb.slack.com/archives/C72LB5RPV/p1730225657999979"); + assumeFalse(testDescription.equals("BulkWrite with document comment"), "Skipping until we decide " + + "whether to update the spec or test https://mongodb.slack.com/archives/C72LB5RPV/p1730225657999979"); } @Override From 81934d4accc81dcfb42898982ac224beebbf8939 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Tue, 29 Oct 2024 23:34:18 +0000 Subject: [PATCH 2/7] - Skipping more tests - Fix checkstyle --- .../mongodb/client/unified/UnifiedCrudTest.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java index 56385e9c6f5..6fe33fcdbc5 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java @@ -43,14 +43,12 @@ public static void doSkips(final String fileDescription, final String testDescri assumeFalse(testDescription.equals("Aggregate with $out includes read preference for 5.0+ server")); assumeFalse(testDescription.equals("Database-level aggregate with $out includes read preference for 5.0+ server")); } - assumeFalse(testDescription.endsWith("updateOne with sort option unsupported (server-side error)"), "Skipping until JAVA-5622 is " + - "implemented"); - assumeFalse(testDescription.endsWith("replaceOne with sort option unsupported (server-side error)"), "Skipping until " + - "JAVA-5622 is implemented"); - assumeFalse(testDescription.equals("BulkWrite with string comment"), "Skipping until we decide " + - "whether to update the spec or test https://mongodb.slack.com/archives/C72LB5RPV/p1730225657999979"); - assumeFalse(testDescription.equals("BulkWrite with document comment"), "Skipping until we decide " + - "whether to update the spec or test https://mongodb.slack.com/archives/C72LB5RPV/p1730225657999979"); + assumeFalse(testDescription.toLowerCase().contains("updateone with sort option"), "Skipping until JAVA-5622 is implemented"); + assumeFalse(testDescription.toLowerCase().contains("replaceone with sort option"), "Skipping until JAVA-5622 is implemented"); + assumeFalse(testDescription.equals("BulkWrite with string comment"), "Skipping until we decide " + + "whether to update the spec or test https://mongodb.slack.com/archives/C72LB5RPV/p1730225657999979"); + assumeFalse(testDescription.equals("BulkWrite with document comment"), "Skipping until we decide " + + "whether to update the spec or test https://mongodb.slack.com/archives/C72LB5RPV/p1730225657999979"); } @Override From 62c00d2c2685c42e470e0759db5494ba39e01c3e Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Wed, 30 Oct 2024 14:12:05 +0000 Subject: [PATCH 3/7] Removing unnecessary YAML files --- .../crud/aggregate-allowdiskuse.yml | 75 --- .../crud/aggregate-collation.yml | 48 -- .../crud/aggregate-let.yml | 138 ------ .../crud/aggregate-merge-errorResponse.yml | 42 -- .../crud/aggregate-merge.yml | 182 ------- .../crud/aggregate-out-readConcern.yml | 168 ------- .../crud/aggregate-out.yml | 72 --- .../crud/aggregate-write-readPreference.yml | 143 ------ .../unified-test-format/crud/aggregate.yml | 232 --------- .../bulkWrite-arrayFilters-clientError.yml | 95 ---- .../crud/bulkWrite-arrayFilters.yml | 210 -------- .../crud/bulkWrite-collation.yml | 130 ----- .../crud/bulkWrite-comment.yml | 175 ------- .../bulkWrite-delete-hint-clientError.yml | 110 ----- .../bulkWrite-delete-hint-serverError.yml | 139 ------ .../crud/bulkWrite-delete-hint.yml | 151 ------ ...lkWrite-deleteMany-hint-unacknowledged.yml | 98 ---- .../crud/bulkWrite-deleteMany-let.yml | 86 ---- ...ulkWrite-deleteOne-hint-unacknowledged.yml | 97 ---- .../crud/bulkWrite-deleteOne-let.yml | 86 ---- .../crud/bulkWrite-errorResponse.yml | 50 -- .../bulkWrite-insertOne-dots_and_dollars.yml | 138 ------ .../bulkWrite-replaceOne-dots_and_dollars.yml | 165 ------- ...lkWrite-replaceOne-hint-unacknowledged.yml | 103 ---- .../crud/bulkWrite-replaceOne-let.yml | 93 ---- .../crud/bulkWrite-replaceOne-sort.yml | 94 ---- .../bulkWrite-update-hint-clientError.yml | 145 ------ .../bulkWrite-update-hint-serverError.yml | 236 --------- .../crud/bulkWrite-update-hint.yml | 253 ---------- .../crud/bulkWrite-update-validation.yml | 73 --- .../bulkWrite-updateMany-dots_and_dollars.yml | 150 ------ ...lkWrite-updateMany-hint-unacknowledged.yml | 104 ---- .../crud/bulkWrite-updateMany-let.yml | 96 ---- .../bulkWrite-updateOne-dots_and_dollars.yml | 150 ------ ...ulkWrite-updateOne-hint-unacknowledged.yml | 103 ---- .../crud/bulkWrite-updateOne-let.yml | 95 ---- .../crud/bulkWrite-updateOne-sort.yml | 94 ---- .../unified-test-format/crud/bulkWrite.yml | 448 ------------------ .../crud/count-collation.yml | 57 --- .../unified-test-format/crud/count-empty.yml | 52 -- .../unified-test-format/crud/count.yml | 95 ---- .../crud/countDocuments-comment.yml | 92 ---- .../db-aggregate-write-readPreference.yml | 138 ------ .../unified-test-format/crud/db-aggregate.yml | 70 --- .../crud/deleteMany-collation.yml | 54 --- .../crud/deleteMany-comment.yml | 97 ---- .../crud/deleteMany-hint-clientError.yml | 84 ---- .../crud/deleteMany-hint-serverError.yml | 104 ---- .../crud/deleteMany-hint-unacknowledged.yml | 90 ---- .../crud/deleteMany-hint.yml | 96 ---- .../crud/deleteMany-let.yml | 93 ---- .../unified-test-format/crud/deleteMany.yml | 63 --- .../crud/deleteOne-collation.yml | 55 --- .../crud/deleteOne-comment.yml | 98 ---- .../crud/deleteOne-errorResponse.yml | 46 -- .../crud/deleteOne-hint-clientError.yml | 77 --- .../crud/deleteOne-hint-serverError.yml | 97 ---- .../crud/deleteOne-hint-unacknowledged.yml | 89 ---- .../crud/deleteOne-hint.yml | 92 ---- .../crud/deleteOne-let.yml | 91 ---- .../unified-test-format/crud/deleteOne.yml | 76 --- .../crud/distinct-collation.yml | 48 -- .../crud/distinct-comment.yml | 98 ---- .../unified-test-format/crud/distinct.yml | 54 --- .../crud/estimatedDocumentCount-comment.yml | 95 ---- .../crud/estimatedDocumentCount.yml | 181 ------- .../crud/find-allowdiskuse-clientError.yml | 52 -- .../crud/find-allowdiskuse-serverError.yml | 65 --- .../crud/find-allowdiskuse.yml | 76 --- .../crud/find-collation.yml | 46 -- .../unified-test-format/crud/find-comment.yml | 166 ------- .../unified-test-format/crud/find-let.yml | 71 --- .../unified-test-format/crud/find.yml | 107 ----- .../crud/findOneAndDelete-collation.yml | 56 --- .../crud/findOneAndDelete-comment.yml | 96 ---- .../findOneAndDelete-hint-clientError.yml | 88 ---- .../findOneAndDelete-hint-serverError.yml | 104 ---- .../findOneAndDelete-hint-unacknowledged.yml | 88 ---- .../crud/findOneAndDelete-hint.yml | 99 ---- .../crud/findOneAndDelete-let.yml | 86 ---- .../crud/findOneAndDelete.yml | 84 ---- .../crud/findOneAndReplace-collation.yml | 57 --- .../crud/findOneAndReplace-comment.yml | 101 ---- .../findOneAndReplace-dots_and_dollars.yml | 140 ------ .../findOneAndReplace-hint-clientError.yml | 80 ---- .../findOneAndReplace-hint-serverError.yml | 96 ---- .../findOneAndReplace-hint-unacknowledged.yml | 96 ---- .../crud/findOneAndReplace-hint.yml | 95 ---- .../crud/findOneAndReplace-let.yml | 94 ---- .../crud/findOneAndReplace-upsert.yml | 127 ----- .../crud/findOneAndReplace.yml | 152 ------ .../crud/findOneAndUpdate-arrayFilters.yml | 89 ---- .../crud/findOneAndUpdate-collation.yml | 58 --- .../crud/findOneAndUpdate-comment.yml | 95 ---- .../findOneAndUpdate-dots_and_dollars.yml | 127 ----- .../crud/findOneAndUpdate-errorResponse.yml | 69 --- .../findOneAndUpdate-hint-clientError.yml | 81 ---- .../findOneAndUpdate-hint-serverError.yml | 97 ---- .../findOneAndUpdate-hint-unacknowledged.yml | 92 ---- .../crud/findOneAndUpdate-hint.yml | 96 ---- .../crud/findOneAndUpdate-let.yml | 96 ---- .../crud/findOneAndUpdate.yml | 199 -------- .../crud/insertMany-comment.yml | 93 ---- .../crud/insertMany-dots_and_dollars.yml | 128 ----- .../unified-test-format/crud/insertMany.yml | 118 ----- .../crud/insertOne-comment.yml | 91 ---- .../crud/insertOne-dots_and_dollars.yml | 238 ---------- .../crud/insertOne-errorResponse.yml | 46 -- .../unified-test-format/crud/insertOne.yml | 44 -- .../crud/replaceOne-collation.yml | 57 --- .../crud/replaceOne-comment.yml | 105 ---- .../crud/replaceOne-dots_and_dollars.yml | 180 ------- .../crud/replaceOne-hint-unacknowledged.yml | 95 ---- .../crud/replaceOne-hint.yml | 105 ---- .../crud/replaceOne-let.yml | 98 ---- .../crud/replaceOne-sort.yml | 94 ---- .../crud/replaceOne-validation.yml | 37 -- .../unified-test-format/crud/replaceOne.yml | 138 ------ .../crud/updateMany-arrayFilters.yml | 98 ---- .../crud/updateMany-collation.yml | 59 --- .../crud/updateMany-comment.yml | 104 ---- .../crud/updateMany-dots_and_dollars.yml | 138 ------ .../crud/updateMany-hint-clientError.yml | 88 ---- .../crud/updateMany-hint-serverError.yml | 112 ----- .../crud/updateMany-hint-unacknowledged.yml | 96 ---- .../crud/updateMany-hint.yml | 112 ----- .../crud/updateMany-let.yml | 107 ----- .../crud/updateMany-validation.yml | 39 -- .../unified-test-format/crud/updateMany.yml | 120 ----- .../crud/updateOne-arrayFilters.yml | 150 ------ .../crud/updateOne-collation.yml | 57 --- .../crud/updateOne-comment.yml | 104 ---- .../crud/updateOne-dots_and_dollars.yml | 138 ------ .../crud/updateOne-errorResponse.yml | 47 -- .../crud/updateOne-hint-clientError.yml | 82 ---- .../crud/updateOne-hint-serverError.yml | 106 ----- .../crud/updateOne-hint-unacknowledged.yml | 95 ---- .../crud/updateOne-hint.yml | 106 ----- .../crud/updateOne-let.yml | 102 ---- .../crud/updateOne-sort.yml | 96 ---- .../crud/updateOne-validation.yml | 37 -- .../unified-test-format/crud/updateOne.yml | 114 ----- .../crud/updateWithPipelines.yml | 296 ------------ 143 files changed, 15140 deletions(-) delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-allowdiskuse.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-collation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-merge-errorResponse.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-merge.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-out-readConcern.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-out.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate-write-readPreference.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/aggregate.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters-clientError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-collation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-clientError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-serverError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-hint-unacknowledged.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-hint-unacknowledged.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-errorResponse.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-insertOne-dots_and_dollars.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-dots_and_dollars.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-hint-unacknowledged.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-sort.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-clientError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-serverError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-validation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-dots_and_dollars.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-hint-unacknowledged.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-dots_and_dollars.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-hint-unacknowledged.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-sort.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/bulkWrite.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/count-collation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/count-empty.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/count.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/countDocuments-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/db-aggregate-write-readPreference.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/db-aggregate.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-collation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-clientError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-serverError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-unacknowledged.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteMany.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-collation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-errorResponse.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-clientError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-serverError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-unacknowledged.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/deleteOne.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/distinct-collation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/distinct-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/distinct.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-clientError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-serverError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/find-collation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/find-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/find-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/find.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-collation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-clientError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-serverError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-unacknowledged.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-collation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-dots_and_dollars.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-clientError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-serverError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-unacknowledged.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-upsert.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-arrayFilters.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-collation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-dots_and_dollars.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-errorResponse.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-clientError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-serverError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-unacknowledged.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertMany-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertMany-dots_and_dollars.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertMany.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertOne-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertOne-dots_and_dollars.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertOne-errorResponse.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/insertOne.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-collation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-dots_and_dollars.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint-unacknowledged.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-sort.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne-validation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/replaceOne.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-arrayFilters.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-collation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-dots_and_dollars.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-clientError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-serverError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-unacknowledged.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-hint.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany-validation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateMany.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-arrayFilters.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-collation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-comment.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-dots_and_dollars.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-errorResponse.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-clientError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-serverError.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-unacknowledged.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-hint.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-let.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-sort.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne-validation.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateOne.yml delete mode 100644 driver-core/src/test/resources/unified-test-format/crud/updateWithPipelines.yml diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-allowdiskuse.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-allowdiskuse.yml deleted file mode 100644 index d9d25562052..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/aggregate-allowdiskuse.yml +++ /dev/null @@ -1,75 +0,0 @@ -description: aggregate-allowdiskuse - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: [] - -tests: - - description: 'Aggregate does not send allowDiskUse when value is not specified' - operations: - - object: *collection0 - name: aggregate - arguments: - pipeline: &pipeline [ { $match: {} } ] - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *pipeline - allowDiskUse: { $$exists: false } - commandName: aggregate - databaseName: *database0Name - - - description: 'Aggregate sends allowDiskUse false when false is specified' - operations: - - object: *collection0 - name: aggregate - arguments: - pipeline: *pipeline - allowDiskUse: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *pipeline - allowDiskUse: false - commandName: aggregate - databaseName: *database0Name - - - description: 'Aggregate sends allowDiskUse true when true is specified' - operations: - - object: *collection0 - name: aggregate - arguments: - pipeline: *pipeline - allowDiskUse: true - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *pipeline - allowDiskUse: true - commandName: aggregate - databaseName: *database0Name diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-collation.yml deleted file mode 100644 index 088dc5705b2..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/aggregate-collation.yml +++ /dev/null @@ -1,48 +0,0 @@ -description: aggregate-collation - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '3.4' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: ping } - -tests: - - - description: 'Aggregate with collation' - operations: - - - object: *collection0 - name: aggregate - arguments: - pipeline: - - { $match: { x: PING } } - # https://www.mongodb.com/docs/manual/reference/collation/#collation-document - collation: - locale: en_US - strength: 2 - expectResult: - - { _id: 1, x: ping } diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-let.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-let.yml deleted file mode 100644 index 7fa1f9b798e..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/aggregate-let.yml +++ /dev/null @@ -1,138 +0,0 @@ -description: "aggregate-let" - -schemaVersion: "1.4" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - - collection: - id: &collection1 collection1 - database: *database0 - collectionName: &collection1Name coll1 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - collectionName: *collection1Name - databaseName: *database0Name - documents: [ ] - -tests: - - description: "Aggregate with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: aggregate - object: *collection0 - arguments: - pipeline: &pipeline0 - # $match takes a query expression, so $expr is necessary to utilize - # an aggregate expression context and access "let" variables. - - $match: { $expr: { $eq: ["$_id", "$$id"] } } - - $project: { _id: 0, x: "$$x", y: "$$y", rand: "$$rand" } - # Values in "let" must be constant or closed expressions that do not - # depend on document values. This test demonstrates a basic constant - # value, a value wrapped with $literal (to avoid expression parsing), - # and a closed expression (e.g. $rand). - let: &let0 - id: 1 - x: foo - y: { $literal: "$bar" } - rand: { $rand: {} } - expectResult: - - { x: "foo", y: "$bar", rand: { $$type: "double" } } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *pipeline0 - let: *let0 - - - description: "Aggregate with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "2.6.0" - maxServerVersion: "4.4.99" - operations: - - name: aggregate - object: *collection0 - arguments: - pipeline: &pipeline1 - - $match: { _id: 1 } - let: &let1 - x: foo - expectError: - # Older server versions may not report an error code, but the error - # message is consistent between 2.6.x and 4.4.x server versions. - errorContains: "unrecognized field 'let'" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *pipeline1 - let: *let1 - - - description: "Aggregate to collection with let option" - runOnRequirements: - - minServerVersion: "5.0" - serverless: "forbid" - operations: - - name: aggregate - object: *collection0 - arguments: - pipeline: &pipeline2 - - $match: { $expr: { $eq: ["$_id", "$$id"] } } - - $project: { _id: 1 } - - $out: *collection1Name - let: &let2 - id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *pipeline2 - let: *let2 - outcome: - - collectionName: *collection1Name - databaseName: *database0Name - documents: - - { _id: 1 } - - - description: "Aggregate to collection with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "2.6.0" - maxServerVersion: "4.4.99" - operations: - - name: aggregate - object: *collection0 - arguments: - pipeline: *pipeline2 - let: *let2 - expectError: - errorContains: "unrecognized field 'let'" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *pipeline2 - let: *let2 diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-merge-errorResponse.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-merge-errorResponse.yml deleted file mode 100644 index 5fd679bffb2..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/aggregate-merge-errorResponse.yml +++ /dev/null @@ -1,42 +0,0 @@ -description: "aggregate-merge-errorResponse" - -schemaVersion: "1.12" - -createEntities: - - client: - id: &client0 client0 - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name test - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 1 } - - { _id: 2, x: 1 } - -tests: - - description: "aggregate $merge DuplicateKey error is accessible" - runOnRequirements: - - minServerVersion: "5.1" # SERVER-59097 - # Exclude sharded topologies since the aggregate command fails with - # IllegalOperation(20) instead of DuplicateKey(11000) - topologies: [ single, replicaset ] - operations: - - name: aggregate - object: *database0 - arguments: - pipeline: - - { $documents: [ { _id: 2, x: 1 } ] } - - { $merge: { into: *collection0Name, whenMatched: "fail" } } - expectError: - errorCode: 11000 # DuplicateKey - errorResponse: - keyPattern: { _id: 1 } - keyValue: { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-merge.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-merge.yml deleted file mode 100644 index 48dd54d1bd2..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/aggregate-merge.yml +++ /dev/null @@ -1,182 +0,0 @@ -description: aggregate-merge -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.1.11 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_aggregate_merge - - - collection: - id: &collection_readConcern_majority collection_readConcern_majority - database: database0 - collectionName: *collection_name - collectionOptions: - readConcern: { level: "majority" } - - - collection: - id: &collection_readConcern_local collection_readConcern_local - database: database0 - collectionName: *collection_name - collectionOptions: - readConcern: { level: "local" } - - - collection: - id: &collection_readConcern_available collection_readConcern_available - database: database0 - collectionName: *collection_name - collectionOptions: - readConcern: { level: "available" } -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 -tests: - - - description: 'Aggregate with $merge' - operations: - - - object: *collection0 - name: aggregate - arguments: &arguments - pipeline: &pipeline - - - $sort: - x: 1 - - - $match: - _id: - $gt: 1 - - - $merge: - into: &output_collection other_test_collection - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - aggregate: *collection_name - pipeline: *pipeline - outcome: &outcome - - - collectionName: *output_collection - databaseName: *database_name - documents: - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - description: 'Aggregate with $merge and batch size of 0' - operations: - - - object: *collection0 - name: aggregate - arguments: - pipeline: &pipeline - - - $sort: - x: 1 - - - $match: - _id: - $gt: 1 - - - $merge: - into: &output_collection other_test_collection - batchSize: 0 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - aggregate: *collection_name - pipeline: *pipeline - cursor: { } - outcome: *outcome - - - description: 'Aggregate with $merge and majority readConcern' - operations: - - - object: *collection_readConcern_majority - name: aggregate - arguments: *arguments - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - aggregate: *collection_name - pipeline: *pipeline - readConcern: - level: majority - outcome: *outcome - - - description: 'Aggregate with $merge and local readConcern' - operations: - - - object: *collection_readConcern_local - name: aggregate - arguments: *arguments - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - aggregate: *collection_name - pipeline: *pipeline - readConcern: - level: local - outcome: *outcome - - - description: 'Aggregate with $merge and available readConcern' - operations: - - - object: *collection_readConcern_available - name: aggregate - arguments: *arguments - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - aggregate: *collection_name - pipeline: *pipeline - readConcern: - level: available - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-out-readConcern.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-out-readConcern.yml deleted file mode 100644 index 67bdee676a5..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/aggregate-out-readConcern.yml +++ /dev/null @@ -1,168 +0,0 @@ -description: aggregate-out-readConcern -schemaVersion: '1.4' -runOnRequirements: - - - minServerVersion: 4.1.0 - topologies: - - replicaset - - sharded - serverless: "forbid" -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_aggregate_out_readconcern - - - collection: - id: &collection_readConcern_majority collection_readConcern_majority - database: database0 - collectionName: *collection_name - collectionOptions: - readConcern: { level: "majority" } - - - collection: - id: &collection_readConcern_local collection_readConcern_local - database: database0 - collectionName: *collection_name - collectionOptions: - readConcern: { level: "local" } - - - collection: - id: &collection_readConcern_available collection_readConcern_available - database: database0 - collectionName: *collection_name - collectionOptions: - readConcern: { level: "available" } - - - collection: - id: &collection_readConcern_linearizable collection_readConcern_linearizable - database: database0 - collectionName: *collection_name - collectionOptions: - readConcern: { level: "linearizable" } -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 -tests: - - - description: 'readConcern majority with out stage' - operations: - - - object: *collection_readConcern_majority - name: aggregate - arguments: &arguments - pipeline: - - - $sort: - x: 1 - - - $match: - _id: - $gt: 1 - - - $out: &output_collection other_test_collection - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - aggregate: *collection_name - pipeline: &pipeline - - { $sort: { x: 1 } } - - { $match: { _id: { $gt: 1 } } } - - { $out: other_test_collection } - readConcern: - level: majority - outcome: &outcome - - - collectionName: *output_collection - databaseName: *database_name - documents: - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - description: 'readConcern local with out stage' - operations: - - - object: *collection_readConcern_local - name: aggregate - arguments: *arguments - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - aggregate: *collection_name - pipeline: *pipeline - readConcern: - level: local - outcome: *outcome - - - description: 'readConcern available with out stage' - operations: - - - object: *collection_readConcern_available - name: aggregate - arguments: *arguments - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - aggregate: *collection_name - pipeline: *pipeline - readConcern: - level: available - outcome: *outcome - - - description: 'readConcern linearizable with out stage' - operations: - - - object: *collection_readConcern_linearizable - name: aggregate - arguments: *arguments - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - aggregate: *collection_name - pipeline: *pipeline - readConcern: - level: linearizable diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-out.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-out.yml deleted file mode 100644 index a85eed03220..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/aggregate-out.yml +++ /dev/null @@ -1,72 +0,0 @@ -description: aggregate-out - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '2.6' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - - description: 'Aggregate with $out' - operations: - - - object: *collection0 - name: aggregate - arguments: - pipeline: - - { $sort: { x: 1 } } - - { $match: { _id: { $gt: 1 } } } - - { $out: other_test_collection } - batchSize: 2 - outcome: - - - collectionName: other_test_collection - databaseName: *database_name - documents: - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - - description: 'Aggregate with $out and batch size of 0' - operations: - - - object: *collection0 - name: aggregate - arguments: - pipeline: - - { $sort: { x: 1 } } - - { $match: { _id: { $gt: 1 } } } - - { $out: other_test_collection } - batchSize: 0 - outcome: - - - collectionName: other_test_collection - databaseName: *database_name - documents: - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate-write-readPreference.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate-write-readPreference.yml deleted file mode 100644 index 16f1035752d..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/aggregate-write-readPreference.yml +++ /dev/null @@ -1,143 +0,0 @@ -description: aggregate-write-readPreference - -schemaVersion: '1.4' - -runOnRequirements: - # 3.6+ non-standalone is needed to utilize $readPreference in OP_MSG - - minServerVersion: "3.6" - topologies: [ replicaset, sharded, load-balanced ] - -_yamlAnchors: - readConcern: &readConcern - level: &readConcernLevel "local" - writeConcern: &writeConcern - w: &writeConcernW 1 - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - # Used to test that read and write concerns are still inherited - uriOptions: - readConcernLevel: *readConcernLevel - w: *writeConcernW - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - readPreference: &readPreference - # secondaryPreferred is specified for compatibility with clusters that - # may not have a secondary (e.g. each shard is only a primary). - mode: secondaryPreferred - # maxStalenessSeconds is specified to ensure that drivers forward the - # read preference to mongos or a load balancer. That would not be the - # case with only secondaryPreferred. - maxStalenessSeconds: 600 - - collection: - id: &collection1 collection1 - database: *database0 - collectionName: &collection1Name coll1 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: "Aggregate with $out includes read preference for 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - serverless: "forbid" - operations: - - object: *collection0 - name: aggregate - arguments: - pipeline: &outPipeline - - { $match: { _id: { $gt: 1 } } } - - { $sort: { x: 1 } } - - { $out: *collection1Name } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *outPipeline - $readPreference: *readPreference - readConcern: *readConcern - writeConcern: *writeConcern - - - description: "Aggregate with $out omits read preference for pre-5.0 server" - runOnRequirements: - # MongoDB 4.2 introduced support for read concerns and write stages. - # Pre-4.2 servers may allow a "local" read concern anyway, but some - # drivers may avoid inheriting a client-level read concern for pre-4.2. - - minServerVersion: "4.2" - maxServerVersion: "4.4.99" - serverless: "forbid" - operations: - - object: *collection0 - name: aggregate - arguments: - pipeline: *outPipeline - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *outPipeline - $readPreference: { $$exists: false } - readConcern: *readConcern - writeConcern: *writeConcern - - - description: "Aggregate with $merge includes read preference for 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - object: *collection0 - name: aggregate - arguments: - pipeline: &mergePipeline - - { $match: { _id: { $gt: 1 } } } - - { $sort: { x: 1 } } - - { $merge: { into: *collection1Name } } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *mergePipeline - $readPreference: *readPreference - readConcern: *readConcern - writeConcern: *writeConcern - - - description: "Aggregate with $merge omits read preference for pre-5.0 server" - runOnRequirements: - - minServerVersion: "4.2" - maxServerVersion: "4.4.99" - operations: - - object: *collection0 - name: aggregate - arguments: - pipeline: *mergePipeline - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *mergePipeline - $readPreference: { $$exists: false } - readConcern: *readConcern - writeConcern: *writeConcern diff --git a/driver-core/src/test/resources/unified-test-format/crud/aggregate.yml b/driver-core/src/test/resources/unified-test-format/crud/aggregate.yml deleted file mode 100644 index 6f99aaf0fe5..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/aggregate.yml +++ /dev/null @@ -1,232 +0,0 @@ -description: "aggregate" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - useMultipleMongoses: true # ensure cursors pin to a single server - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name aggregate-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - { _id: 5, x: 55 } - - { _id: 6, x: 66 } - -tests: - - description: "aggregate with multiple batches works" - operations: - - name: aggregate - arguments: - pipeline: [ { $match: { _id: { $gt: 1 } }} ] - batchSize: 2 - object: *collection0 - expectResult: - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - { _id: 5, x: 55 } - - { _id: 6, x: 66 } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: [ { $match: { _id: { $gt: 1 } }} ] - cursor: { batchSize: 2 } - commandName: aggregate - databaseName: *database0Name - - commandStartedEvent: - command: - getMore: { $$type: [ int, long ] } - collection: *collection0Name - batchSize: 2 - commandName: getMore - databaseName: *database0Name - - commandStartedEvent: - command: - getMore: { $$type: [ int, long ] } - collection: *collection0Name - batchSize: 2 - commandName: getMore - databaseName: *database0Name - - - description: "aggregate with a string comment" - runOnRequirements: - - minServerVersion: "3.6.0" - operations: - - name: aggregate - arguments: - pipeline: [ { $match: { _id: { $gt: 1 } }} ] - comment: "comment" - object: *collection0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: [ { $match: { _id: { $gt: 1 } } } ] - comment: "comment" - - - description: "aggregate with a document comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: aggregate - arguments: - pipeline: [ { $match: { _id: { $gt: 1 } }} ] - comment: &comment0 { content: "test" } - object: *collection0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: [ { $match: { _id: { $gt: 1 } } } ] - comment: *comment0 - - - description: "aggregate with a document comment - pre 4.4" - runOnRequirements: - - minServerVersion: "3.6.0" - maxServerVersion: "4.2.99" - operations: - - name: aggregate - object: *collection0 - arguments: - pipeline: [ { $match: { _id: { $gt: 1 } }} ] - comment: *comment0 - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: [ { $match: { _id: { $gt: 1 } }} ] - comment: *comment0 - commandName: aggregate - databaseName: *database0Name - - - description: "aggregate with comment sets comment on getMore" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - name: aggregate - arguments: - pipeline: [ { $match: { _id: { $gt: 1 } }} ] - batchSize: 2 - comment: *comment0 - object: *collection0 - expectResult: - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - { _id: 5, x: 55 } - - { _id: 6, x: 66 } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: [ { $match: { _id: { $gt: 1 } }} ] - cursor: { batchSize: 2 } - comment: *comment0 - commandName: aggregate - databaseName: *database0Name - - commandStartedEvent: - command: - getMore: { $$type: [ int, long ] } - collection: *collection0Name - batchSize: 2 - comment: *comment0 - commandName: getMore - databaseName: *database0Name - - commandStartedEvent: - command: - getMore: { $$type: [ int, long ] } - collection: *collection0Name - batchSize: 2 - comment: *comment0 - commandName: getMore - databaseName: *database0Name - - - description: "aggregate with comment does not set comment on getMore - pre 4.4" - runOnRequirements: - - minServerVersion: "3.6.0" - maxServerVersion: "4.3.99" - operations: - - name: aggregate - arguments: - pipeline: [ { $match: { _id: { $gt: 1 } }} ] - batchSize: 2 - comment: "comment" - object: *collection0 - expectResult: - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - { _id: 5, x: 55 } - - { _id: 6, x: 66 } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: [ { $match: { _id: { $gt: 1 } }} ] - cursor: { batchSize: 2 } - comment: "comment" - commandName: aggregate - databaseName: *database0Name - - commandStartedEvent: - command: - getMore: { $$type: [ int, long ] } - collection: *collection0Name - batchSize: 2 - comment: { $$exists: false } - commandName: getMore - databaseName: *database0Name - - commandStartedEvent: - command: - getMore: { $$type: [ int, long ] } - collection: *collection0Name - batchSize: 2 - comment: { $$exists: false } - commandName: getMore - databaseName: *database0Name - - - description: 'Aggregate with multiple stages' - operations: - - - object: *collection0 - name: aggregate - arguments: - pipeline: - - { $sort: { x: 1 } } - - { $match: { _id: { $gt: 1 } } } - batchSize: 2 - expectResult: - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - { _id: 5, x: 55 } - - { _id: 6, x: 66 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters-clientError.yml deleted file mode 100644 index 12bc84c704e..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters-clientError.yml +++ /dev/null @@ -1,95 +0,0 @@ -description: bulkWrite-arrayFilters-clientError -schemaVersion: '1.0' -runOnRequirements: - - - maxServerVersion: 3.5.5 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name crud-v2 -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - 'y': - - - b: 3 - - - b: 1 - - - _id: 2 - 'y': - - - b: 0 - - - b: 1 -tests: - - - description: 'BulkWrite on server that doesn''t support arrayFilters' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - updateOne: - filter: { } - update: - $set: - y.0.b: 2 - arrayFilters: - - - i.b: 1 - ordered: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - - - description: 'BulkWrite on server that doesn''t support arrayFilters with arrayFilters on second op' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - updateOne: - filter: { } - update: - $set: - y.0.b: 2 - - - updateMany: - filter: { } - update: - $set: - 'y.$[i].b': 2 - arrayFilters: - - - i.b: 1 - ordered: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters.yml deleted file mode 100644 index 9db833581f7..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-arrayFilters.yml +++ /dev/null @@ -1,210 +0,0 @@ -description: bulkWrite-arrayFilters -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 3.5.6 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-tests - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - 'y': - - - b: 3 - - - b: 1 - - - _id: 2 - 'y': - - - b: 0 - - - b: 1 -tests: - - - description: 'BulkWrite updateOne with arrayFilters' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - updateOne: - filter: { } - update: - $set: - 'y.$[i].b': 2 - arrayFilters: - - - i.b: 3 - ordered: true - expectResult: - deletedCount: 0 - insertedCount: 0 - insertedIds: { $$unsetOrMatches: {} } - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - upsertedIds: { } - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: { } - u: - $set: { 'y.$[i].b': 2 } - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - arrayFilters: - - { i.b: 3 } - ordered: true - commandName: update - databaseName: *database_name - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - 'y': - - - b: 2 - - - b: 1 - - - _id: 2 - 'y': - - - b: 0 - - - b: 1 - - - description: 'BulkWrite updateMany with arrayFilters' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - updateMany: - filter: { } - update: - $set: - 'y.$[i].b': 2 - arrayFilters: - - - i.b: 1 - ordered: true - expectResult: - deletedCount: 0 - insertedCount: 0 - insertedIds: { $$unsetOrMatches: {} } - matchedCount: 2 - modifiedCount: 2 - upsertedCount: 0 - upsertedIds: { } - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: { } - u: - $set: { 'y.$[i].b': 2 } - multi: true - upsert: { $$unsetOrMatches: false } - arrayFilters: - - { i.b: 1 } - ordered: true - commandName: update - databaseName: *database_name - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - 'y': - - - b: 3 - - - b: 2 - - - _id: 2 - 'y': - - - b: 0 - - - b: 2 - - - description: 'BulkWrite with arrayFilters' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - # UpdateOne when one document matches arrayFilters - updateOne: - filter: { } - update: { $set: { 'y.$[i].b': 2 } } - arrayFilters: - - { i.b: 3 } - - - # UpdateMany when multiple documents match arrayFilters - updateMany: - filter: { } - update: { $set: { 'y.$[i].b': 2 } } - arrayFilters: - - { i.b: 1 } - ordered: true - expectResult: - deletedCount: 0 - insertedCount: 0 - insertedIds: - $$unsetOrMatches: { } - matchedCount: 3 - modifiedCount: 3 - upsertedCount: 0 - upsertedIds: { } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 2 }, { b: 2 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 2 } ] } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-collation.yml deleted file mode 100644 index b9b3fc4fe92..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-collation.yml +++ /dev/null @@ -1,130 +0,0 @@ -description: bulkWrite-collation - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '3.4' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: ping } - - { _id: 3, x: pINg } - - { _id: 4, x: pong } - - { _id: 5, x: pONg } - -# See: https://www.mongodb.com/docs/manual/reference/collation/#collation-document -tests: - - - description: 'BulkWrite with delete operations and collation' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - # matches two documents but deletes one - deleteOne: - filter: { x: "PING" } - collation: { locale: "en_US", strength: 2 } - - - # matches the remaining document and deletes it - deleteOne: - filter: { x: "PING" } - collation: { locale: "en_US", strength: 2 } - - - # matches two documents and deletes them - deleteMany: - filter: { x: "PONG" } - collation: { locale: "en_US", strength: 2 } - ordered: true - expectResult: - deletedCount: 4 - insertedCount: 0 - insertedIds: - $$unsetOrMatches: { } - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - upsertedIds: { } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - - description: 'BulkWrite with update operations and collation' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - # matches only one document due to strength and updates - updateMany: - filter: { x: "ping" } - update: { $set: { x: "PONG" } } - collation: { locale: "en_US", strength: 3 } - - - # matches one document and updates - updateOne: - filter: { x: "ping" } - update: { $set: { x: "PONG" } } - collation: { locale: "en_US", strength: 2 } - - - # matches no document due to strength and upserts - replaceOne: - filter: { x: "ping" } - replacement: { _id: 6, x: "ping" } - upsert: true - collation: { locale: "en_US", strength: 3 } - - - # matches two documents and updates - updateMany: - filter: { x: "pong" } - update: { $set: { x: "PONG" } } - collation: { locale: "en_US", strength: 2 } - ordered: true - expectResult: - deletedCount: 0 - insertedCount: 0 - insertedIds: - $$unsetOrMatches: { } - matchedCount: 6 - modifiedCount: 4 - upsertedCount: 1 - upsertedIds: { '2': 6 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - {_id: 1, x: 11 } - - {_id: 2, x: "PONG" } - - {_id: 3, x: "PONG" } - - {_id: 4, x: "PONG" } - - {_id: 5, x: "PONG" } - - {_id: 6, x: "ping" } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.yml deleted file mode 100644 index 965a0b8384b..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.yml +++ /dev/null @@ -1,175 +0,0 @@ -description: bulkWrite-comment -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name BulkWrite_comment - -initialData: &initial_data - - collectionName: *collection_name - databaseName: *database_name - documents: - - _id: 1 - x: 11 - - _id: 2 - x: 22 - - _id: 3 - x: 33 - - _id: 4 - x: 44 - -tests: - - description: 'BulkWrite with string comment' - runOnRequirements: - - minServerVersion: "4.4" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: &requests - - insertOne: - document: &inserted_document - _id: 5 - x: "inserted" - - replaceOne: - filter: &replaceOne_filter - _id: 1 - replacement: &replacement { _id: 1, x: "replaced" } - - updateOne: - filter: &updateOne_filter - _id: 2 - update: &update { $set: {x: "updated"} } - - deleteOne: - filter: &deleteOne_filter - _id: 3 - comment: &string_comment "comment" - expectResult: &expect_results - deletedCount: 1 - insertedCount: 1 - insertedIds: { $$unsetOrMatches: { 0: 5} } - matchedCount: 2 - modifiedCount: 2 - upsertedCount: 0 - upsertedIds: { } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection_name - documents: - - *inserted_document - ordered: true - comment: *string_comment - - commandStartedEvent: - command: - update: *collection_name - updates: - - q: *replaceOne_filter - u: *replacement - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - - q: *updateOne_filter - u: *update - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - ordered: true - comment: *string_comment - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - q: *deleteOne_filter - limit: 1 - ordered: true - comment: *string_comment - outcome: &outcome - - collectionName: *collection_name - databaseName: *database_name - documents: - - _id: 1 - x: "replaced" - - _id: 2 - x: "updated" - - _id: 4 - x: 44 - - _id: 5 - x: "inserted" - - - description: 'BulkWrite with document comment' - runOnRequirements: - - minServerVersion: "4.4" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: *requests - comment: &document_comment { key: "value" } - expectResult: *expect_results - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection_name - documents: - - *inserted_document - ordered: true - comment: *document_comment - - commandStartedEvent: - command: - update: *collection_name - updates: - - q: *replaceOne_filter - u: *replacement - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - - q: *updateOne_filter - u: *update - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - ordered: true - comment: *document_comment - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - q: *deleteOne_filter - limit: 1 - ordered: true - comment: *document_comment - outcome: *outcome - - - description: 'BulkWrite with comment - pre 4.4' - runOnRequirements: - - minServerVersion: "3.4.0" - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: *requests - comment: "comment" - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection_name - documents: - - *inserted_document - ordered: true - comment: "comment" - outcome: *initial_data diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-clientError.yml deleted file mode 100644 index 5c172610046..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-clientError.yml +++ /dev/null @@ -1,110 +0,0 @@ -description: bulkWrite-delete-hint-clientError -schemaVersion: '1.0' -runOnRequirements: - - - maxServerVersion: 3.3.99 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name BulkWrite_delete_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 -tests: - - - description: 'BulkWrite deleteOne with hints unsupported (client-side error)' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - deleteOne: - filter: &deleteOne_filter1 - _id: 1 - hint: &hint_string _id_ - - - deleteOne: - filter: &deleteOne_filter2 - _id: 2 - hint: &hint_doc - _id: 1 - ordered: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 - - - description: 'BulkWrite deleteMany with hints unsupported (client-side error)' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - deleteMany: - filter: &deleteMany_filter1 - _id: - $lt: 3 - hint: *hint_string - - - deleteMany: - filter: &deleteMany_filter2 - _id: - $gte: 4 - hint: *hint_doc - ordered: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-serverError.yml deleted file mode 100644 index 06ad7787a7a..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint-serverError.yml +++ /dev/null @@ -1,139 +0,0 @@ -description: bulkWrite-delete-hint-serverError -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 3.4.0 - maxServerVersion: 4.3.3 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name BulkWrite_delete_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 -tests: - - - description: 'BulkWrite deleteOne with hints unsupported (server-side error)' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - deleteOne: - filter: &deleteOne_filter1 - _id: 1 - hint: &hint_string _id_ - - - deleteOne: - filter: &deleteOne_filter2 - _id: 2 - hint: &hint_doc - _id: 1 - ordered: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - - q: *deleteOne_filter1 - hint: *hint_string - limit: 1 - - - q: *deleteOne_filter2 - hint: *hint_doc - limit: 1 - ordered: true - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 - - - description: 'BulkWrite deleteMany with hints unsupported (server-side error)' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - deleteMany: - filter: &deleteMany_filter1 - _id: - $lt: 3 - hint: *hint_string - - - deleteMany: - filter: &deleteMany_filter2 - _id: - $gte: 4 - hint: *hint_doc - ordered: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - - q: *deleteMany_filter1 - hint: *hint_string - limit: 0 - - - q: *deleteMany_filter2 - hint: *hint_doc - limit: 0 - ordered: true - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint.yml deleted file mode 100644 index ac451bfc466..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-delete-hint.yml +++ /dev/null @@ -1,151 +0,0 @@ -description: bulkWrite-delete-hint -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.3.4 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name BulkWrite_delete_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 -tests: - - - description: 'BulkWrite deleteOne with hints' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - deleteOne: - filter: &deleteOne_filter1 - _id: 1 - hint: &hint_string _id_ - - - deleteOne: - filter: &deleteOne_filter2 - _id: 2 - hint: &hint_doc - _id: 1 - ordered: true - expectResult: - deletedCount: 2 - insertedCount: 0 - insertedIds: { $$unsetOrMatches: {} } - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - upsertedIds: { } - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - - q: *deleteOne_filter1 - hint: *hint_string - limit: 1 - - - q: *deleteOne_filter2 - hint: *hint_doc - limit: 1 - ordered: true - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 - - - description: 'BulkWrite deleteMany with hints' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - deleteMany: - filter: &deleteMany_filter1 - _id: - $lt: 3 - hint: *hint_string - - - deleteMany: - filter: &deleteMany_filter2 - _id: - $gte: 4 - hint: *hint_doc - ordered: true - expectResult: - deletedCount: 3 - insertedCount: 0 - insertedIds: { $$unsetOrMatches: {} } - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - upsertedIds: { } - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - - q: *deleteMany_filter1 - hint: *hint_string - limit: 0 - - - q: *deleteMany_filter2 - hint: *hint_doc - limit: 0 - ordered: true - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 3 - x: 33 diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-hint-unacknowledged.yml deleted file mode 100644 index aa2cdbce922..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-hint-unacknowledged.yml +++ /dev/null @@ -1,98 +0,0 @@ -description: bulkWrite-deleteMany-hint-unacknowledged - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - writeConcern: { w: 0 } - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: &documents - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: "Unacknowledged deleteMany with hint string fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - deleteMany: - filter: &filter { _id: { $gt: 1 } } - hint: _id_ - expectError: - isClientError: true - expectEvents: &noEvents - - client: *client0 - events: [] - - - description: "Unacknowledged deleteMany with hint document fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - deleteMany: - filter: *filter - hint: { _id: 1 } - expectError: - isClientError: true - expectEvents: *noEvents - - - description: "Unacknowledged deleteMany with hint string on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - deleteMany: - filter: *filter - hint: _id_ - expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } - expectEvents: &events - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - hint: { $$type: [ string, object ]} - limit: 0 - writeConcern: { w: 0 } - - - description: "Unacknowledged deleteMany with hint document on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - deleteMany: - filter: *filter - hint: { _id: 1 } - expectResult: *unacknowledgedResult - expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-let.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-let.yml deleted file mode 100644 index 48b3a06d2e7..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteMany-let.yml +++ /dev/null @@ -1,86 +0,0 @@ -description: "BulkWrite deleteMany-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - -tests: - - description: "BulkWrite deleteMany with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - deleteMany: - filter: &filter - $expr: - $eq: [ "$_id", "$$id" ] - let: &let - id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - limit: 0 - let: *let - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 2 } - - - description: "BulkWrite deleteMany with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "3.6.0" - maxServerVersion: "4.4.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - deleteOne: - filter: *filter - let: *let - expectError: - errorContains: "'delete.let' is an unknown field" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - limit: 1 - let: *let - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-hint-unacknowledged.yml deleted file mode 100644 index 820697008e5..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-hint-unacknowledged.yml +++ /dev/null @@ -1,97 +0,0 @@ -description: bulkWrite-deleteOne-hint-unacknowledged - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - writeConcern: { w: 0 } - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: &documents - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - -tests: - - description: "Unacknowledged deleteOne with hint string fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - deleteOne: - filter: &filter { _id: { $gt: 1 } } - hint: _id_ - expectError: - isClientError: true - expectEvents: &noEvents - - client: *client0 - events: [] - - - description: "Unacknowledged deleteOne with hint document fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - deleteOne: - filter: *filter - hint: { _id: 1 } - expectError: - isClientError: true - expectEvents: *noEvents - - - description: "Unacknowledged deleteOne with hint string on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - deleteOne: - filter: *filter - hint: _id_ - expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } - expectEvents: &events - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - hint: { $$type: [ string, object ]} - limit: 1 - writeConcern: { w: 0 } - - - description: "Unacknowledged deleteOne with hint document on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - deleteOne: - filter: *filter - hint: { _id: 1 } - expectResult: *unacknowledgedResult - expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-let.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-let.yml deleted file mode 100644 index 128d74a4415..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-deleteOne-let.yml +++ /dev/null @@ -1,86 +0,0 @@ -description: "BulkWrite deleteOne-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - -tests: - - description: "BulkWrite deleteOne with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - deleteOne: - filter: &filter - $expr: - $eq: [ "$_id", "$$id" ] - let: &let - id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - limit: 1 - let: *let - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 2 } - - - description: "BulkWrite deleteOne with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "3.6.0" - maxServerVersion: "4.9" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - deleteOne: - filter: *filter - let: *let - expectError: - errorContains: "'delete.let' is an unknown field" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - limit: 1 - let: *let - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-errorResponse.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-errorResponse.yml deleted file mode 100644 index d4f335dfd33..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-errorResponse.yml +++ /dev/null @@ -1,50 +0,0 @@ -description: "bulkWrite-errorResponse" - -schemaVersion: "1.12" - -createEntities: - - client: - id: &client0 client0 - useMultipleMongoses: false - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name test - -tests: - # This test intentionally executes only a single insert operation in the bulk - # write to make the error code and response assertions less ambiguous. That - # said, some drivers may still need to skip this test because the CRUD spec - # does not prescribe how drivers should formulate a BulkWriteException beyond - # collecting write and write concern errors. - - description: "bulkWrite operations support errorResponse assertions" - runOnRequirements: - - minServerVersion: "4.0.0" - topologies: [ single, replicaset ] - - minServerVersion: "4.2.0" - topologies: [ sharded ] - operations: - - name: failPoint - object: testRunner - arguments: - client: *client0 - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: [ insert ] - errorCode: &errorCode 8 # UnknownError - - name: bulkWrite - object: *collection0 - arguments: - requests: - - insertOne: - document: { _id: 1 } - expectError: - errorCode: *errorCode - errorResponse: - code: *errorCode diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-insertOne-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-insertOne-dots_and_dollars.yml deleted file mode 100644 index de3885ac8ce..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-insertOne-dots_and_dollars.yml +++ /dev/null @@ -1,138 +0,0 @@ -description: "bulkWrite-insertOne-dots_and_dollars" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: [] - -tests: - - description: "Inserting document with top-level dollar-prefixed key on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - insertOne: - document: &dollarPrefixedKey { _id: 1, $a: 1 } - expectResult: &bulkWriteResult - deletedCount: 0 - insertedCount: 1 - insertedIds: { $$unsetOrMatches: { 0: 1 } } - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - upsertedIds: { } - expectEvents: &expectEventsDollarPrefixedKey - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dollarPrefixedKey - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dollarPrefixedKey - - - description: "Inserting document with top-level dollar-prefixed key on pre-5.0 server yields server-side error" - runOnRequirements: - - maxServerVersion: "4.99" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - insertOne: - document: *dollarPrefixedKey - expectError: - isClientError: false - expectEvents: *expectEventsDollarPrefixedKey - outcome: *initialData - - - description: "Inserting document with top-level dotted key" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - insertOne: - document: &dottedKey { _id: 1, a.b: 1 } - expectResult: *bulkWriteResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dottedKey - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dottedKey - - - description: "Inserting document with dollar-prefixed key in embedded doc" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - insertOne: - document: &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } } - expectResult: *bulkWriteResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dollarPrefixedKeyInEmbedded - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dollarPrefixedKeyInEmbedded - - - description: "Inserting document with dotted key in embedded doc" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - insertOne: - document: &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } } - expectResult: *bulkWriteResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dottedKeyInEmbedded - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dottedKeyInEmbedded diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-dots_and_dollars.yml deleted file mode 100644 index 65c414c1d6d..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-dots_and_dollars.yml +++ /dev/null @@ -1,165 +0,0 @@ -description: "bulkWrite-replaceOne-dots_and_dollars" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - -tests: - - description: "Replacing document with top-level dotted key on 3.6+ server" - runOnRequirements: - - minServerVersion: "3.6" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - replaceOne: - filter: { _id: 1 } - replacement: &dottedKey { _id: 1, a.b: 1 } - expectResult: &bulkWriteResult - deletedCount: 0 - insertedCount: 0 - insertedIds: { $$unsetOrMatches: { } } - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - upsertedIds: { } - expectEvents: &expectEventsDottedKey - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dottedKey - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dottedKey - - - description: "Replacing document with top-level dotted key on pre-3.6 server yields server-side error" - runOnRequirements: - - maxServerVersion: "3.4.99" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - replaceOne: - filter: { _id: 1 } - replacement: *dottedKey - expectError: - isClientError: false - expectEvents: *expectEventsDottedKey - outcome: *initialData - - - description: "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - replaceOne: - filter: { _id: 1 } - replacement: &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } } - expectResult: *bulkWriteResult - expectEvents: &expectEventsDollarPrefixedKeyInEmbedded - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dollarPrefixedKeyInEmbedded - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dollarPrefixedKeyInEmbedded - - - description: "Replacing document with dollar-prefixed key in embedded doc on pre-5.0 server yields server-side error" - runOnRequirements: - - maxServerVersion: "4.99" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - replaceOne: - filter: { _id: 1 } - replacement: *dollarPrefixedKeyInEmbedded - expectError: - isClientError: false - expectEvents: *expectEventsDollarPrefixedKeyInEmbedded - outcome: *initialData - - - description: "Replacing document with dotted key in embedded doc on 3.6+ server" - runOnRequirements: - - minServerVersion: "3.6" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - replaceOne: - filter: { _id: 1 } - replacement: &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } } - expectResult: *bulkWriteResult - expectEvents: &expectEventsDottedKeyInEmbedded - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dottedKeyInEmbedded - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dottedKeyInEmbedded - - - description: "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error" - runOnRequirements: - - maxServerVersion: "3.4.99" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - replaceOne: - filter: { _id: 1 } - replacement: *dottedKeyInEmbedded - expectError: - isClientError: false - expectEvents: *expectEventsDottedKeyInEmbedded - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-hint-unacknowledged.yml deleted file mode 100644 index d656c5fc6b6..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-hint-unacknowledged.yml +++ /dev/null @@ -1,103 +0,0 @@ -description: bulkWrite-replaceOne-hint-unacknowledged - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - writeConcern: { w: 0 } - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: &documents - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - -tests: - - description: "Unacknowledged replaceOne with hint string fails with client-side error on pre-4.2 server" - runOnRequirements: - - maxServerVersion: "4.0.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - replaceOne: - filter: &filter { _id: { $gt: 1 } } - replacement: &replacement { x: 111 } - hint: _id_ - expectError: - isClientError: true - expectEvents: &noEvents - - client: *client0 - events: [] - - - description: "Unacknowledged replaceOne with hint document fails with client-side error on pre-4.2 server" - runOnRequirements: - - maxServerVersion: "4.0.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - replaceOne: - filter: *filter - replacement: *replacement - hint: { _id: 1 } - expectError: - isClientError: true - expectEvents: *noEvents - - - description: "Unacknowledged replaceOne with hint string on 4.2+ server" - runOnRequirements: - - minServerVersion: "4.2.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - replaceOne: - filter: *filter - replacement: *replacement - hint: _id_ - expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } - expectEvents: &events - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: *filter - u: *replacement - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - hint: { $$type: [ string, object ]} - writeConcern: { w: 0 } - - - description: "Unacknowledged replaceOne with hint document on 4.2+ server" - runOnRequirements: - - minServerVersion: "4.2.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - replaceOne: - filter: *filter - replacement: *replacement - hint: { _id: 1 } - expectResult: *unacknowledgedResult - expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-let.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-let.yml deleted file mode 100644 index 5453868ba4c..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-let.yml +++ /dev/null @@ -1,93 +0,0 @@ -description: "BulkWrite replaceOne-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - -tests: - - description: "BulkWrite replaceOne with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - replaceOne: - filter: &filter - $expr: - $eq: [ "$_id", "$$id" ] - replacement: &replacement {"x": 3} - let: &let - id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: *filter - u: *replacement - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - let: *let - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 3 } - - { _id: 2 } - - - description: "BulkWrite replaceOne with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "4.2" - maxServerVersion: "4.9" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - replaceOne: - filter: *filter - replacement: *replacement - let: *let - expectError: - errorContains: "'update.let' is an unknown field" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: *filter - u: *replacement - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - let: *let - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-sort.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-sort.yml deleted file mode 100644 index 6f326fe043c..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-replaceOne-sort.yml +++ /dev/null @@ -1,94 +0,0 @@ -description: BulkWrite replaceOne-sort - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent, commandSucceededEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: BulkWrite replaceOne with sort option - runOnRequirements: - - minServerVersion: "8.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - replaceOne: - filter: { _id: { $gt: 1 } } - sort: { _id: -1 } - replacement: { x: 1 } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: { $gt: 1 } } - u: { x: 1 } - sort: { _id: -1 } - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - - commandSucceededEvent: - reply: { ok: 1, n: 1 } - commandName: update - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 1 } - - - description: BulkWrite replaceOne with sort option unsupported (server-side error) - runOnRequirements: - - maxServerVersion: "7.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - replaceOne: - filter: { _id: { $gt: 1 } } - sort: { _id: -1 } - replacement: { x: 1 } - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: { $gt: 1 } } - u: { x: 1 } - sort: { _id: -1 } - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-clientError.yml deleted file mode 100644 index cf75a7c450f..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-clientError.yml +++ /dev/null @@ -1,145 +0,0 @@ -description: bulkWrite-update-hint-clientError -schemaVersion: '1.0' -runOnRequirements: - - - maxServerVersion: 3.3.99 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_bulkwrite_update_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 -tests: - - - description: 'BulkWrite updateOne with update hints unsupported (client-side error)' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - updateOne: - filter: &updateOne_filter - _id: 1 - update: &updateOne_update - $inc: - x: 1 - hint: &hint_string _id_ - - - updateOne: - filter: *updateOne_filter - update: *updateOne_update - hint: &hint_doc - _id: 1 - ordered: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 - - - description: 'BulkWrite updateMany with update hints unsupported (client-side error)' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - updateMany: - filter: &updateMany_filter - _id: - $lt: 3 - update: &updateMany_update - $inc: - x: 1 - hint: *hint_string - - - updateMany: - filter: *updateMany_filter - update: *updateMany_update - hint: *hint_doc - ordered: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: *outcome - - - description: 'BulkWrite replaceOne with update hints unsupported (client-side error)' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - replaceOne: - filter: - _id: 3 - replacement: - x: 333 - hint: *hint_string - - - replaceOne: - filter: - _id: 4 - replacement: - x: 444 - hint: *hint_doc - ordered: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-serverError.yml deleted file mode 100644 index 64310a2eaff..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint-serverError.yml +++ /dev/null @@ -1,236 +0,0 @@ -description: bulkWrite-update-hint-serverError -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 3.4.0 - maxServerVersion: 4.1.9 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_bulkwrite_update_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 -tests: - - - description: 'BulkWrite updateOne with update hints unsupported (server-side error)' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - updateOne: - filter: &updateOne_filter - _id: 1 - update: &updateOne_update - $inc: - x: 1 - hint: &hint_string _id_ - - - updateOne: - filter: *updateOne_filter - update: *updateOne_update - hint: &hint_doc - _id: 1 - ordered: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *updateOne_filter - u: *updateOne_update - hint: *hint_string - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - - - q: *updateOne_filter - u: *updateOne_update - hint: *hint_doc - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - ordered: true - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 - - - description: 'BulkWrite updateMany with update hints unsupported (server-side error)' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - updateMany: - filter: &updateMany_filter - _id: - $lt: 3 - update: &updateMany_update - $inc: - x: 1 - hint: *hint_string - - - updateMany: - filter: *updateMany_filter - update: *updateMany_update - hint: *hint_doc - ordered: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *updateMany_filter - u: *updateMany_update - multi: true - hint: *hint_string - upsert: { $$unsetOrMatches: false } - - - q: *updateMany_filter - u: *updateMany_update - multi: true - hint: *hint_doc - upsert: { $$unsetOrMatches: false } - ordered: true - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 - - - description: 'BulkWrite replaceOne with update hints unsupported (server-side error)' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - replaceOne: - filter: - _id: 3 - replacement: - x: 333 - hint: *hint_string - - - replaceOne: - filter: - _id: 4 - replacement: - x: 444 - hint: *hint_doc - ordered: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: - _id: 3 - u: - x: 333 - hint: *hint_string - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - - - q: - _id: 4 - u: - x: 444 - hint: *hint_doc - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - ordered: true - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint.yml deleted file mode 100644 index e739074ea26..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-hint.yml +++ /dev/null @@ -1,253 +0,0 @@ -description: bulkWrite-update-hint -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.2.0 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_bulkwrite_update_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 -tests: - - - description: 'BulkWrite updateOne with update hints' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - updateOne: - filter: &updateOne_filter - _id: 1 - update: &updateOne_update - $inc: - x: 1 - hint: &hint_string _id_ - - - updateOne: - filter: *updateOne_filter - update: *updateOne_update - hint: &hint_doc - _id: 1 - ordered: true - expectResult: - deletedCount: 0 - insertedCount: 0 - insertedIds: { $$unsetOrMatches: {} } - matchedCount: 2 - modifiedCount: 2 - upsertedCount: 0 - upsertedIds: { } - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *updateOne_filter - u: *updateOne_update - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - hint: *hint_string - - - q: *updateOne_filter - u: *updateOne_update - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - hint: *hint_doc - ordered: true - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 13 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 - - - description: 'BulkWrite updateMany with update hints' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - updateMany: - filter: &updateMany_filter - _id: - $lt: 3 - update: &updateMany_update - $inc: - x: 1 - hint: *hint_string - - - updateMany: - filter: *updateMany_filter - update: *updateMany_update - hint: *hint_doc - ordered: true - expectResult: - deletedCount: 0 - insertedCount: 0 - insertedIds: { $$unsetOrMatches: {} } - matchedCount: 4 - modifiedCount: 4 - upsertedCount: 0 - upsertedIds: { } - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *updateMany_filter - u: *updateMany_update - multi: true - upsert: { $$unsetOrMatches: false } - hint: *hint_string - - - q: *updateMany_filter - u: *updateMany_update - multi: true - upsert: { $$unsetOrMatches: false } - hint: *hint_doc - ordered: true - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 13 - - - _id: 2 - x: 24 - - - _id: 3 - x: 33 - - - _id: 4 - x: 44 - - - description: 'BulkWrite replaceOne with update hints' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - replaceOne: - filter: - _id: 3 - replacement: - x: 333 - hint: *hint_string - - - replaceOne: - filter: - _id: 4 - replacement: - x: 444 - hint: *hint_doc - ordered: true - expectResult: - deletedCount: 0 - insertedCount: 0 - insertedIds: { $$unsetOrMatches: {} } - matchedCount: 2 - modifiedCount: 2 - upsertedCount: 0 - upsertedIds: { } - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: - _id: 3 - u: - x: 333 - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - hint: *hint_string - - - q: - _id: 4 - u: - x: 444 - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - hint: *hint_doc - ordered: true - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 333 - - - _id: 4 - x: 444 diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-validation.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-validation.yml deleted file mode 100644 index 57defd56a46..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-update-validation.yml +++ /dev/null @@ -1,73 +0,0 @@ -description: "bulkWrite-update-validation" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: "BulkWrite replaceOne prohibits atomic modifiers" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - replaceOne: - filter: { _id: 1 } - replacement: { $set: { x: 22 } } - expectError: - isClientError: true - expectEvents: - - client: *client0 - events: [] - outcome: *initialData - - - description: "BulkWrite updateOne requires atomic modifiers" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - updateOne: - filter: { _id: 1 } - update: { x: 22 } - expectError: - isClientError: true - expectEvents: - - client: *client0 - events: [] - outcome: *initialData - - - description: "BulkWrite updateMany requires atomic modifiers" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - updateMany: - filter: { _id: { $gt: 1 } } - update: { x: 44 } - expectError: - isClientError: true - expectEvents: - - client: *client0 - events: [] - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-dots_and_dollars.yml deleted file mode 100644 index 68cebd09cf2..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-dots_and_dollars.yml +++ /dev/null @@ -1,150 +0,0 @@ -description: "bulkWrite-updateMany-dots_and_dollars" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {} } - -tests: - - description: "Updating document to set top-level dollar-prefixed key on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - updateMany: - filter: { _id: 1 } - update: &dollarPrefixedKey - - { $replaceWith: { $setField: { field: { $literal: $a }, value: 1, input: $$ROOT } } } - expectResult: &bulkWriteResult - deletedCount: 0 - insertedCount: 0 - insertedIds: { $$unsetOrMatches: { } } - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - upsertedIds: { } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dollarPrefixedKey - multi: true - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {}, $a: 1 } - - - description: "Updating document to set top-level dotted key on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - updateMany: - filter: { _id: 1 } - update: &dottedKey - - { $replaceWith: { $setField: { field: { $literal: a.b }, value: 1, input: $$ROOT } } } - expectResult: *bulkWriteResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dottedKey - multi: true - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {}, a.b: 1 } - - - description: "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - updateMany: - filter: { _id: 1 } - update: &dollarPrefixedKeyInEmbedded - - { $set: { foo: { $setField: { field: { $literal: $a }, value: 1, input: $foo } } } } - expectResult: *bulkWriteResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dollarPrefixedKeyInEmbedded - multi: true - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: { $a: 1 } } - - - description: "Updating document to set dotted key in embedded doc on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - updateMany: - filter: { _id: 1 } - update: &dottedKeyInEmbedded - - { $set: { foo: { $setField: { field: { $literal: a.b }, value: 1, input: $foo } } } } - expectResult: *bulkWriteResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dottedKeyInEmbedded - multi: true - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: { a.b: 1 } } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-hint-unacknowledged.yml deleted file mode 100644 index 7cb376c90c0..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-hint-unacknowledged.yml +++ /dev/null @@ -1,104 +0,0 @@ -description: bulkWrite-updateMany-hint-unacknowledged - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - writeConcern: { w: 0 } - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: &documents - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: "Unacknowledged updateMany with hint string fails with client-side error on pre-4.2 server" - runOnRequirements: - - maxServerVersion: "4.0.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateMany: - filter: &filter { _id: { $gt: 1 } } - update: &update { $inc: { x: 1 } } - hint: _id_ - expectError: - isClientError: true - expectEvents: &noEvents - - client: *client0 - events: [] - - - description: "Unacknowledged updateMany with hint document fails with client-side error on pre-4.2 server" - runOnRequirements: - - maxServerVersion: "4.0.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateMany: - filter: *filter - update: *update - hint: { _id: 1 } - expectError: - isClientError: true - expectEvents: *noEvents - - - description: "Unacknowledged updateMany with hint string on 4.2+ server" - runOnRequirements: - - minServerVersion: "4.2.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateMany: - filter: *filter - update: *update - hint: _id_ - expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } - expectEvents: &events - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: *filter - u: *update - multi: true - upsert: { $$unsetOrMatches: false } - hint: { $$type: [ string, object ]} - writeConcern: { w: 0 } - - - description: "Unacknowledged updateMany with hint document on 4.2+ server" - runOnRequirements: - - minServerVersion: "4.2.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateMany: - filter: *filter - update: *update - hint: { _id: 1 } - expectResult: *unacknowledgedResult - expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-let.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-let.yml deleted file mode 100644 index f67d000334a..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateMany-let.yml +++ /dev/null @@ -1,96 +0,0 @@ -description: "BulkWrite updateMany-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 20 } - - { _id: 2, x: 21 } - -tests: - - description: "BulkWrite updateMany with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateMany: - filter: &filter - $expr: - $eq: [ "$_id", "$$id" ] - update: &update - - $set: - x: 21 - let: &let - id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: *filter - u: *update - multi: true - upsert: { $$unsetOrMatches: false } - let: *let - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 21 } - - { _id: 2, x: 21 } - - - description: "BulkWrite updateMany with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "4.2.0" - maxServerVersion: "4.9" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateMany: - filter: *filter - update: *update - let: *let - expectError: - errorContains: "'update.let' is an unknown field" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: *filter - u: *update - multi: true - upsert: { $$unsetOrMatches: false } - let: *let - - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 20 } - - { _id: 2, x: 21 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-dots_and_dollars.yml deleted file mode 100644 index c5a1662db10..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-dots_and_dollars.yml +++ /dev/null @@ -1,150 +0,0 @@ -description: "bulkWrite-updateOne-dots_and_dollars" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {} } - -tests: - - description: "Updating document to set top-level dollar-prefixed key on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - updateOne: - filter: { _id: 1 } - update: &dollarPrefixedKey - - { $replaceWith: { $setField: { field: { $literal: $a }, value: 1, input: $$ROOT } } } - expectResult: &bulkWriteResult - deletedCount: 0 - insertedCount: 0 - insertedIds: { $$unsetOrMatches: { } } - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - upsertedIds: { } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dollarPrefixedKey - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {}, $a: 1 } - - - description: "Updating document to set top-level dotted key on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - updateOne: - filter: { _id: 1 } - update: &dottedKey - - { $replaceWith: { $setField: { field: { $literal: a.b }, value: 1, input: $$ROOT } } } - expectResult: *bulkWriteResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dottedKey - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {}, a.b: 1 } - - - description: "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - updateOne: - filter: { _id: 1 } - update: &dollarPrefixedKeyInEmbedded - - { $set: { foo: { $setField: { field: { $literal: $a }, value: 1, input: $foo } } } } - expectResult: *bulkWriteResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dollarPrefixedKeyInEmbedded - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: { $a: 1 } } - - - description: "Updating document to set dotted key in embedded doc on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: bulkWrite - object: *collection0 - arguments: - requests: - - updateOne: - filter: { _id: 1 } - update: &dottedKeyInEmbedded - - { $set: { foo: { $setField: { field: { $literal: a.b }, value: 1, input: $foo } } } } - expectResult: *bulkWriteResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dottedKeyInEmbedded - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: { a.b: 1 } } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-hint-unacknowledged.yml deleted file mode 100644 index 5997c54c2b5..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-hint-unacknowledged.yml +++ /dev/null @@ -1,103 +0,0 @@ -description: bulkWrite-updateOne-hint-unacknowledged - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - writeConcern: { w: 0 } - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: &documents - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - -tests: - - description: "Unacknowledged updateOne with hint string fails with client-side error on pre-4.2 server" - runOnRequirements: - - maxServerVersion: "4.0.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateOne: - filter: &filter { _id: { $gt: 1 } } - update: &update { $inc: { x: 1 } } - hint: _id_ - expectError: - isClientError: true - expectEvents: &noEvents - - client: *client0 - events: [] - - - description: "Unacknowledged updateOne with hint document fails with client-side error on pre-4.2 server" - runOnRequirements: - - maxServerVersion: "4.0.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateOne: - filter: *filter - update: *update - hint: { _id: 1 } - expectError: - isClientError: true - expectEvents: *noEvents - - - description: "Unacknowledged updateOne with hint string on 4.2+ server" - runOnRequirements: - - minServerVersion: "4.2.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateOne: - filter: *filter - update: *update - hint: _id_ - expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } - expectEvents: &events - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: *filter - u: *update - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - hint: { $$type: [ string, object ]} - writeConcern: { w: 0 } - - - description: "Unacknowledged updateOne with hint document on 4.2+ server" - runOnRequirements: - - minServerVersion: "4.2.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateOne: - filter: *filter - update: *update - hint: { _id: 1 } - expectResult: *unacknowledgedResult - expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-let.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-let.yml deleted file mode 100644 index dc3cd2b5999..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-let.yml +++ /dev/null @@ -1,95 +0,0 @@ -description: "BulkWrite updateOne-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 20 } - - { _id: 2, x: 21 } - -tests: - - description: "BulkWrite updateOne with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateOne: - filter: &filter - $expr: - $eq: [ "$_id", "$$id" ] - update: &update - - $set: - x: 22 - let: &let - id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: *filter - u: *update - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - let: *let - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 22 } - - { _id: 2, x: 21 } - - - description: "BulkWrite updateOne with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "4.2.0" - maxServerVersion: "4.9" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateOne: - filter: *filter - update: *update - let: *let - expectError: - errorContains: "'update.let' is an unknown field" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: *filter - u: *update - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - let: *let - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 20 } - - { _id: 2, x: 21 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-sort.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-sort.yml deleted file mode 100644 index 72bc814d69e..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-updateOne-sort.yml +++ /dev/null @@ -1,94 +0,0 @@ -description: BulkWrite updateOne-sort - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent, commandSucceededEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: BulkWrite updateOne with sort option - runOnRequirements: - - minServerVersion: "8.0" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateOne: - filter: { _id: { $gt: 1 } } - sort: { _id: -1 } - update: [ $set: { x: 1 } ] - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: { $gt: 1 } } - u: [ $set: { x: 1 } ] - sort: { _id: -1 } - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - - commandSucceededEvent: - reply: { ok: 1, n: 1 } - commandName: update - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 1 } - - - description: BulkWrite updateOne with sort option unsupported (server-side error) - runOnRequirements: - - maxServerVersion: "7.99" - operations: - - object: *collection0 - name: bulkWrite - arguments: - requests: - - updateOne: - filter: { _id: { $gt: 1 } } - sort: { _id: -1 } - update: [ $set: { x: 1 } ] - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: { $gt: 1 } } - u: [ $set: { x: 1 } ] - sort: { _id: -1 } - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite.yml b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite.yml deleted file mode 100644 index 677e6725c44..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite.yml +++ /dev/null @@ -1,448 +0,0 @@ -description: bulkWrite - -schemaVersion: '1.0' - -runOnRequirements: - - - minServerVersion: '2.6' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - -tests: - - - description: 'BulkWrite with deleteOne operations' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - # Note: as in the "DeleteOne when many documents match" test in - # deleteOne.yml, we omit a deleteOne operation that might match - # multiple documents as that would hinder our ability to assert the - # final state of the collection under test. - requests: - - - # does not match an existing document - deleteOne: - filter: { _id: 3 } - - - # deletes the matched document - deleteOne: - filter: { _id: 2 } - ordered: true - expectResult: - deletedCount: 1 - insertedCount: 0 - insertedIds: - $$unsetOrMatches: { } - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - upsertedIds: { } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - - description: 'BulkWrite with deleteMany operations' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - # does not match any existing documents - deleteMany: - filter: { x: { $lt: 11 } } - - - # deletes the matched documents - deleteMany: - filter: { x: { $lte: 22 } } - ordered: true - expectResult: - deletedCount: 2 - insertedCount: 0 - insertedIds: - $$unsetOrMatches: { } - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - upsertedIds: { } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: [] - - - description: 'BulkWrite with insertOne operations' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - insertOne: - document: { _id: 3, x: 33 } - - - insertOne: - document: { _id: 4, x: 44 } - ordered: true - expectResult: - deletedCount: 0 - insertedCount: 2 - insertedIds: - $$unsetOrMatches: - '0': 3 - '1': 4 - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - upsertedIds: { } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - - description: 'BulkWrite with replaceOne operations' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - # Note: as in the "ReplaceOne when many documents match" test in - # replaceOne.yml, we omit a replaceOne operation that might match - # multiple documents as that would hinder our ability to assert the - # final state of the collection under test. - requests: - - - # does not match an existing document - replaceOne: - filter: { _id: 3 } - replacement: { x: 33 } - - - # modifies the matched document - replaceOne: - filter: { _id: 1 } - replacement: { x: 12 } - - - # does not match an existing document and upserts - replaceOne: - filter: { _id: 3 } - replacement: { x: 33 } - upsert: true - ordered: true - expectResult: - deletedCount: 0 - insertedCount: 0 - insertedIds: - $$unsetOrMatches: { } - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 1 - upsertedIds: { '2': 3 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 12 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - - description: 'BulkWrite with updateOne operations' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - # Note: as in the "UpdateOne when many documents match" test in - # updateOne.yml, we omit an updateOne operation that might match - # multiple documents as that would hinder our ability to assert the - # final state of the collection under test. - requests: - - - # does not match an existing document - updateOne: - filter: { _id: 0 } - update: { $set: { x: 0 } } - - - # does not modify the matched document - updateOne: - filter: { _id: 1 } - update: { $set: { x: 11 } } - - - # modifies the matched document - updateOne: - filter: { _id: 2 } - update: { $inc: { x: 1 } } - - - # does not match an existing document and upserts - updateOne: - filter: { _id: 3 } - update: { $set: { x: 33 } } - upsert: true - ordered: true - expectResult: - deletedCount: 0 - insertedCount: 0 - insertedIds: - $$unsetOrMatches: { } - matchedCount: 2 - modifiedCount: 1 - upsertedCount: 1 - upsertedIds: { '3': 3 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 23 } - - { _id: 3, x: 33 } - - - description: 'BulkWrite with updateMany operations' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - # does not match any existing documents - updateMany: - filter: { x: { $lt: 11 } } - update: { $set: { x: 0 } } - - - # does not modify the matched documents - updateMany: - filter: { x: { $lte: 22 } } - update: { $unset: { y: 1 } } - - - # modifies the matched documents - updateMany: - filter: { x: { $lte: 22 } } - update: { $inc: { x: 1 } } - - - # does not match any existing documents and upserts - updateMany: - filter: { _id: 3 } - update: { $set: { x: 33 } } - upsert: true - ordered: true - expectResult: - deletedCount: 0 - insertedCount: 0 - insertedIds: - $$unsetOrMatches: { } - matchedCount: 4 - modifiedCount: 2 - upsertedCount: 1 - upsertedIds: { '3': 3 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 12 } - - { _id: 2, x: 23 } - - { _id: 3, x: 33 } - - - description: 'BulkWrite with mixed ordered operations' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - insertOne: - document: { _id: 3, x: 33 } - - - updateOne: - filter: { _id: 2 } - update: { $inc: { x: 1 } } - - - updateMany: - filter: { _id: { $gt: 1 } } - update: { $inc: { x: 1 } } - - - insertOne: - document: { _id: 4, x: 44 } - - - deleteMany: - filter: { x: { $nin: [ 24, 34 ] } } - - - replaceOne: - filter: { _id: 4 } - replacement: { _id: 4, x: 44 } - upsert: true - ordered: true - expectResult: - deletedCount: 2 - insertedCount: 2 - insertedIds: - $$unsetOrMatches: - '0': 3 - '3': 4 - matchedCount: 3 - modifiedCount: 3 - upsertedCount: 1 - upsertedIds: { '5': 4 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 2, x: 24 } - - { _id: 3, x: 34 } - - { _id: 4, x: 44 } - - - description: 'BulkWrite with mixed unordered operations' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - # We omit inserting multiple documents and updating documents that may - # not exist at the start of this test as we cannot assume the order in - # which the operations will execute. - requests: - - - replaceOne: - filter: { _id: 3 } - replacement: { _id: 3, x: 33 } - upsert: true - - - deleteOne: - filter: { _id: 1 } - - - updateOne: - filter: { _id: 2 } - update: { $inc: { x: 1 } } - ordered: false - expectResult: - deletedCount: 1 - insertedCount: 0 - insertedIds: - $$unsetOrMatches: { } - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 1 - upsertedIds: { '0': 3 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 2, x: 23 } - - { _id: 3, x: 33 } - - - description: 'BulkWrite continue-on-error behavior with unordered (preexisting duplicate key)' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - insertOne: - document: { _id: 2, x: 22 } - - - insertOne: - document: { _id: 3, x: 33 } - - - insertOne: - document: { _id: 4, x: 44 } - ordered: false - expectError: - isError: true - expectResult: - deletedCount: 0 - insertedCount: 2 - # Since the map of insertedIds is generated before execution it - # could indicate inserts that did not actually succeed. We omit this - # field rather than expect drivers to provide an accurate map - # filtered by write errors. - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - upsertedIds: { } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - - description: 'BulkWrite continue-on-error behavior with unordered (duplicate key in requests)' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - insertOne: - document: { _id: 3, x: 33 } - - - insertOne: - document: { _id: 3, x: 33 } - - - insertOne: - document: { _id: 4, x: 44 } - ordered: false - expectError: - isError: true - expectResult: - deletedCount: 0 - insertedCount: 2 - # Since the map of insertedIds is generated before execution it - # could indicate inserts that did not actually succeed. We omit this - # field rather than expect drivers to provide an accurate map - # filtered by write errors. - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - upsertedIds: { } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/count-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/count-collation.yml deleted file mode 100644 index 692a3c69880..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/count-collation.yml +++ /dev/null @@ -1,57 +0,0 @@ -description: count-collation - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '3.4' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: ping } - -tests: - - - description: 'Count documents with collation' - operations: - - - object: *collection0 - name: countDocuments - arguments: - filter: { x: ping } - # https://www.mongodb.com/docs/manual/reference/collation/#collation-document - collation: - locale: en_US - strength: 2 - expectResult: 1 - - - description: 'Deprecated count with collation' - operations: - - - object: *collection0 - name: count - arguments: - filter: { x: ping } - collation: - locale: en_US - strength: 2 - expectResult: 1 diff --git a/driver-core/src/test/resources/unified-test-format/crud/count-empty.yml b/driver-core/src/test/resources/unified-test-format/crud/count-empty.yml deleted file mode 100644 index a5d5ae35b7c..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/count-empty.yml +++ /dev/null @@ -1,52 +0,0 @@ -description: count-empty - -schemaVersion: '1.0' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: [] - -tests: - - - description: 'Estimated document count with empty collection' - operations: - - - object: *collection0 - name: estimatedDocumentCount - arguments: { } - expectResult: 0 - - - description: 'Count documents with empty collection' - operations: - - - object: *collection0 - name: countDocuments - arguments: - filter: { } - expectResult: 0 - - - description: 'Deprecated count with empty collection' - operations: - - - object: *collection0 - name: count - arguments: - filter: { } - expectResult: 0 diff --git a/driver-core/src/test/resources/unified-test-format/crud/count.yml b/driver-core/src/test/resources/unified-test-format/crud/count.yml deleted file mode 100644 index 5f9fbb76338..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/count.yml +++ /dev/null @@ -1,95 +0,0 @@ -description: count - -schemaVersion: '1.0' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - - description: 'Estimated document count' - operations: - - - object: *collection0 - name: estimatedDocumentCount - arguments: { } - expectResult: 3 - - - description: 'Count documents without a filter' - operations: - - - object: *collection0 - name: countDocuments - arguments: - filter: { } - expectResult: 3 - - - description: 'Count documents with a filter' - operations: - - - object: *collection0 - name: countDocuments - arguments: - filter: { _id: { $gt: 1 } } - expectResult: 2 - - - description: 'Count documents with skip and limit' - operations: - - - object: *collection0 - name: countDocuments - arguments: - filter: { } - skip: 1 - limit: 3 - expectResult: 2 - - - description: 'Deprecated count without a filter' - operations: - - - object: *collection0 - name: count - arguments: - filter: { } - expectResult: 3 - - - description: 'Deprecated count with a filter' - operations: - - - object: *collection0 - name: count - arguments: - filter: { _id: { $gt: 1 } } - expectResult: 2 - - - description: 'Deprecated count with skip and limit' - operations: - - - object: *collection0 - name: count - arguments: - filter: { } - skip: 1 - limit: 3 - expectResult: 2 diff --git a/driver-core/src/test/resources/unified-test-format/crud/countDocuments-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/countDocuments-comment.yml deleted file mode 100644 index 8f1f7bc4b4d..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/countDocuments-comment.yml +++ /dev/null @@ -1,92 +0,0 @@ -description: "countDocuments-comment" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name countDocuments-comments-test - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: "countDocuments with document comment" - runOnRequirements: - - minServerVersion: 4.4.0 - operations: - - name: countDocuments - object: *collection0 - arguments: - filter: {} - comment: &documentComment { key: "value" } - expectResult: 3 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: &pipeline - - $match: {} - - $group: { _id: 1, n: { $sum: 1 } } - comment: *documentComment - commandName: aggregate - databaseName: *database0Name - - - description: "countDocuments with string comment" - runOnRequirements: - - minServerVersion: 3.6.0 - operations: - - name: countDocuments - object: *collection0 - arguments: - filter: {} - comment: &stringComment "comment" - expectResult: 3 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *pipeline - comment: *stringComment - commandName: aggregate - databaseName: *database0Name - - - description: "countDocuments with document comment on less than 4.4.0 - server error" - runOnRequirements: - - minServerVersion: 3.6.0 - maxServerVersion: 4.3.99 - operations: - - name: countDocuments - object: *collection0 - arguments: - filter: {} - comment: *documentComment - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: *collection0Name - pipeline: *pipeline - comment: *documentComment - commandName: aggregate - databaseName: *database0Name diff --git a/driver-core/src/test/resources/unified-test-format/crud/db-aggregate-write-readPreference.yml b/driver-core/src/test/resources/unified-test-format/crud/db-aggregate-write-readPreference.yml deleted file mode 100644 index 03fcd35aa35..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/db-aggregate-write-readPreference.yml +++ /dev/null @@ -1,138 +0,0 @@ -description: db-aggregate-write-readPreference - -schemaVersion: '1.4' - -runOnRequirements: - # 3.6+ non-standalone is needed to utilize $readPreference in OP_MSG. - # Serverless does not support $listLocalSessions and $currentOp stages, and - # mongos does not allow combining them with $out or $merge. - - minServerVersion: "3.6" - topologies: [ replicaset ] - serverless: forbid - -_yamlAnchors: - readConcern: &readConcern - level: &readConcernLevel "local" - writeConcern: &writeConcern - w: &writeConcernW 1 - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - # Used to test that read and write concerns are still inherited - uriOptions: - readConcernLevel: *readConcernLevel - w: *writeConcernW - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - databaseOptions: - readPreference: &readPreference - # secondaryPreferred is specified for compatibility with clusters that - # may not have a secondary (e.g. each shard is only a primary). - mode: secondaryPreferred - # maxStalenessSeconds is specified to ensure that drivers forward the - # read preference to mongos or a load balancer. That would not be the - # case with only secondaryPreferred. - maxStalenessSeconds: 600 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -tests: - - description: "Database-level aggregate with $out includes read preference for 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - serverless: "forbid" - operations: - - object: *database0 - name: aggregate - arguments: - pipeline: &outPipeline - - { $listLocalSessions: {} } - - { $limit: 1 } - - { $addFields: { _id: 1 } } - - { $project: { _id: 1 } } - - { $out: *collection0Name } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: 1 - pipeline: *outPipeline - $readPreference: *readPreference - readConcern: *readConcern - writeConcern: *writeConcern - - - description: "Database-level aggregate with $out omits read preference for pre-5.0 server" - runOnRequirements: - # MongoDB 4.2 introduced support for read concerns and write stages. - # Pre-4.2 servers may allow a "local" read concern anyway, but some - # drivers may avoid inheriting a client-level read concern for pre-4.2. - - minServerVersion: "4.2" - maxServerVersion: "4.4.99" - serverless: "forbid" - operations: - - object: *database0 - name: aggregate - arguments: - pipeline: *outPipeline - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: 1 - pipeline: *outPipeline - $readPreference: { $$exists: false } - readConcern: *readConcern - writeConcern: *writeConcern - - - description: "Database-level aggregate with $merge includes read preference for 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - object: *database0 - name: aggregate - arguments: - pipeline: &mergePipeline - - { $listLocalSessions: {} } - - { $limit: 1 } - - { $addFields: { _id: 1 } } - - { $project: { _id: 1 } } - - { $merge: { into: *collection0Name } } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: 1 - pipeline: *mergePipeline - $readPreference: *readPreference - readConcern: *readConcern - writeConcern: *writeConcern - - - description: "Database-level aggregate with $merge omits read preference for pre-5.0 server" - runOnRequirements: - - minServerVersion: "4.2" - maxServerVersion: "4.4.99" - operations: - - object: *database0 - name: aggregate - arguments: - pipeline: *mergePipeline - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - aggregate: 1 - pipeline: *mergePipeline - $readPreference: { $$exists: false } - readConcern: *readConcern - writeConcern: *writeConcern diff --git a/driver-core/src/test/resources/unified-test-format/crud/db-aggregate.yml b/driver-core/src/test/resources/unified-test-format/crud/db-aggregate.yml deleted file mode 100644 index df82c32b059..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/db-aggregate.yml +++ /dev/null @@ -1,70 +0,0 @@ -description: db-aggregate -schemaVersion: '1.4' -runOnRequirements: - - - minServerVersion: 3.6.0 - # serverless does not support either of the current database-level aggregation stages ($listLocalSessions and - # $currentOp) - serverless: forbid -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name admin - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name crud-v2 -tests: - - - description: 'Aggregate with $listLocalSessions' - operations: - - - object: *database0 - name: aggregate - arguments: - pipeline: - - - $listLocalSessions: { } - - - $limit: 1 - - - $addFields: - dummy: 'dummy field' - - - $project: - _id: 0 - dummy: 1 - expectResult: - - - dummy: 'dummy field' - - - description: 'Aggregate with $listLocalSessions and allowDiskUse' - operations: - - - object: *database0 - name: aggregate - arguments: - pipeline: - - - $listLocalSessions: { } - - - $limit: 1 - - - $addFields: - dummy: 'dummy field' - - - $project: - _id: 0 - dummy: 1 - allowDiskUse: true - expectResult: - - - dummy: 'dummy field' diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-collation.yml deleted file mode 100644 index b7caab67dd0..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-collation.yml +++ /dev/null @@ -1,54 +0,0 @@ -description: deleteMany-collation - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '3.4' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: ping } - - { _id: 3, x: pINg } - -tests: - - - description: 'DeleteMany when many documents match with collation' - operations: - - - object: *collection0 - name: deleteMany - arguments: - filter: { x: PING } - # https://www.mongodb.com/docs/manual/reference/collation/#collation-document - collation: - locale: en_US - strength: 2 - expectResult: - deletedCount: 2 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-comment.yml deleted file mode 100644 index 8f1b3522a76..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-comment.yml +++ /dev/null @@ -1,97 +0,0 @@ -description: "deleteMany-comment" -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2, name: "name2" } - - { _id: 3, name: "name3" } - -tests: - - description: "deleteMany with string comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: deleteMany - object: *collection0 - arguments: - filter: &filter { _id: { $gt: 1 } } - comment: "comment" - expectResult: &expect_result - deletedCount: 2 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - limit: 0 - comment: "comment" - outcome: &outcome - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - - description: "deleteMany with document comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: deleteMany - object: *collection0 - arguments: - filter: *filter - comment: &comment { key: "value" } - expectResult: *expect_result - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - limit: 0 - comment: *comment - outcome: *outcome - - - description: "deleteMany with comment - pre 4.4" - runOnRequirements: - - minServerVersion: "3.4.0" - maxServerVersion: "4.2.99" - operations: - - name: deleteMany - object: *collection0 - arguments: - filter: *filter - comment: "comment" - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - limit: 0 - comment: "comment" - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-clientError.yml deleted file mode 100644 index c04d7507e33..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-clientError.yml +++ /dev/null @@ -1,84 +0,0 @@ -description: deleteMany-hint-clientError -schemaVersion: '1.0' -runOnRequirements: - - - maxServerVersion: 3.3.99 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name DeleteMany_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 -tests: - - - description: 'DeleteMany with hint string unsupported (client-side error)' - operations: - - - object: *collection0 - name: deleteMany - arguments: - filter: &filter - _id: - $gt: 1 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - description: 'DeleteMany with hint document unsupported (client-side error)' - operations: - - - object: *collection0 - name: deleteMany - arguments: - filter: *filter - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-serverError.yml deleted file mode 100644 index 24260e2611a..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-serverError.yml +++ /dev/null @@ -1,104 +0,0 @@ -description: deleteMany-hint-serverError -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 3.4.0 - maxServerVersion: 4.3.3 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name DeleteMany_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 -tests: - - - description: 'DeleteMany with hint string unsupported (server-side error)' - operations: - - - object: *collection0 - name: deleteMany - arguments: - filter: &filter - _id: - $gt: 1 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - - q: *filter - hint: _id_ - limit: 0 - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - description: 'DeleteMany with hint document unsupported (server-side error)' - operations: - - - object: *collection0 - name: deleteMany - arguments: - filter: *filter - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - - q: *filter - hint: - _id: 1 - limit: 0 - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-unacknowledged.yml deleted file mode 100644 index 827618d174f..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint-unacknowledged.yml +++ /dev/null @@ -1,90 +0,0 @@ -description: deleteMany-hint-unacknowledged - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - writeConcern: { w: 0 } - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: &documents - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: "Unacknowledged deleteMany with hint string fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: deleteMany - arguments: - filter: &filter { _id: { $gt: 1 } } - hint: _id_ - expectError: - isClientError: true - expectEvents: &noEvents - - client: *client0 - events: [] - - - description: "Unacknowledged deleteMany with hint document fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: deleteMany - arguments: - filter: *filter - hint: { _id: 1 } - expectError: - isClientError: true - expectEvents: *noEvents - - - description: "Unacknowledged deleteMany with hint string on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: deleteMany - arguments: - filter: *filter - hint: _id_ - expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } - expectEvents: &events - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - hint: { $$type: [ string, object ]} - limit: 0 - writeConcern: { w: 0 } - - - description: "Unacknowledged deleteMany with hint document on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: deleteMany - arguments: - filter: *filter - hint: { _id: 1 } - expectResult: *unacknowledgedResult - expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint.yml deleted file mode 100644 index ce5f0a058d3..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-hint.yml +++ /dev/null @@ -1,96 +0,0 @@ -description: deleteMany-hint -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.3.4 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name DeleteMany_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 -tests: - - - description: 'DeleteMany with hint string' - operations: - - - object: *collection0 - name: deleteMany - arguments: - filter: &filter - _id: - $gt: 1 - hint: _id_ - expectResult: &result - deletedCount: 2 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - - q: *filter - hint: _id_ - limit: 0 - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - description: 'DeleteMany with hint document' - operations: - - - object: *collection0 - name: deleteMany - arguments: - filter: *filter - hint: - _id: 1 - expectResult: *result - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - - q: *filter - hint: - _id: 1 - limit: 0 - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-let.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany-let.yml deleted file mode 100644 index 723985aa8c0..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteMany-let.yml +++ /dev/null @@ -1,93 +0,0 @@ -description: "deleteMany-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2, name: "name" } - - { _id: 3, name: "name" } - -tests: - - description: "deleteMany with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: deleteMany - object: *collection0 - arguments: - filter: &filter - $expr: - $eq: [ "$name", "$$name" ] - let: &let0 - name: "name" - expectResult: - deletedCount: 2 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - - q: *filter - limit: 0 - let: *let0 - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - - description: "deleteMany with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "3.6.0" - maxServerVersion: "4.4.99" - operations: - - name: deleteMany - object: *collection0 - arguments: - filter: &filter1 - $expr: - $eq: [ "$name", "$$name" ] - let: &let1 - name: "name" - expectError: - errorContains: "'delete.let' is an unknown field" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - - q: *filter1 - limit: 0 - let: *let1 - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2, name: "name" } - - { _id: 3, name: "name" } diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteMany.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteMany.yml deleted file mode 100644 index 832201ed51a..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteMany.yml +++ /dev/null @@ -1,63 +0,0 @@ -description: deleteMany - -schemaVersion: '1.0' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - - description: 'DeleteMany when many documents match' - operations: - - - object: *collection0 - name: deleteMany - arguments: - filter: { _id: { $gt: 1 } } - expectResult: - deletedCount: 2 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - - description: 'DeleteMany when no document matches' - operations: - - - object: *collection0 - name: deleteMany - arguments: - filter: { _id: 4 } - expectResult: - deletedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-collation.yml deleted file mode 100644 index 2ec971550ac..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-collation.yml +++ /dev/null @@ -1,55 +0,0 @@ -description: deleteOne-collation - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '3.4' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: ping } - - { _id: 3, x: pINg } - -tests: - - - description: 'DeleteOne when many documents matches with collation' - operations: - - - object: *collection0 - name: deleteOne - arguments: - filter: { x: PING } - # https://www.mongodb.com/docs/manual/reference/collation/#collation-document - collation: - locale: en_US - strength: 2 - expectResult: - deletedCount: 1 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 3, x: pINg } diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-comment.yml deleted file mode 100644 index 1e52298f397..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-comment.yml +++ /dev/null @@ -1,98 +0,0 @@ -description: "deleteOne-comment" -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2, name: "name" } - - { _id: 3, name: "name" } - -tests: - - description: "deleteOne with string comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: deleteOne - object: *collection0 - arguments: - filter: &filter { _id: 1 } - comment: "comment" - expectResult: &expect_result - deletedCount: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - limit: 1 - comment: "comment" - outcome: &outcome - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 2, name: "name" } - - { _id: 3, name: "name" } - - - description: "deleteOne with document comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: deleteOne - object: *collection0 - arguments: - filter: *filter - comment: &comment { key: "value" } - expectResult: *expect_result - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - limit: 1 - comment: *comment - outcome: *outcome - - - description: "deleteOne with comment - pre 4.4" - runOnRequirements: - - minServerVersion: "3.4.0" - maxServerVersion: "4.2.99" - operations: - - name: deleteOne - object: *collection0 - arguments: - filter: *filter - comment: "comment" - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - limit: 1 - comment: "comment" - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-errorResponse.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-errorResponse.yml deleted file mode 100644 index dcf013060e9..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-errorResponse.yml +++ /dev/null @@ -1,46 +0,0 @@ -description: "deleteOne-errorResponse" - -schemaVersion: "1.12" - -createEntities: - - client: - id: &client0 client0 - useMultipleMongoses: false - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name test - -tests: - # Some drivers may still need to skip this test because the CRUD spec does not - # prescribe how drivers should formulate a WriteException beyond collecting a - # write or write concern error. - - description: "delete operations support errorResponse assertions" - runOnRequirements: - - minServerVersion: "4.0.0" - topologies: [ single, replicaset ] - - minServerVersion: "4.2.0" - topologies: [ sharded ] - operations: - - name: failPoint - object: testRunner - arguments: - client: *client0 - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: [ delete ] - errorCode: &errorCode 8 # UnknownError - - name: deleteOne - object: *collection0 - arguments: - filter: { _id: 1 } - expectError: - errorCode: *errorCode - errorResponse: - code: *errorCode diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-clientError.yml deleted file mode 100644 index 7ff6f8d9615..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-clientError.yml +++ /dev/null @@ -1,77 +0,0 @@ -description: deleteOne-hint-clientError -schemaVersion: '1.0' -runOnRequirements: - - - maxServerVersion: 3.3.99 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name DeleteOne_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'DeleteOne with hint string unsupported (client-side error)' - operations: - - - object: *collection0 - name: deleteOne - arguments: - filter: &filter - _id: 1 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - description: 'DeleteOne with hint document unsupported (client-side error)' - operations: - - - object: *collection0 - name: deleteOne - arguments: - filter: *filter - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-serverError.yml deleted file mode 100644 index 191d96aeaf4..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-serverError.yml +++ /dev/null @@ -1,97 +0,0 @@ -description: deleteOne-hint-serverError -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 3.4.0 - maxServerVersion: 4.3.3 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name DeleteOne_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'DeleteOne with hint string unsupported (server-side error)' - operations: - - - object: *collection0 - name: deleteOne - arguments: - filter: &filter - _id: 1 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - - q: *filter - hint: _id_ - limit: 1 - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - description: 'DeleteOne with hint document unsupported (server-side error)' - operations: - - - object: *collection0 - name: deleteOne - arguments: - filter: *filter - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - - q: *filter - hint: - _id: 1 - limit: 1 - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-unacknowledged.yml deleted file mode 100644 index 4ccbe13d60f..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint-unacknowledged.yml +++ /dev/null @@ -1,89 +0,0 @@ -description: deleteOne-hint-unacknowledged - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - writeConcern: { w: 0 } - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: &documents - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - -tests: - - description: "Unacknowledged deleteOne with hint string fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: deleteOne - arguments: - filter: &filter { _id: { $gt: 1 } } - hint: _id_ - expectError: - isClientError: true - expectEvents: &noEvents - - client: *client0 - events: [] - - - description: "Unacknowledged deleteOne with hint document fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: deleteOne - arguments: - filter: *filter - hint: { _id: 1 } - expectError: - isClientError: true - expectEvents: *noEvents - - - description: "Unacknowledged deleteOne with hint string on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: deleteOne - arguments: - filter: *filter - hint: _id_ - expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } - expectEvents: &events - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - q: *filter - hint: { $$type: [ string, object ]} - limit: 1 - writeConcern: { w: 0 } - - - description: "Unacknowledged deleteOne with hint document on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: deleteOne - arguments: - filter: *filter - hint: { _id: 1 } - expectResult: *unacknowledgedResult - expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint.yml deleted file mode 100644 index ce23b8a9870..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-hint.yml +++ /dev/null @@ -1,92 +0,0 @@ -description: deleteOne-hint -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.3.4 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name DeleteOne_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'DeleteOne with hint string' - operations: - - - object: *collection0 - name: deleteOne - arguments: - filter: &filter - _id: 1 - hint: _id_ - expectResult: &result - deletedCount: 1 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - - q: *filter - hint: _id_ - limit: 1 - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 2 - x: 22 - - - description: 'deleteOne with hint document' - operations: - - - object: *collection0 - name: deleteOne - arguments: - filter: *filter - hint: - _id: 1 - expectResult: *result - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - delete: *collection_name - deletes: - - - q: *filter - hint: - _id: 1 - limit: 1 - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-let.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne-let.yml deleted file mode 100644 index c52d98b99d4..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteOne-let.yml +++ /dev/null @@ -1,91 +0,0 @@ -description: "deleteOne-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - -tests: - - description: "deleteOne with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: deleteOne - object: *collection0 - arguments: - filter: &filter - $expr: - $eq: [ "$_id", "$$id" ] - let: &let0 - id: 1 - expectResult: - deletedCount: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - - q: *filter - limit: 1 - let: *let0 - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 2 } - - - description: "deleteOne with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "3.6.0" - maxServerVersion: "4.4.99" - operations: - - name: deleteOne - object: *collection0 - arguments: - filter: &filter1 - $expr: - $eq: [ "$_id", "$$id" ] - let: &let1 - id: 1 - expectError: - errorContains: "'delete.let' is an unknown field" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - delete: *collection0Name - deletes: - - - q: *filter1 - limit: 1 - let: *let1 - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/deleteOne.yml b/driver-core/src/test/resources/unified-test-format/crud/deleteOne.yml deleted file mode 100644 index 6c7dc951910..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/deleteOne.yml +++ /dev/null @@ -1,76 +0,0 @@ -description: deleteOne - -schemaVersion: '1.0' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - - # This test doesn't verify the output collection because we cannot assume - # which document gets deleted. - description: 'DeleteOne when many documents match' - operations: - - - object: *collection0 - name: deleteOne - arguments: - filter: { _id: { $gt: 1 } } - expectResult: - deletedCount: 1 - - - description: 'DeleteOne when one document matches' - operations: - - - object: *collection0 - name: deleteOne - arguments: - filter: { _id: 2 } - expectResult: - deletedCount: 1 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 3, x: 33 } - - - description: 'DeleteOne when no documents match' - operations: - - - object: *collection0 - name: deleteOne - arguments: - filter: { _id: 4 } - expectResult: - deletedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/distinct-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/distinct-collation.yml deleted file mode 100644 index 74cf1bae35a..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/distinct-collation.yml +++ /dev/null @@ -1,48 +0,0 @@ -description: distinct-collation - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '3.4' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - {_id: 1, string: 'PING'} - - {_id: 2, string: 'ping'} - -tests: - - - description: 'Distinct with a collation' - operations: - - - object: *collection0 - name: distinct - arguments: - fieldName: string - filter: { } - # https://www.mongodb.com/docs/manual/reference/collation/#collation-document - collation: - locale: en_US - strength: 2 - expectResult: - - PING diff --git a/driver-core/src/test/resources/unified-test-format/crud/distinct-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/distinct-comment.yml deleted file mode 100644 index c0820099431..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/distinct-comment.yml +++ /dev/null @@ -1,98 +0,0 @@ -description: "distinct-comment" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name distinct-comment-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: "distinct with document comment" - runOnRequirements: - # https://jira.mongodb.org/browse/SERVER-44847 - # Server supports distinct with comment of any type for comment starting from 4.4.14. - - minServerVersion: "4.4.14" - operations: - - name: distinct - object: *collection0 - arguments: - fieldName: &fieldName x - filter: &filter {} - comment: &documentComment { key: "value"} - expectResult: [ 11, 22, 33 ] - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - distinct: *collection0Name - key: *fieldName - query: *filter - comment: *documentComment - commandName: distinct - databaseName: *database0Name - - - description: "distinct with string comment" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - name: distinct - object: *collection0 - arguments: - fieldName: *fieldName - filter: *filter - comment: &stringComment "comment" - expectResult: [ 11, 22, 33 ] - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - distinct: *collection0Name - key: *fieldName - query: *filter - comment: *stringComment - commandName: distinct - databaseName: *database0Name - - - description: "distinct with document comment - pre 4.4, server error" - runOnRequirements: - - minServerVersion: "3.6.0" - maxServerVersion: "4.4.13" - operations: - - name: distinct - object: *collection0 - arguments: - fieldName: *fieldName - filter: *filter - comment: *documentComment - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - distinct: *collection0Name - key: *fieldName - query: *filter - comment: *documentComment - commandName: distinct - databaseName: *database0Name diff --git a/driver-core/src/test/resources/unified-test-format/crud/distinct.yml b/driver-core/src/test/resources/unified-test-format/crud/distinct.yml deleted file mode 100644 index c554a7671b4..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/distinct.yml +++ /dev/null @@ -1,54 +0,0 @@ -description: distinct - -schemaVersion: '1.0' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - - description: 'Distinct without a filter' - operations: - - - object: *collection0 - name: distinct - arguments: - fieldName: x - filter: { } - expectResult: - - 11 - - 22 - - 33 - - - description: 'Distinct with a filter' - operations: - - - object: *collection0 - name: distinct - arguments: - fieldName: x - filter: { _id: { $gt: 1 } } - expectResult: - - 22 - - 33 diff --git a/driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount-comment.yml deleted file mode 100644 index b7853151048..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount-comment.yml +++ /dev/null @@ -1,95 +0,0 @@ -description: "estimatedDocumentCount-comment" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name edc-comment-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: "estimatedDocumentCount with document comment" - runOnRequirements: - # https://jira.mongodb.org/browse/SERVER-63315 - # Server supports count with comment of any type for comment starting from 4.4.14. - - minServerVersion: "4.4.14" - operations: - - name: estimatedDocumentCount - object: *collection0 - arguments: - comment: &documentComment { key: "value"} - expectResult: 3 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - count: *collection0Name - comment: *documentComment - commandName: count - databaseName: *database0Name - - - description: "estimatedDocumentCount with string comment" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - name: estimatedDocumentCount - object: *collection0 - arguments: - comment: &stringComment "comment" - expectResult: 3 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - count: *collection0Name - comment: *stringComment - commandName: count - databaseName: *database0Name - - - description: "estimatedDocumentCount with document comment - pre 4.4.14, server error" - runOnRequirements: - - minServerVersion: "3.6.0" - maxServerVersion: "4.4.13" - # Server does not raise an error if topology is sharded. - # https://jira.mongodb.org/browse/SERVER-65954 - topologies: [ single, replicaset ] - operations: - - name: estimatedDocumentCount - object: *collection0 - arguments: - # Even though according to the docs count command does not support any - # comment for server version less than 4.4, no error is raised by such - # servers. Therefore, we have only one test with a document comment - # to test server errors. - # https://jira.mongodb.org/browse/SERVER-63315 - # Server supports count with comment of any type for comment starting from 4.4.14. - comment: *documentComment - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - count: *collection0Name - comment: *documentComment - commandName: count - databaseName: *database0Name diff --git a/driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount.yml b/driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount.yml deleted file mode 100644 index 12f33cc7e51..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/estimatedDocumentCount.yml +++ /dev/null @@ -1,181 +0,0 @@ -description: "estimatedDocumentCount" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - useMultipleMongoses: false # Avoid setting fail points with multiple mongoses - uriOptions: { retryReads: false } # Avoid retrying fail points with closeConnection - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name edc-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - - collection: - # Nonexistent collection intentionally omitted from initialData - id: &collection1 collection1 - database: *database0 - collectionName: &collection1Name coll1 - - collection: - id: &collection0View collection0View - database: *database0 - collectionName: &collection0ViewName coll0view - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: "estimatedDocumentCount always uses count" - operations: - - name: estimatedDocumentCount - object: *collection0 - expectResult: 3 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - count: *collection0Name - commandName: count - databaseName: *database0Name - - - description: "estimatedDocumentCount with maxTimeMS" - operations: - - name: estimatedDocumentCount - object: *collection0 - arguments: - maxTimeMS: 6000 - expectResult: 3 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - count: *collection0Name - maxTimeMS: 6000 - commandName: count - databaseName: *database0Name - - - description: "estimatedDocumentCount on non-existent collection" - operations: - - name: estimatedDocumentCount - object: *collection1 - expectResult: 0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - count: *collection1Name - commandName: count - databaseName: *database0Name - - - description: "estimatedDocumentCount errors correctly--command error" - runOnRequirements: - - minServerVersion: "4.0.0" - topologies: [ single, replicaset ] - - minServerVersion: "4.2.0" - topologies: [ sharded ] - operations: - - name: failPoint - object: testRunner - arguments: - client: *client0 - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: [ count ] - errorCode: 8 # UnknownError - - name: estimatedDocumentCount - object: *collection0 - expectError: - errorCode: 8 # UnknownError - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - count: *collection0Name - commandName: count - databaseName: *database0Name - - - description: "estimatedDocumentCount errors correctly--socket error" - runOnRequirements: - - minServerVersion: "4.0.0" - topologies: [ single, replicaset ] - - minServerVersion: "4.2.0" - topologies: [ sharded ] - operations: - - name: failPoint - object: testRunner - arguments: - client: *client0 - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: [ count ] - closeConnection: true - - name: estimatedDocumentCount - object: *collection0 - expectError: - isError: true - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - count: *collection0Name - commandName: count - databaseName: *database0Name - - - description: "estimatedDocumentCount works correctly on views" - # viewOn option was added to the create command in 3.4 - runOnRequirements: - - minServerVersion: "3.4.0" - operations: - - name: dropCollection - object: *database0 - arguments: - collection: *collection0ViewName - - name: createCollection - object: *database0 - arguments: - collection: *collection0ViewName - viewOn: *collection0Name - pipeline: &pipeline - - { $match: { _id: { $gt: 1 } } } - - name: estimatedDocumentCount - object: *collection0View - expectResult: 2 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - drop: *collection0ViewName - commandName: drop - databaseName: *database0Name - - commandStartedEvent: - command: - create: *collection0ViewName - viewOn: *collection0Name - pipeline: *pipeline - commandName: create - databaseName: *database0Name - - commandStartedEvent: - command: - count: *collection0ViewName - commandName: count - databaseName: *database0Name diff --git a/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-clientError.yml deleted file mode 100644 index da7f6365f1f..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-clientError.yml +++ /dev/null @@ -1,52 +0,0 @@ -description: find-allowdiskuse-clientError -schemaVersion: '1.0' -runOnRequirements: - - - maxServerVersion: 3.0.99 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_find_allowdiskuse_clienterror -tests: - - - description: 'Find fails when allowDiskUse true is specified against pre 3.2 server' - operations: - - - object: *collection0 - name: find - arguments: - filter: { } - allowDiskUse: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - - - description: 'Find fails when allowDiskUse false is specified against pre 3.2 server' - operations: - - - object: *collection0 - name: find - arguments: - filter: { } - allowDiskUse: false - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] diff --git a/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-serverError.yml deleted file mode 100644 index 86f48d18e58..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse-serverError.yml +++ /dev/null @@ -1,65 +0,0 @@ -description: find-allowdiskuse-serverError -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: '3.2' - maxServerVersion: 4.3.0 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_find_allowdiskuse_servererror -tests: - - - description: 'Find fails when allowDiskUse true is specified against pre 4.4 server (server-side error)' - operations: - - - object: *collection0 - name: find - arguments: - filter: &filter { } - allowDiskUse: true - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - find: *collection_name - filter: *filter - allowDiskUse: true - - - description: 'Find fails when allowDiskUse false is specified against pre 4.4 server (server-side error)' - operations: - - - object: *collection0 - name: find - arguments: - filter: *filter - allowDiskUse: false - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - find: *collection_name - filter: *filter - allowDiskUse: false diff --git a/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse.yml b/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse.yml deleted file mode 100644 index 2f4190b9c31..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/find-allowdiskuse.yml +++ /dev/null @@ -1,76 +0,0 @@ -description: find-allowdiskuse -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.3.1 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_find_allowdiskuse -tests: - - - description: 'Find does not send allowDiskUse when value is not specified' - operations: - - - object: *collection0 - name: find - arguments: - filter: { } - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - find: *collection_name - allowDiskUse: - $$exists: false - - - description: 'Find sends allowDiskUse false when false is specified' - operations: - - - object: *collection0 - name: find - arguments: - filter: { } - allowDiskUse: false - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - find: *collection_name - allowDiskUse: false - - - description: 'Find sends allowDiskUse true when true is specified' - operations: - - - object: *collection0 - name: find - arguments: - filter: { } - allowDiskUse: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - find: *collection_name - allowDiskUse: true diff --git a/driver-core/src/test/resources/unified-test-format/crud/find-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/find-collation.yml deleted file mode 100644 index 9810b609708..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/find-collation.yml +++ /dev/null @@ -1,46 +0,0 @@ -description: find-collation - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '3.4' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: ping } - -tests: - - - description: 'Find with a collation' - operations: - - - object: *collection0 - name: find - arguments: - filter: { x: PING } - # https://www.mongodb.com/docs/manual/reference/collation/#collation-document - collation: - locale: en_US - strength: 2 - expectResult: - - { _id: 1, x: ping } diff --git a/driver-core/src/test/resources/unified-test-format/crud/find-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/find-comment.yml deleted file mode 100644 index 905241ad0e9..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/find-comment.yml +++ /dev/null @@ -1,166 +0,0 @@ -description: "find-comment" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - { _id: 5, x: 55 } - - { _id: 6, x: 66 } - -tests: - - description: "find with string comment" - runOnRequirements: - - minServerVersion: "3.6" - operations: - - name: find - object: *collection0 - arguments: - filter: &filter - _id: 1 - comment: "comment" - expectResult: &expect_result - - { _id: 1 } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - find: *collection0Name - filter: *filter - comment: "comment" - - - description: "find with document comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: find - object: *collection0 - arguments: - filter: *filter - comment: &comment { key: "value"} - expectResult: *expect_result - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - find: *collection0Name - filter: *filter - comment: *comment - - - description: "find with document comment - pre 4.4" - runOnRequirements: - - maxServerVersion: "4.2.99" - minServerVersion: "3.6" - operations: - - name: find - object: *collection0 - arguments: - filter: *filter - comment: *comment - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - find: *collection0Name - filter: *filter - comment: *comment - - - description: "find with comment sets comment on getMore" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - name: find - object: *collection0 - arguments: - filter: &filter_get_more { _id: { $gt: 1 } } - batchSize: 2 - comment: *comment - expectResult: - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - { _id: 5, x: 55 } - - { _id: 6, x: 66 } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - find: *collection0Name - filter: { _id: { $gt: 1 } } - batchSize: 2 - comment: *comment - - commandStartedEvent: - command: - getMore: { $$type: [ int, long ] } - collection: *collection0Name - batchSize: 2 - comment: *comment - - commandStartedEvent: - command: - getMore: { $$type: [ int, long ] } - collection: *collection0Name - batchSize: 2 - comment: *comment - - - description: "find with comment does not set comment on getMore - pre 4.4" - runOnRequirements: - - minServerVersion: "3.6.0" - maxServerVersion: "4.3.99" - operations: - - name: find - object: *collection0 - arguments: - filter: &filter_get_more { _id: { $gt: 1 } } - batchSize: 2 - comment: "comment" - expectResult: - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - { _id: 5, x: 55 } - - { _id: 6, x: 66 } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - find: *collection0Name - filter: { _id: { $gt: 1 } } - batchSize: 2 - comment: "comment" - - commandStartedEvent: - command: - getMore: { $$type: [ int, long ] } - collection: *collection0Name - batchSize: 2 - comment: { $$exists: false } - - commandStartedEvent: - command: - getMore: { $$type: [ int, long ] } - collection: *collection0Name - batchSize: 2 - comment: { $$exists: false } diff --git a/driver-core/src/test/resources/unified-test-format/crud/find-let.yml b/driver-core/src/test/resources/unified-test-format/crud/find-let.yml deleted file mode 100644 index 20afe85c879..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/find-let.yml +++ /dev/null @@ -1,71 +0,0 @@ -description: "find-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - -tests: - - description: "Find with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: find - object: *collection0 - arguments: - filter: &filter - $expr: - $eq: [ "$_id", "$$id" ] - let: &let0 - id: 1 - expectResult: - - { _id: 1 } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - find: *collection0Name - filter: *filter - let: *let0 - - - description: "Find with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "3.6.0" - maxServerVersion: "4.4.99" - operations: - - name: find - object: *collection0 - arguments: - filter: &filter1 - _id: 1 - let: &let1 - x: 1 - expectError: - errorContains: "Unrecognized field 'let'" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - find: *collection0Name - filter: *filter1 - let: *let1 diff --git a/driver-core/src/test/resources/unified-test-format/crud/find.yml b/driver-core/src/test/resources/unified-test-format/crud/find.yml deleted file mode 100644 index 76676900fad..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/find.yml +++ /dev/null @@ -1,107 +0,0 @@ -description: "find" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - useMultipleMongoses: true # ensure cursors pin to a single server - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name find-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - { _id: 5, x: 55 } - - { _id: 6, x: 66 } - -tests: - - description: "find with multiple batches works" - operations: - - name: find - arguments: - filter: { _id: { $gt: 1 } } - batchSize: 2 - object: *collection0 - expectResult: - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - { _id: 5, x: 55 } - - { _id: 6, x: 66 } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - find: *collection0Name - filter: { _id: { $gt: 1 } } - batchSize: 2 - commandName: find - databaseName: *database0Name - - commandStartedEvent: - command: - getMore: { $$type: [ int, long ] } - collection: *collection0Name - batchSize: 2 - commandName: getMore - databaseName: *database0Name - - commandStartedEvent: - command: - getMore: { $$type: [ int, long ] } - collection: *collection0Name - batchSize: 2 - commandName: getMore - databaseName: *database0Name - - - description: 'Find with filter' - operations: - - - object: *collection0 - name: find - arguments: - filter: { _id: 1 } - expectResult: - - { _id: 1, x: 11 } - - - description: 'Find with filter, sort, skip, and limit' - operations: - - - object: *collection0 - name: find - arguments: - filter: { _id: { $gt: 2 } } - sort: { _id: 1 } - skip: 2 - limit: 2 - expectResult: - - { _id: 5, x: 55 } - - { _id: 6, x: 66 } - - - description: 'Find with limit, sort, and batchsize' - operations: - - - object: *collection0 - name: find - arguments: - filter: { } - sort: { _id: 1 } - limit: 4 - batchSize: 2 - expectResult: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-collation.yml deleted file mode 100644 index 2e6de9b08ef..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-collation.yml +++ /dev/null @@ -1,56 +0,0 @@ -description: findOneAndDelete-collation - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '3.4' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: ping } - - { _id: 3, x: pINg } - -tests: - - - description: 'FindOneAndDelete when one document matches with collation' - operations: - - - object: *collection0 - name: findOneAndDelete - arguments: - filter: { _id: 2, x: PING } - projection: { x: 1, _id: 0 } - sort: { x: 1 } - # https://www.mongodb.com/docs/manual/reference/collation/#collation-document - collation: - locale: en_US - strength: 2 - expectResult: { x: ping } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 3, x: pINg } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-comment.yml deleted file mode 100644 index dfa7ff2ce0a..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-comment.yml +++ /dev/null @@ -1,96 +0,0 @@ -description: "findOneAndDelete-comment" -schemaVersion: "1.0" - - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - -tests: - - description: "findOneAndDelete with string comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: findOneAndDelete - object: *collection0 - arguments: - filter: &filter - _id: 1 - comment: "comment" - expectResult: - _id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - remove: true - comment: "comment" - outcome: &outcome - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 2 } - - - description: "findOneAndDelete with document comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: findOneAndDelete - object: *collection0 - arguments: - filter: *filter - comment: &comment { key: "value"} - expectResult: - _id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - remove: true - comment: *comment - outcome: *outcome - - - description: "findOneAndDelete with comment - pre 4.4" - runOnRequirements: - - minServerVersion: "4.2.0" # findAndModify option validation was introduced in 4.2 - maxServerVersion: "4.2.99" - operations: - - name: findOneAndDelete - object: *collection0 - arguments: - filter: *filter - comment: "comment" - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - remove: true - comment: "comment" - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-clientError.yml deleted file mode 100644 index 46c7521ad8c..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-clientError.yml +++ /dev/null @@ -1,88 +0,0 @@ -description: findOneAndDelete-hint-clientError -schemaVersion: '1.0' -runOnRequirements: - - - maxServerVersion: 4.0.99 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name findOneAndDelete_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'FindOneAndDelete with hint string unsupported (client-side error)' - operations: - - - object: *collection0 - name: findOneAndDelete - arguments: - filter: &filter - _id: 1 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - description: 'FindOneAndDelete with hint document' - operations: - - - object: *collection0 - name: findOneAndDelete - arguments: - filter: &filter - _id: 1 - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-serverError.yml deleted file mode 100644 index db75131545f..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-serverError.yml +++ /dev/null @@ -1,104 +0,0 @@ -description: findOneAndDelete-hint-serverError -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.2.0 - maxServerVersion: 4.3.3 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name findOneAndDelete_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'FindOneAndDelete with hint string unsupported (server-side error)' - operations: - - - object: *collection0 - name: findOneAndDelete - arguments: - filter: &filter - _id: 1 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - findAndModify: *collection_name - query: *filter - hint: _id_ - remove: true - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - description: 'FindOneAndDelete with hint document unsupported (server-side error)' - operations: - - - object: *collection0 - name: findOneAndDelete - arguments: - filter: &filter - _id: 1 - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - findAndModify: *collection_name - query: *filter - hint: - _id: 1 - remove: true - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-unacknowledged.yml deleted file mode 100644 index 2b29a4923ea..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint-unacknowledged.yml +++ /dev/null @@ -1,88 +0,0 @@ -description: findOneAndDelete-hint-unacknowledged - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - writeConcern: { w: 0 } - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: &documents - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - -tests: - - description: "Unacknowledged findOneAndDelete with hint string fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: findOneAndDelete - arguments: - filter: &filter { _id: { $gt: 1 } } - hint: _id_ - expectError: - isClientError: true - expectEvents: &noEvents - - client: *client0 - events: [] - - - description: "Unacknowledged findOneAndDelete with hint document fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: findOneAndDelete - arguments: - filter: *filter - hint: { _id: 1 } - expectError: - isClientError: true - expectEvents: *noEvents - - - description: "Unacknowledged findOneAndDelete with hint string on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: findOneAndDelete - arguments: - filter: *filter - hint: _id_ - expectResult: &unacknowledgedResult { $$unsetOrMatches: null } - expectEvents: &events - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - remove: true - hint: { $$type: [ string, object ]} - writeConcern: { w: 0 } - - - description: "Unacknowledged findOneAndDelete with hint document on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: findOneAndDelete - arguments: - filter: *filter - hint: { _id: 1 } - expectResult: *unacknowledgedResult - expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint.yml deleted file mode 100644 index 90907798310..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-hint.yml +++ /dev/null @@ -1,99 +0,0 @@ -description: findOneAndDelete-hint -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.3.4 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name findOneAndDelete_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'FindOneAndDelete with hint string' - operations: - - - object: *collection0 - name: findOneAndDelete - arguments: - filter: &filter - _id: 1 - hint: _id_ - expectResult: &result - _id: 1 - x: 11 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - findAndModify: *collection_name - query: *filter - hint: _id_ - remove: true - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 2 - x: 22 - - - description: 'FindOneAndDelete with hint document' - operations: - - - object: *collection0 - name: findOneAndDelete - arguments: - filter: &filter - _id: 1 - hint: - _id: 1 - expectResult: &result - _id: 1 - x: 11 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - findAndModify: *collection_name - query: *filter - hint: - _id: 1 - remove: true - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 2 - x: 22 diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-let.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-let.yml deleted file mode 100644 index 0174af0a2b3..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete-let.yml +++ /dev/null @@ -1,86 +0,0 @@ -description: "findOneAndDelete-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - -tests: - - description: "findOneAndDelete with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: findOneAndDelete - object: *collection0 - arguments: - filter: &filter - $expr: - $eq: [ "$_id", "$$id" ] - let: &let0 - id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - remove: true - let: *let0 - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 2 } - - - description: "findOneAndDelete with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "4.2.0" - maxServerVersion: "4.4.99" - operations: - - name: findOneAndDelete - object: *collection0 - arguments: - filter: &filter1 - $expr: - $eq: [ "$_id", "$$id" ] - let: &let1 - id: 1 - expectError: - # This error message is consistent between 4.2.x and 4.4.x servers. - # Older servers return a different error message. - errorContains: "field 'let' is an unknown field" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter1 - remove: true - let: *let1 - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete.yml deleted file mode 100644 index 6bb3a1ccca1..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndDelete.yml +++ /dev/null @@ -1,84 +0,0 @@ -description: findOneAndDelete - -schemaVersion: '1.0' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - - description: 'FindOneAndDelete when many documents match' - operations: - - - object: *collection0 - name: findOneAndDelete - arguments: - filter: { _id: { $gt: 1 } } - projection: { x: 1, _id: 0 } - sort: { x: 1 } - expectResult: { x: 22 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 3, x: 33 } - - - description: 'FindOneAndDelete when one document matches' - operations: - - - object: *collection0 - name: findOneAndDelete - arguments: - filter: { _id: 2 } - projection: { x: 1, _id: 0 } - sort: { x: 1 } - expectResult: { x: 22 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 3, x: 33 } - - - description: 'FindOneAndDelete when no documents match' - operations: - - - object: *collection0 - name: findOneAndDelete - arguments: - filter: { _id: 4 } - projection: { x: 1, _id: 0 } - sort: { x: 1 } - expectResult: null - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-collation.yml deleted file mode 100644 index c3d8a8e78fc..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-collation.yml +++ /dev/null @@ -1,57 +0,0 @@ -description: findOneAndReplace-collation - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '3.4' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: ping } - -tests: - - - description: 'FindOneAndReplace when one document matches with collation returning the document after modification' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: { x: PING } - replacement: { x: pong } - projection: { x: 1, _id: 0 } - returnDocument: After - sort: { x: 1 } - # https://www.mongodb.com/docs/manual/reference/collation/#collation-document - collation: - locale: en_US - strength: 2 - expectResult: { x: pong } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: pong } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-comment.yml deleted file mode 100644 index 2c6aaef07ba..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-comment.yml +++ /dev/null @@ -1,101 +0,0 @@ -description: "findOneAndReplace-comment" -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - -tests: - - description: "findOneAndReplace with string comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: findOneAndReplace - object: *collection0 - arguments: - filter: &filter - _id: 1 - replacement: &replacement - x: 5 - comment: "comment" - expectResult: - _id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - update: *replacement - comment: "comment" - outcome: &outcome - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 5 } - - { _id: 2 } - - - description: "findOneAndReplace with document comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: findOneAndReplace - object: *collection0 - arguments: - filter: *filter - replacement: *replacement - comment: &comment { key: "value"} - expectResult: - _id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - update: *replacement - comment: *comment - outcome: *outcome - - - - description: "findOneAndReplace with comment - pre 4.4" - runOnRequirements: - - minServerVersion: "4.2.0" # findAndModify option validation was introduced in 4.2 - maxServerVersion: "4.2.99" - operations: - - name: findOneAndReplace - object: *collection0 - arguments: - filter: *filter - replacement: *replacement - comment: "comment" - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - update: *replacement - comment: "comment" - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-dots_and_dollars.yml deleted file mode 100644 index 0823824cca6..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-dots_and_dollars.yml +++ /dev/null @@ -1,140 +0,0 @@ -description: "findOneAndReplace-dots_and_dollars" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - &initialDocument { _id: 1 } - -tests: - - description: "Replacing document with top-level dotted key on 3.6+ server" - runOnRequirements: - - minServerVersion: "3.6" - operations: - - name: findOneAndReplace - object: *collection0 - arguments: - filter: { _id: 1 } - replacement: &dottedKey { _id: 1, a.b: 1 } - expectResult: *initialDocument - expectEvents: &expectEventsDottedKey - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: { _id: 1 } - update: *dottedKey - new: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dottedKey - - - description: "Replacing document with top-level dotted key on pre-3.6 server yields server-side error" - runOnRequirements: - - maxServerVersion: "3.4.99" - operations: - - name: findOneAndReplace - object: *collection0 - arguments: - filter: { _id: 1 } - replacement: *dottedKey - expectError: - isClientError: false - expectEvents: *expectEventsDottedKey - outcome: *initialData - - - description: "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: findOneAndReplace - object: *collection0 - arguments: - filter: { _id: 1 } - replacement: &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } } - expectResult: *initialDocument - expectEvents: &expectEventsDollarPrefixedKeyInEmbedded - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: { _id: 1 } - update: *dollarPrefixedKeyInEmbedded - new: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dollarPrefixedKeyInEmbedded - - - description: "Replacing document with dollar-prefixed key in embedded doc on pre-5.0 server yields server-side error" - runOnRequirements: - - maxServerVersion: "4.99" - operations: - - name: findOneAndReplace - object: *collection0 - arguments: - filter: { _id: 1 } - replacement: *dollarPrefixedKeyInEmbedded - expectError: - isClientError: false - expectEvents: *expectEventsDollarPrefixedKeyInEmbedded - outcome: *initialData - - - description: "Replacing document with dotted key in embedded doc on 3.6+ server" - runOnRequirements: - - minServerVersion: "3.6" - operations: - - name: findOneAndReplace - object: *collection0 - arguments: - filter: { _id: 1 } - replacement: &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } } - expectResult: *initialDocument - expectEvents: &expectEventsDottedKeyInEmbedded - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: { _id: 1 } - update: *dottedKeyInEmbedded - new: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dottedKeyInEmbedded - - - description: "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error" - runOnRequirements: - - maxServerVersion: "3.4.99" - operations: - - name: findOneAndReplace - object: *collection0 - arguments: - filter: { _id: 1 } - replacement: *dottedKeyInEmbedded - expectError: - isClientError: false - expectEvents: *expectEventsDottedKeyInEmbedded - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-clientError.yml deleted file mode 100644 index a0a8f94beba..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-clientError.yml +++ /dev/null @@ -1,80 +0,0 @@ -description: findOneAndReplace-hint-clientError -schemaVersion: '1.0' -runOnRequirements: - - - maxServerVersion: 4.0.99 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name findOneAndReplace_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'FindOneAndReplace with hint string unsupported (client-side error)' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: &filter - _id: 1 - replacement: &replacement - x: 33 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - description: 'FindOneAndReplace with hint document unsupported (client-side error)' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: *filter - replacement: *replacement - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-serverError.yml deleted file mode 100644 index 1fea6f364b2..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-serverError.yml +++ /dev/null @@ -1,96 +0,0 @@ -description: findOneAndReplace-hint-serverError -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.2.0 - maxServerVersion: 4.3.0 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name findOneAndReplace_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'FindOneAndReplace with hint string unsupported (server-side error)' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: &filter - _id: 1 - replacement: &replacement - x: 33 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - findAndModify: *collection_name - query: *filter - update: *replacement - hint: _id_ - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - description: 'FindOneAndReplace with hint document unsupported (server-side error)' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: *filter - replacement: *replacement - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - findAndModify: *collection_name - query: *filter - update: *replacement - hint: - _id: 1 - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-unacknowledged.yml deleted file mode 100644 index 20a2737de24..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint-unacknowledged.yml +++ /dev/null @@ -1,96 +0,0 @@ -description: findOneAndReplace-hint-unacknowledged - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - writeConcern: { w: 0 } - - collection: - id: &collection1 collection1 - database: *database0 - collectionName: *collection0Name - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: &documents - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - -tests: - - description: "Unacknowledged findOneAndReplace with hint string fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: findOneAndReplace - arguments: - filter: &filter { _id: { $gt: 1 } } - replacement: &replacement { x: 111 } - hint: _id_ - expectError: - isClientError: true - expectEvents: &noEvents - - client: *client0 - events: [] - - - description: "Unacknowledged findOneAndReplace with hint document fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: findOneAndReplace - arguments: - filter: *filter - replacement: *replacement - hint: { _id: 1 } - expectError: - isClientError: true - expectEvents: *noEvents - - - description: "Unacknowledged findOneAndReplace with hint string on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: findOneAndReplace - arguments: - filter: *filter - replacement: *replacement - hint: _id_ - expectResult: &unacknowledgedResult { $$unsetOrMatches: null } - expectEvents: &events - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - update: *replacement - hint: { $$type: [ string, object ]} - writeConcern: { w: 0 } - - - description: "Unacknowledged findOneAndReplace with hint document on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: findOneAndReplace - arguments: - filter: *filter - replacement: *replacement - hint: { _id: 1 } - expectResult: *unacknowledgedResult - expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint.yml deleted file mode 100644 index 67fbf2cb2bf..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-hint.yml +++ /dev/null @@ -1,95 +0,0 @@ -description: findOneAndReplace-hint -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.3.1 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name findOneAndReplace_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'FindOneAndReplace with hint string' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: &filter - _id: 1 - replacement: &replacement - x: 33 - hint: _id_ - expectResult: &result - _id: 1 - x: 11 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - findAndModify: *collection_name - query: *filter - update: *replacement - hint: _id_ - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 33 - - - _id: 2 - x: 22 - - - description: 'FindOneAndReplace with hint document' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: *filter - replacement: *replacement - hint: - _id: 1 - expectResult: *result - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - findAndModify: *collection_name - query: *filter - update: *replacement - hint: - _id: 1 - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-let.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-let.yml deleted file mode 100644 index 3ee1b7b672f..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-let.yml +++ /dev/null @@ -1,94 +0,0 @@ -description: "findOneAndReplace-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - -tests: - - description: "findOneAndReplace with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: findOneAndReplace - object: *collection0 - arguments: - filter: &filter - $expr: - $eq: [ "$_id", "$$id" ] - replacement: &replacement - x: "x" - let: &let0 - id: 1 - expectResult: - _id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - update: *replacement - let: *let0 - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: "x" } - - { _id: 2 } - - - description: "findOneAndReplace with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "4.2.0" - maxServerVersion: "4.4.99" - operations: - - name: findOneAndReplace - object: *collection0 - arguments: - filter: &filter1 - $expr: - $eq: [ "$_id", "$$id" ] - replacement: &replacement1 - x: "x" - let: &let1 - id: 1 - expectError: - # This error message is consistent between 4.2.x and 4.4.x servers. - # Older servers return a different error message. - errorContains: "field 'let' is an unknown field" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter1 - update: *replacement1 - let: *let1 - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-upsert.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-upsert.yml deleted file mode 100644 index c52fdf11b17..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace-upsert.yml +++ /dev/null @@ -1,127 +0,0 @@ -description: findOneAndReplace-upsert - -schemaVersion: '1.0' - -runOnRequirements: - - - minServerVersion: '2.6' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - - description: 'FindOneAndReplace when no documents match without id specified with upsert returning the document before modification' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: { _id: 4 } - replacement: { x: 44 } - projection: { x: 1, _id: 0 } - # Omit the sort option as it has no effect when no documents match and - # would only cause an inconsistent return value on pre-3.0 servers - # when combined with returnDocument "before" (see: SERVER-17650). - upsert: true - expectResult: null - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - - description: 'FindOneAndReplace when no documents match without id specified with upsert returning the document after modification' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: { _id: 4 } - replacement: { x: 44 } - projection: { x: 1, _id: 0 } - returnDocument: After - sort: { x: 1 } - upsert: true - expectResult: { x: 44 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - - description: 'FindOneAndReplace when no documents match with id specified with upsert returning the document before modification' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: { _id: 4 } - replacement: { _id: 4, x: 44 } - projection: { x: 1, _id: 0 } - # Omit the sort option as it has no effect when no documents match and - # would only cause an inconsistent return value on pre-3.0 servers - # when combined with returnDocument "before" (see: SERVER-17650). - upsert: true - expectResult: null - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } - - - description: 'FindOneAndReplace when no documents match with id specified with upsert returning the document after modification' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: { _id: 4 } - replacement: { _id: 4, x: 44 } - projection: { x: 1, _id: 0 } - returnDocument: After - sort: { x: 1 } - upsert: true - expectResult: { x: 44 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 44 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace.yml deleted file mode 100644 index ddfd533558d..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndReplace.yml +++ /dev/null @@ -1,152 +0,0 @@ -description: findOneAndReplace - -schemaVersion: '1.0' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - - description: 'FindOneAndReplace when many documents match returning the document before modification' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: { _id: { $gt: 1 } } - replacement: { x: 32 } - projection: { x: 1, _id: 0 } - sort: { x: 1 } - expectResult: { x: 22 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 32 } - - { _id: 3, x: 33 } - - - description: 'FindOneAndReplace when many documents match returning the document after modification' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: { _id: { $gt: 1 } } - replacement: { x: 32 } - projection: { x: 1, _id: 0 } - returnDocument: After - sort: { x: 1 } - expectResult: { x: 32 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 32 } - - { _id: 3, x: 33 } - - - description: 'FindOneAndReplace when one document matches returning the document before modification' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: { _id: 2 } - replacement: { x: 32 } - projection: { x: 1, _id: 0 } - sort: { x: 1 } - expectResult: { x: 22 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 32 } - - { _id: 3, x: 33 } - - - description: 'FindOneAndReplace when one document matches returning the document after modification' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: { _id: 2 } - replacement: { x: 32 } - projection: { x: 1, _id: 0 } - returnDocument: After - sort: { x: 1 } - expectResult: { x: 32 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 32 } - - { _id: 3, x: 33 } - - - description: 'FindOneAndReplace when no documents match returning the document before modification' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: { _id: 4 } - replacement: { x: 44 } - projection: { x: 1, _id: 0 } - sort: { x: 1 } - expectResult: null - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - - description: 'FindOneAndReplace when no documents match returning the document after modification' - operations: - - - object: *collection0 - name: findOneAndReplace - arguments: - filter: { _id: 4 } - replacement: { x: 44 } - projection: { x: 1, _id: 0 } - returnDocument: After - sort: { x: 1 } - expectResult: null - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-arrayFilters.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-arrayFilters.yml deleted file mode 100644 index 42e392c2c5c..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-arrayFilters.yml +++ /dev/null @@ -1,89 +0,0 @@ -description: findOneAndUpdate-arrayFilters - -schemaVersion: '1.0' - -runOnRequirements: - - - minServerVersion: 3.5.6 - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } - -tests: - - - description: 'FindOneAndUpdate when no document matches arrayFilters' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: { } - update: { $set: { 'y.$[i].b': 2 } } - arrayFilters: - - { i.b: 4 } - expectResult: { _id: 1, y: [ { b: 3 }, { b: 1 } ] } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } - - - description: 'FindOneAndUpdate when one document matches arrayFilters' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: { } - update: { $set: { 'y.$[i].b': 2 } } - arrayFilters: - - { i.b: 3 } - expectResult: { _id: 1, y: [ { b: 3 }, { b: 1 } ] } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 2 }, { b: 1 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } - - - description: 'FindOneAndUpdate when multiple documents match arrayFilters' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: { } - update: { $set: { 'y.$[i].b': 2 } } - arrayFilters: - - { i.b: 1 } - expectResult: { _id: 1, y: [ { b: 3 }, { b: 1 } ] } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 3 }, { b: 2 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-collation.yml deleted file mode 100644 index 8b2048bc82c..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-collation.yml +++ /dev/null @@ -1,58 +0,0 @@ -description: findOneAndUpdate-collation - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '3.4' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: ping } - - { _id: 3, x: pINg } - -tests: - - - description: 'FindOneAndUpdate when many documents match with collation returning the document before modification' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: { x: PING } - update: { $set: { x: pong } } - projection: { x: 1, _id: 0 } - sort: { _id: 1 } - # https://www.mongodb.com/docs/manual/reference/collation/#collation-document - collation: - locale: en_US - strength: 2 - expectResult: { x: ping } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: pong } - - { _id: 3, x: pINg } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-comment.yml deleted file mode 100644 index 66d2d099c1d..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-comment.yml +++ /dev/null @@ -1,95 +0,0 @@ -description: "findOneAndUpdate-comment" -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - -tests: - - description: "findOneAndUpdate with string comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: findOneAndUpdate - object: *collection0 - arguments: - filter: &filter - _id: 1 - update: &update - - $set: {x: 5 } - comment: "comment" - expectResult: - _id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - update: *update - comment: "comment" - - - description: "findOneAndUpdate with document comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: findOneAndUpdate - object: *collection0 - arguments: - filter: &filter - _id: 1 - update: &update - - $set: {x: 5 } - comment: &comment { key: "value"} - expectResult: - _id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - update: *update - comment: *comment - - - description: "findOneAndUpdate with comment - pre 4.4" - runOnRequirements: - - minServerVersion: "4.2.0" # findAndModify option validation was introduced in 4.2 - maxServerVersion: "4.2.99" - operations: - - name: findOneAndUpdate - object: *collection0 - arguments: - filter: *filter - update: *update - comment: "comment" - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - update: *update - comment: "comment" - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-dots_and_dollars.yml deleted file mode 100644 index 69b46a15bc3..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-dots_and_dollars.yml +++ /dev/null @@ -1,127 +0,0 @@ -description: "findOneAndUpdate-dots_and_dollars" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - &initialDocument { _id: 1, foo: {} } - -tests: - - description: "Updating document to set top-level dollar-prefixed key on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: findOneAndUpdate - object: *collection0 - arguments: - filter: { _id: 1 } - update: &dollarPrefixedKey - - { $replaceWith: { $setField: { field: { $literal: $a }, value: 1, input: $$ROOT } } } - expectResult: *initialDocument - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: { _id: 1 } - update: *dollarPrefixedKey - new: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {}, $a: 1 } - - - description: "Updating document to set top-level dotted key on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: findOneAndUpdate - object: *collection0 - arguments: - filter: { _id: 1 } - update: &dottedKey - - { $replaceWith: { $setField: { field: { $literal: a.b }, value: 1, input: $$ROOT } } } - expectResult: *initialDocument - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: { _id: 1 } - update: *dottedKey - new: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {}, a.b: 1 } - - - description: "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: findOneAndUpdate - object: *collection0 - arguments: - filter: { _id: 1 } - update: &dollarPrefixedKeyInEmbedded - - { $set: { foo: { $setField: { field: { $literal: $a }, value: 1, input: $foo } } } } - expectResult: *initialDocument - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: { _id: 1 } - update: *dollarPrefixedKeyInEmbedded - new: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: { $a: 1 } } - - - description: "Updating document to set dotted key in embedded doc on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: findOneAndUpdate - object: *collection0 - arguments: - filter: { _id: 1 } - update: &dottedKeyInEmbedded - - { $set: { foo: { $setField: { field: { $literal: a.b }, value: 1, input: $foo } } } } - expectResult: *initialDocument - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: { _id: 1 } - update: *dottedKeyInEmbedded - new: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: { a.b: 1 } } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-errorResponse.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-errorResponse.yml deleted file mode 100644 index 8faed768097..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-errorResponse.yml +++ /dev/null @@ -1,69 +0,0 @@ -description: "findOneAndUpdate-errorResponse" - -schemaVersion: "1.12" - -createEntities: - - client: - id: &client0 client0 - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name test - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: "foo" } - -tests: - - description: "findOneAndUpdate DuplicateKey error is accessible" - runOnRequirements: - - minServerVersion: "4.2" # SERVER-37124 - operations: - - name: createIndex - object: *collection0 - arguments: - keys: { x: 1 } - unique: true - - name: findOneAndUpdate - object: *collection0 - arguments: - filter: { _id: 2 } - update: { $set: { x: "foo" } } - upsert: true - expectError: - errorCode: 11000 # DuplicateKey - errorResponse: - keyPattern: { x: 1 } - keyValue: { x: "foo" } - - - description: "findOneAndUpdate document validation errInfo is accessible" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: modifyCollection - object: *database0 - arguments: - collection: *collection0Name - validator: - x: { $type: "string" } - - name: findOneAndUpdate - object: *collection0 - arguments: - filter: { _id: 1 } - update: { $set: { x: 1 } } - expectError: - errorCode: 121 # DocumentValidationFailure - errorResponse: - # Avoid asserting the exact contents of errInfo as it may vary by - # server version. Likewise, this is why drivers do not model the - # document. The following is sufficient to test that validation - # details are accessible. See SERVER-20547 for more context. - errInfo: - failingDocumentId: 1 - details: { $$type: "object" } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-clientError.yml deleted file mode 100644 index 77b41a165c7..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-clientError.yml +++ /dev/null @@ -1,81 +0,0 @@ -description: findOneAndUpdate-hint-clientError -schemaVersion: '1.0' -runOnRequirements: - - - maxServerVersion: 4.0.99 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name findOneAndUpdate_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'FindOneAndUpdate with hint string unsupported (client-side error)' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: &filter - _id: 1 - update: &update - $inc: - x: 1 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - description: 'FindOneAndUpdate with hint document unsupported (client-side error)' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: *filter - update: *update - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-serverError.yml deleted file mode 100644 index 13abba5f5cc..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-serverError.yml +++ /dev/null @@ -1,97 +0,0 @@ -description: findOneAndUpdate-hint-serverError -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.2.0 - maxServerVersion: 4.3.0 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name findOneAndUpdate_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'FindOneAndUpdate with hint string unsupported (server-side error)' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: &filter - _id: 1 - update: &update - $inc: - x: 1 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - findAndModify: *collection_name - query: *filter - update: *update - hint: _id_ - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - description: 'FindOneAndUpdate with hint document unsupported (server-side error)' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: *filter - update: *update - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - findAndModify: *collection_name - query: *filter - update: *update - hint: - _id: 1 - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-unacknowledged.yml deleted file mode 100644 index ec576375a6f..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint-unacknowledged.yml +++ /dev/null @@ -1,92 +0,0 @@ -description: findOneAndUpdate-hint-unacknowledged - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - writeConcern: { w: 0 } - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: &documents - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - -tests: - - description: "Unacknowledged findOneAndUpdate with hint string fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: &filter { _id: { $gt: 1 } } - update: &update { $inc: { x: 1 } } - hint: _id_ - expectError: - isClientError: true - expectEvents: &noEvents - - client: *client0 - events: [] - - - description: "Unacknowledged findOneAndUpdate with hint document fails with client-side error on pre-4.4 server" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: *filter - update: *update - hint: { _id: 1 } - expectError: - isClientError: true - expectEvents: *noEvents - - - description: "Unacknowledged findOneAndUpdate with hint string on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: *filter - update: *update - hint: _id_ - expectResult: &unacknowledgedResult { $$unsetOrMatches: null } - expectEvents: &events - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - update: *update - hint: { $$type: [ string, object ]} - writeConcern: { w: 0 } - - - description: "Unacknowledged findOneAndUpdate with hint document on 4.4+ server" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: *filter - update: *update - hint: { _id: 1 } - expectResult: *unacknowledgedResult - expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint.yml deleted file mode 100644 index f7a3c33f083..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-hint.yml +++ /dev/null @@ -1,96 +0,0 @@ -description: findOneAndUpdate-hint -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.3.1 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name findOneAndUpdate_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'FindOneAndUpdate with hint string' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: &filter - _id: 1 - update: &update - $inc: - x: 1 - hint: _id_ - expectResult: &result - _id: 1 - x: 11 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - findAndModify: *collection_name - query: *filter - update: *update - hint: _id_ - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 12 - - - _id: 2 - x: 22 - - - description: 'FindOneAndUpdate with hint document' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: *filter - update: *update - hint: - _id: 1 - expectResult: *result - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - findAndModify: *collection_name - query: *filter - update: *update - hint: - _id: 1 - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-let.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-let.yml deleted file mode 100644 index 761001db9ef..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate-let.yml +++ /dev/null @@ -1,96 +0,0 @@ -description: "findOneAndUpdate-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - -tests: - - description: "findOneAndUpdate with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: findOneAndUpdate - object: *collection0 - arguments: - filter: &filter - $expr: - $eq: [ "$_id", "$$id" ] - update: &update - - $set: {x: "$$x" } - let: &let0 - id: 1 - x: "foo" - expectResult: - _id: 1 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter - update: *update - let: *let0 - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: "foo" } - - { _id: 2 } - - - description: "findOneAndUpdate with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "4.2.0" - maxServerVersion: "4.4.99" - operations: - - name: findOneAndUpdate - object: *collection0 - arguments: - filter: &filter1 - $expr: - $eq: [ "$_id", "$$id" ] - update: &update1 - - $set: {x: "$$x"} - let: &let1 - id: 1 - x: "foo" - expectError: - # This error message is consistent between 4.2.x and 4.4.x servers. - # Older servers return a different error message. - errorContains: "field 'let' is an unknown field" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - findAndModify: *collection0Name - query: *filter1 - update: *update1 - let: *let1 - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate.yml b/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate.yml deleted file mode 100644 index 181c6b8b546..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/findOneAndUpdate.yml +++ /dev/null @@ -1,199 +0,0 @@ -description: findOneAndUpdate - -schemaVersion: '1.0' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - - description: 'FindOneAndUpdate when many documents match returning the document before modification' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: { _id: { $gt: 1 } } - update: { $inc: { x: 1 } } - projection: { x: 1, _id: 0 } - sort: { x: 1 } - expectResult: { x: 22 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 23 } - - { _id: 3, x: 33 } - - - description: 'FindOneAndUpdate when many documents match returning the document after modification' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: { _id: { $gt: 1 } } - update: { $inc: { x: 1 } } - projection: { x: 1, _id: 0 } - returnDocument: After - sort: { x: 1 } - expectResult: { x: 23 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 23 } - - { _id: 3, x: 33 } - - - description: 'FindOneAndUpdate when one document matches returning the document before modification' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: { _id: 2 } - update: { $inc: { x: 1 } } - projection: { x: 1, _id: 0 } - sort: { x: 1 } - expectResult: { x: 22 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 23 } - - { _id: 3, x: 33 } - - - description: 'FindOneAndUpdate when one document matches returning the document after modification' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: { _id: 2 } - update: { $inc: { x: 1 } } - projection: { x: 1, _id: 0 } - returnDocument: After - sort: { x: 1 } - expectResult: { x: 23 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 23 } - - { _id: 3, x: 33 } - - - description: 'FindOneAndUpdate when no documents match returning the document before modification' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: { _id: 4 } - update: { $inc: { x: 1 } } - projection: { x: 1, _id: 0 } - sort: { x: 1 } - expectResult: null - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - - description: 'FindOneAndUpdate when no documents match with upsert returning the document before modification' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: { _id: 4 } - update: { $inc: { x: 1 } } - projection: { x: 1, _id: 0 } - # Omit the sort option as it has no effect when no documents match and - # would only cause an inconsistent return value on pre-3.0 servers - # when combined with returnDocument "before" (see: SERVER-17650). - upsert: true - expectResult: null - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 1 } - - - description: 'FindOneAndUpdate when no documents match returning the document after modification' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: { _id: 4 } - update: { $inc: { x: 1 } } - projection: { x: 1, _id: 0 } - returnDocument: After - sort: { x: 1 } - expectResult: null - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - - description: 'FindOneAndUpdate when no documents match with upsert returning the document after modification' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: { _id: 4 } - update: { $inc: { x: 1 } } - projection: { x: 1, _id: 0 } - returnDocument: After - sort: { x: 1 } - upsert: true - expectResult: { x: 1 } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 1 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertMany-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/insertMany-comment.yml deleted file mode 100644 index 4b51584df2b..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/insertMany-comment.yml +++ /dev/null @@ -1,93 +0,0 @@ -description: "insertMany-comment" -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - -tests: - - description: "insertMany with string comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: insertMany - object: *collection0 - arguments: - documents: - - &document { _id: 2, x: 22 } - comment: "comment" - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *document - comment: "comment" - outcome: &outcome - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - - description: "insertMany with document comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: insertMany - object: *collection0 - arguments: - documents: - - *document - comment: &comment { key: "value" } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *document - comment: *comment - outcome: *outcome - - - description: "insertMany with comment - pre 4.4" - runOnRequirements: - - minServerVersion: "3.4.0" - maxServerVersion: "4.2.99" - operations: - - name: insertMany - object: *collection0 - arguments: - documents: - - *document - comment: "comment" - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *document - comment: "comment" - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertMany-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/insertMany-dots_and_dollars.yml deleted file mode 100644 index 913a55e4c05..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/insertMany-dots_and_dollars.yml +++ /dev/null @@ -1,128 +0,0 @@ -description: "insertMany-dots_and_dollars" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: [] - -tests: - - description: "Inserting document with top-level dollar-prefixed key on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: insertMany - object: *collection0 - arguments: - documents: - - &dollarPrefixedKey { _id: 1, $a: 1 } - expectResult: &insertResult - # InsertManyResult is optional because all of its fields are optional - $$unsetOrMatches: { insertedIds: { $$unsetOrMatches: { 0: 1 } } } - expectEvents: &expectEventsDollarPrefixedKey - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dollarPrefixedKey - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dollarPrefixedKey - - - description: "Inserting document with top-level dollar-prefixed key on pre-5.0 server yields server-side error" - runOnRequirements: - - maxServerVersion: "4.99" - operations: - - name: insertMany - object: *collection0 - arguments: - documents: - - *dollarPrefixedKey - expectError: - isClientError: false - expectEvents: *expectEventsDollarPrefixedKey - outcome: *initialData - - - description: "Inserting document with top-level dotted key" - operations: - - name: insertMany - object: *collection0 - arguments: - documents: - - &dottedKey { _id: 1, a.b: 1 } - expectResult: *insertResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dottedKey - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dottedKey - - - description: "Inserting document with dollar-prefixed key in embedded doc" - operations: - - name: insertMany - object: *collection0 - arguments: - documents: - - &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } } - expectResult: *insertResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dollarPrefixedKeyInEmbedded - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dollarPrefixedKeyInEmbedded - - - description: "Inserting document with dotted key in embedded doc" - operations: - - name: insertMany - object: *collection0 - arguments: - documents: - - &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } } - expectResult: *insertResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dottedKeyInEmbedded - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dottedKeyInEmbedded diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertMany.yml b/driver-core/src/test/resources/unified-test-format/crud/insertMany.yml deleted file mode 100644 index ac4e868cc1d..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/insertMany.yml +++ /dev/null @@ -1,118 +0,0 @@ -description: insertMany - -schemaVersion: '1.0' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - -tests: - - - description: 'InsertMany with non-existing documents' - operations: - - - object: *collection0 - name: insertMany - arguments: - documents: - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - ordered: true - expectResult: - $$unsetOrMatches: - insertedIds: - $$unsetOrMatches: - '0': 2 - '1': 3 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - - description: 'InsertMany continue-on-error behavior with unordered (preexisting duplicate key)' - operations: - - - object: *collection0 - name: insertMany - arguments: - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - ordered: false - expectError: - isError: true - expectResult: - deletedCount: 0 - insertedCount: 2 - # Since the map of insertedIds is generated before execution it - # could indicate inserts that did not actually succeed. We omit this - # field rather than expect drivers to provide an accurate map - # filtered by write errors. - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - upsertedIds: { } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - - description: 'InsertMany continue-on-error behavior with unordered (duplicate key in requests)' - operations: - - - object: *collection0 - name: insertMany - arguments: - documents: - - { _id: 2, x: 22 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - ordered: false - expectError: - isError: true - expectResult: - deletedCount: 0 - insertedCount: 2 - # Since the map of insertedIds is generated before execution it - # could indicate inserts that did not actually succeed. We omit this - # field rather than expect drivers to provide an accurate map - # filtered by write errors. - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - upsertedIds: { } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertOne-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/insertOne-comment.yml deleted file mode 100644 index f8cb60ce85a..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/insertOne-comment.yml +++ /dev/null @@ -1,91 +0,0 @@ -description: "insertOne-comment" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - -tests: - - description: "insertOne with string comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: insertOne - object: *collection0 - arguments: - document: &document { _id: 2, x: 22 } - comment: "comment" - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *document - comment: "comment" - outcome: &outcome - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - - description: "insertOne with document comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: insertOne - object: *collection0 - arguments: - document: *document - comment: &comment { key: "value" } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *document - comment: *comment - outcome: *outcome - - - description: "insertOne with comment - pre 4.4" - runOnRequirements: - - minServerVersion: "3.4.0" - maxServerVersion: "4.2.99" - operations: - - name: insertOne - object: *collection0 - arguments: - document: *document - comment: "comment" - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *document - comment: "comment" - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertOne-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/insertOne-dots_and_dollars.yml deleted file mode 100644 index fcfcfc71c6f..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/insertOne-dots_and_dollars.yml +++ /dev/null @@ -1,238 +0,0 @@ -description: "insertOne-dots_and_dollars" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - - collection: - id: &collection1 collection1 - database: *database0 - collectionName: &collection1Name coll1 - collectionOptions: - writeConcern: { w: 0 } - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: [] - -tests: - - description: "Inserting document with top-level dollar-prefixed key on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: insertOne - object: *collection0 - arguments: - document: &dollarPrefixedKey { _id: 1, $a: 1 } - expectResult: &insertResult - # InsertOneResult is optional because all of its fields are optional - $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } - expectEvents: &expectEventsDollarPrefixedKey - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dollarPrefixedKey - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dollarPrefixedKey - - - description: "Inserting document with top-level dollar-prefixed key on pre-5.0 server yields server-side error" - runOnRequirements: - - maxServerVersion: "4.99" - operations: - - name: insertOne - object: *collection0 - arguments: - document: *dollarPrefixedKey - expectError: - isClientError: false - expectEvents: *expectEventsDollarPrefixedKey - outcome: *initialData - - - description: "Inserting document with top-level dotted key" - operations: - - name: insertOne - object: *collection0 - arguments: - document: &dottedKey { _id: 1, a.b: 1 } - expectResult: *insertResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dottedKey - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dottedKey - - - description: "Inserting document with dollar-prefixed key in embedded doc" - operations: - - name: insertOne - object: *collection0 - arguments: - document: &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } } - expectResult: *insertResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dollarPrefixedKeyInEmbedded - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dollarPrefixedKeyInEmbedded - - - description: "Inserting document with dotted key in embedded doc" - operations: - - name: insertOne - object: *collection0 - arguments: - document: &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } } - expectResult: *insertResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dottedKeyInEmbedded - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dottedKeyInEmbedded - - - description: "Inserting document with dollar-prefixed key in _id yields server-side error" - # Note: 5.0+ did not remove restrictions on dollar-prefixed keys in _id documents - operations: - - name: insertOne - object: *collection0 - arguments: - document: &dollarPrefixedKeyInId { _id: { $a: 1 } } - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dollarPrefixedKeyInId - outcome: *initialData - - - description: "Inserting document with dotted key in _id on 3.6+ server" - runOnRequirements: - - minServerVersion: "3.6" - operations: - - name: insertOne - object: *collection0 - arguments: - document: &dottedKeyInId { _id: { a.b: 1 } } - expectResult: - # InsertOneResult is optional because all of its fields are optional - $$unsetOrMatches: { insertedId: { $$unsetOrMatches: { a.b: 1 } } } - expectEvents: &expectEventsDottedKeyInId - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dottedKeyInId - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dottedKeyInId - - - description: "Inserting document with dotted key in _id on pre-3.6 server yields server-side error" - runOnRequirements: - - maxServerVersion: "3.4.99" - operations: - - name: insertOne - object: *collection0 - arguments: - document: *dottedKeyInId - expectError: - isClientError: false - expectEvents: *expectEventsDottedKeyInId - outcome: *initialData - - - description: "Inserting document with DBRef-like keys" - operations: - - name: insertOne - object: *collection0 - arguments: - # Note: an incomplete DBRef document may cause issues loading the test - # file with an Extended JSON parser, since the presence of one DBRef - # key may cause the parser to require others and/or enforce expected - # types (e.g. $ref and $db must be strings). - # - # Using "$db" here works for libmongoc so long as it's a string type; - # however, neither $ref nor $id would be accepted on their own. - # - # See https://github.com/mongodb/specifications/blob/master/source/extended-json.md#parsers - document: &dbrefLikeKey { _id: 1, a: { $db: "foo" } } - expectResult: *insertResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection0Name - documents: - - *dbrefLikeKey - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dbrefLikeKey - - - description: "Unacknowledged write using dollar-prefixed or dotted keys may be silently rejected on pre-5.0 server" - runOnRequirements: - - maxServerVersion: "4.99" - operations: - - name: insertOne - object: *collection1 - arguments: - document: *dollarPrefixedKeyInId - expectResult: - # InsertOneResult is optional because all of its fields are optional - $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - insert: *collection1Name - documents: - - *dollarPrefixedKeyInId - writeConcern: { w: 0 } - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertOne-errorResponse.yml b/driver-core/src/test/resources/unified-test-format/crud/insertOne-errorResponse.yml deleted file mode 100644 index b14caa1737f..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/insertOne-errorResponse.yml +++ /dev/null @@ -1,46 +0,0 @@ -description: "insertOne-errorResponse" - -schemaVersion: "1.12" - -createEntities: - - client: - id: &client0 client0 - useMultipleMongoses: false - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name test - -tests: - # Some drivers may still need to skip this test because the CRUD spec does not - # prescribe how drivers should formulate a WriteException beyond collecting a - # write or write concern error. - - description: "insert operations support errorResponse assertions" - runOnRequirements: - - minServerVersion: "4.0.0" - topologies: [ single, replicaset ] - - minServerVersion: "4.2.0" - topologies: [ sharded ] - operations: - - name: failPoint - object: testRunner - arguments: - client: *client0 - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: [ insert ] - errorCode: &errorCode 8 # UnknownError - - name: insertOne - object: *collection0 - arguments: - document: { _id: 1 } - expectError: - errorCode: *errorCode - errorResponse: - code: *errorCode diff --git a/driver-core/src/test/resources/unified-test-format/crud/insertOne.yml b/driver-core/src/test/resources/unified-test-format/crud/insertOne.yml deleted file mode 100644 index 85ab7fe9e0c..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/insertOne.yml +++ /dev/null @@ -1,44 +0,0 @@ -description: insertOne - -schemaVersion: '1.0' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - -tests: - - - description: 'InsertOne with a non-existing document' - operations: - - - object: *collection0 - name: insertOne - arguments: - document: { _id: 2, x: 22 } - expectResult: - $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-collation.yml deleted file mode 100644 index 68eddcff91f..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-collation.yml +++ /dev/null @@ -1,57 +0,0 @@ -description: replaceOne-collation - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '3.4' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: ping } - -tests: - - - description: 'ReplaceOne when one document matches with collation' - operations: - - - object: *collection0 - name: replaceOne - arguments: - filter: { x: PING } - replacement: { _id: 2, x: pong } - # https://www.mongodb.com/docs/manual/reference/collation/#collation-document - collation: - locale: en_US - strength: 2 - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: pong } diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-comment.yml deleted file mode 100644 index 2c22b287572..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-comment.yml +++ /dev/null @@ -1,105 +0,0 @@ -description: "replaceOne-comment" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - -tests: - - description: "ReplaceOne with string comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: &filter { _id: 1 } - replacement: &replacement { x: 22 } - comment: "comment" - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter - u: *replacement - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - comment: "comment" - outcome: &outcome - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 22 } - - - description: "ReplaceOne with document comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: *filter - replacement: *replacement - comment: &comment { key: "value" } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter - u: *replacement - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - comment: *comment - outcome: *outcome - - - description: "ReplaceOne with comment - pre 4.4" - runOnRequirements: - - minServerVersion: "3.4.0" - maxServerVersion: "4.2.99" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: *filter - replacement: *replacement - comment: "comment" - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter - u: *replacement - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - comment: "comment" - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-dots_and_dollars.yml deleted file mode 100644 index b834e222055..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-dots_and_dollars.yml +++ /dev/null @@ -1,180 +0,0 @@ -description: "replaceOne-dots_and_dollars" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - - collection: - id: &collection1 collection1 - database: *database0 - collectionName: &collection1Name coll1 - collectionOptions: - writeConcern: { w: 0 } - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - -tests: - - description: "Replacing document with top-level dotted key on 3.6+ server" - runOnRequirements: - - minServerVersion: "3.6" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: { _id: 1 } - replacement: &dottedKey { _id: 1, a.b: 1 } - expectResult: &replaceResult - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - expectEvents: &expectEventsDottedKey - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dottedKey - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dottedKey - - - description: "Replacing document with top-level dotted key on pre-3.6 server yields server-side error" - runOnRequirements: - - maxServerVersion: "3.4.99" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: { _id: 1 } - replacement: *dottedKey - expectError: - isClientError: false - expectEvents: *expectEventsDottedKey - outcome: *initialData - - - description: "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: { _id: 1 } - replacement: &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } } - expectResult: *replaceResult - expectEvents: &expectEventsDollarPrefixedKeyInEmbedded - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dollarPrefixedKeyInEmbedded - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dollarPrefixedKeyInEmbedded - - - description: "Replacing document with dollar-prefixed key in embedded doc on pre-5.0 server yields server-side error" - runOnRequirements: - - maxServerVersion: "4.99" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: { _id: 1 } - replacement: *dollarPrefixedKeyInEmbedded - expectError: - isClientError: false - expectEvents: *expectEventsDollarPrefixedKeyInEmbedded - outcome: *initialData - - - description: "Replacing document with dotted key in embedded doc on 3.6+ server" - runOnRequirements: - - minServerVersion: "3.6" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: { _id: 1 } - replacement: &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } } - expectResult: *replaceResult - expectEvents: &expectEventsDottedKeyInEmbedded - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dottedKeyInEmbedded - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - *dottedKeyInEmbedded - - - description: "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error" - runOnRequirements: - - maxServerVersion: "3.4.99" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: { _id: 1 } - replacement: *dottedKeyInEmbedded - expectError: - isClientError: false - expectEvents: *expectEventsDottedKeyInEmbedded - outcome: *initialData - - - description: "Unacknowledged write using dollar-prefixed or dotted keys may be silently rejected on pre-5.0 server" - runOnRequirements: - - maxServerVersion: "4.99" - operations: - - name: replaceOne - object: *collection1 - arguments: - filter: { _id: 1 } - replacement: *dollarPrefixedKeyInEmbedded - expectResult: - acknowledged: { $$unsetOrMatches: false } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection1Name - updates: - - q: { _id: 1 } - u: *dollarPrefixedKeyInEmbedded - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - writeConcern: { w: 0 } - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint-unacknowledged.yml deleted file mode 100644 index debb99b22ff..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint-unacknowledged.yml +++ /dev/null @@ -1,95 +0,0 @@ -description: replaceOne-hint-unacknowledged - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - writeConcern: { w: 0 } - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: &documents - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - -tests: - - description: "Unacknowledged replaceOne with hint string fails with client-side error on pre-4.2 server" - runOnRequirements: - - maxServerVersion: "4.0.99" - operations: - - object: *collection0 - name: replaceOne - arguments: - filter: &filter { _id: { $gt: 1 } } - replacement: &replacement { x: 111 } - hint: _id_ - expectError: - isClientError: true - expectEvents: &noEvents - - client: *client0 - events: [] - - - description: "Unacknowledged replaceOne with hint document fails with client-side error on pre-4.2 server" - runOnRequirements: - - maxServerVersion: "4.0.99" - operations: - - object: *collection0 - name: replaceOne - arguments: - filter: *filter - replacement: *replacement - hint: { _id: 1 } - expectError: - isClientError: true - expectEvents: *noEvents - - - description: "Unacknowledged replaceOne with hint string on 4.2+ server" - runOnRequirements: - - minServerVersion: "4.2.0" - operations: - - object: *collection0 - name: replaceOne - arguments: - filter: *filter - replacement: *replacement - hint: _id_ - expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } - expectEvents: &events - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: *filter - u: *replacement - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - hint: { $$type: [ string, object ]} - writeConcern: { w: 0 } - - - description: "Unacknowledged replaceOne with hint document on 4.2+ server" - runOnRequirements: - - minServerVersion: "4.2.0" - operations: - - object: *collection0 - name: replaceOne - arguments: - filter: *filter - replacement: *replacement - hint: { _id: 1 } - expectResult: *unacknowledgedResult - expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint.yml deleted file mode 100644 index 263e372170a..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-hint.yml +++ /dev/null @@ -1,105 +0,0 @@ -description: replaceOne-hint -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.2.0 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_replaceone_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'ReplaceOne with hint string' - operations: - - - object: *collection0 - name: replaceOne - arguments: - filter: &filter - _id: - $gt: 1 - replacement: &replacement - x: 111 - hint: _id_ - expectResult: &result - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *filter - u: *replacement - hint: _id_ - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 111 - - - description: 'ReplaceOne with hint document' - operations: - - - object: *collection0 - name: replaceOne - arguments: - filter: *filter - replacement: *replacement - hint: - _id: 1 - expectResult: *result - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *filter - u: *replacement - hint: - _id: 1 - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-let.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-let.yml deleted file mode 100644 index fda5bb67441..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-let.yml +++ /dev/null @@ -1,98 +0,0 @@ -description: "replaceOne-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - -tests: - - description: "ReplaceOne with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: &filter - $expr: - $eq: [ "$_id", "$$id" ] - replacement: &replacement - x: "foo" - let: &let - id: 1 - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter - u: *replacement - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - let: *let - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: "foo" } - - { _id: 2 } - - - description: "ReplaceOne with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "3.6.0" - maxServerVersion: "4.4.99" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: *filter - replacement: *replacement - let: *let - expectError: - errorContains: "'update.let' is an unknown field" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter - u: *replacement - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - let: *let - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-sort.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-sort.yml deleted file mode 100644 index f4b10fbaf98..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-sort.yml +++ /dev/null @@ -1,94 +0,0 @@ -description: replaceOne-sort - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent, commandSucceededEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: ReplaceOne with sort option - runOnRequirements: - - minServerVersion: "8.0" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: { _id: { $gt: 1 } } - sort: { _id: -1 } - replacement: { x: 1 } - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: { $gt: 1 } } - u: { x: 1 } - sort: { _id: -1 } - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - - commandSucceededEvent: - reply: { ok: 1, n: 1 } - commandName: update - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 1 } - - - description: replaceOne with sort option unsupported (server-side error) - runOnRequirements: - - maxServerVersion: "7.99" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: { _id: { $gt: 1 } } - sort: { _id: -1 } - replacement: { x: 1 } - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: { $gt: 1 } } - u: { x: 1 } - sort: { _id: -1 } - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-validation.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne-validation.yml deleted file mode 100644 index db5a2a6666c..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/replaceOne-validation.yml +++ /dev/null @@ -1,37 +0,0 @@ -description: "replaceOne-validation" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - -tests: - - description: "ReplaceOne prohibits atomic modifiers" - operations: - - name: replaceOne - object: *collection0 - arguments: - filter: { _id: 1 } - replacement: { $set: { x: 22 } } - expectError: - isClientError: true - expectEvents: - - client: *client0 - events: [] - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/replaceOne.yml b/driver-core/src/test/resources/unified-test-format/crud/replaceOne.yml deleted file mode 100644 index ebe0af933ec..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/replaceOne.yml +++ /dev/null @@ -1,138 +0,0 @@ -description: replaceOne - -schemaVersion: '1.0' - -runOnRequirements: - - - minServerVersion: '2.6' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - - # This test doesn't verify the output collection because we cannot assume - # which document gets replaced. - description: 'ReplaceOne when many documents match' - operations: - - - object: *collection0 - name: replaceOne - arguments: - filter: { _id: { $gt: 1 } } - replacement: { x: 111 } - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - - - description: 'ReplaceOne when one document matches' - operations: - - - object: *collection0 - name: replaceOne - arguments: - filter: { _id: 1 } - replacement: { _id: 1, x: 111 } - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 111 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - - description: 'ReplaceOne when no documents match' - operations: - - - object: *collection0 - name: replaceOne - arguments: - filter: { _id: 4 } - replacement: { _id: 4, x: 1 } - expectResult: - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - - description: 'ReplaceOne with upsert when no documents match without an id specified' - operations: - - - object: *collection0 - name: replaceOne - arguments: - filter: { _id: 4 } - replacement: { x: 1 } - upsert: true - expectResult: - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 1 - upsertedId: 4 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 1 } - - - description: 'ReplaceOne with upsert when no documents match with an id specified' - operations: - - - object: *collection0 - name: replaceOne - arguments: - filter: { _id: 4 } - replacement: { _id: 4, x: 1 } - upsert: true - expectResult: - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 1 - upsertedId: 4 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 1 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-arrayFilters.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-arrayFilters.yml deleted file mode 100644 index db5ec29c885..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateMany-arrayFilters.yml +++ /dev/null @@ -1,98 +0,0 @@ -description: updateMany-arrayFilters - -schemaVersion: '1.0' - -runOnRequirements: - - - minServerVersion: 3.5.6 - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } - -tests: - - - description: 'UpdateMany when no documents match arrayFilters' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: { } - update: { $set: { 'y.$[i].b': 2 } } - arrayFilters: - - { i.b: 4 } - expectResult: - matchedCount: 2 - modifiedCount: 0 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } - - - description: 'UpdateMany when one document matches arrayFilters' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: { } - update: { $set: { 'y.$[i].b': 2 } } - arrayFilters: - - { i.b: 3 } - expectResult: - matchedCount: 2 - modifiedCount: 1 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 2 }, { b: 1 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } - - - description: 'UpdateMany when multiple documents match arrayFilters' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: { } - update: { $set: { 'y.$[i].b': 2 } } - arrayFilters: - - { i.b: 1 } - expectResult: - matchedCount: 2 - modifiedCount: 2 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 3 }, { b: 2 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 2 } ] } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-collation.yml deleted file mode 100644 index af5221c02ed..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateMany-collation.yml +++ /dev/null @@ -1,59 +0,0 @@ -description: updateMany-collation - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '3.4' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: ping } - - { _id: 3, x: pINg } - -tests: - - - description: 'UpdateMany when many documents match with collation' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: { x: ping } - update: { $set: { x: pong } } - # https://www.mongodb.com/docs/manual/reference/collation/#collation-document - collation: - locale: en_US - strength: 2 - expectResult: - matchedCount: 2 - modifiedCount: 2 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: pong } - - { _id: 3, x: pong } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-comment.yml deleted file mode 100644 index 4c6fbacd771..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateMany-comment.yml +++ /dev/null @@ -1,104 +0,0 @@ -description: "updateMany-comment" -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - -tests: - - description: "UpdateMany with string comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: updateMany - object: *collection0 - arguments: - filter: &filter { _id: 1 } - update: &update { $set: {x: 22} } - comment: "comment" - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter - u: *update - multi: true - upsert: { $$unsetOrMatches: false } - comment: "comment" - outcome: &outcome - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 22 } - - - description: "UpdateMany with document comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: updateMany - object: *collection0 - arguments: - filter: *filter - update: *update - comment: &comment { key: "value" } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter - u: *update - multi: true - upsert: { $$unsetOrMatches: false } - comment: *comment - outcome: *outcome - - - description: "UpdateMany with comment - pre 4.4" - runOnRequirements: - - minServerVersion: "3.4.0" - maxServerVersion: "4.2.99" - operations: - - name: updateMany - object: *collection0 - arguments: - filter: *filter - update: *update - comment: "comment" - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter - u: *update - multi: true - upsert: { $$unsetOrMatches: false } - comment: "comment" - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-dots_and_dollars.yml deleted file mode 100644 index 6c9da82a5ad..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateMany-dots_and_dollars.yml +++ /dev/null @@ -1,138 +0,0 @@ -description: "updateMany-dots_and_dollars" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {} } - -tests: - - description: "Updating document to set top-level dollar-prefixed key on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: updateMany - object: *collection0 - arguments: - filter: { _id: 1 } - update: &dollarPrefixedKey - - { $replaceWith: { $setField: { field: { $literal: $a }, value: 1, input: $$ROOT } } } - expectResult: &updateResult - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dollarPrefixedKey - multi: true - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {}, $a: 1 } - - - description: "Updating document to set top-level dotted key on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: updateMany - object: *collection0 - arguments: - filter: { _id: 1 } - update: &dottedKey - - { $replaceWith: { $setField: { field: { $literal: a.b }, value: 1, input: $$ROOT } } } - expectResult: *updateResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dottedKey - multi: true - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {}, a.b: 1 } - - - description: "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: updateMany - object: *collection0 - arguments: - filter: { _id: 1 } - update: &dollarPrefixedKeyInEmbedded - - { $set: { foo: { $setField: { field: { $literal: $a }, value: 1, input: $foo } } } } - expectResult: *updateResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dollarPrefixedKeyInEmbedded - multi: true - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: { $a: 1 } } - - - description: "Updating document to set dotted key in embedded doc on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: updateMany - object: *collection0 - arguments: - filter: { _id: 1 } - update: &dottedKeyInEmbedded - - { $set: { foo: { $setField: { field: { $literal: a.b }, value: 1, input: $foo } } } } - expectResult: *updateResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dottedKeyInEmbedded - multi: true - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: { a.b: 1 } } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-clientError.yml deleted file mode 100644 index 163168ecfab..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-clientError.yml +++ /dev/null @@ -1,88 +0,0 @@ -description: updateMany-hint-clientError -schemaVersion: '1.0' -runOnRequirements: - - - maxServerVersion: 3.3.99 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_updatemany_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 -tests: - - - description: 'UpdateMany with hint string unsupported (client-side error)' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: &filter - _id: - $gt: 1 - update: &update - $inc: - x: 1 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - description: 'UpdateMany with hint document unsupported (client-side error)' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: *filter - update: *update - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-serverError.yml deleted file mode 100644 index 61d7179fc03..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-serverError.yml +++ /dev/null @@ -1,112 +0,0 @@ -description: updateMany-hint-serverError -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 3.4.0 - maxServerVersion: 4.1.9 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_updatemany_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 -tests: - - - description: 'UpdateMany with hint string unsupported (server-side error)' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: &filter - _id: - $gt: 1 - update: &update - $inc: - x: 1 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *filter - u: *update - multi: true - hint: _id_ - upsert: { $$unsetOrMatches: false } - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 - - - description: 'UpdateMany with hint document unsupported (server-side error)' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: *filter - update: *update - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *filter - u: *update - multi: true - hint: - _id: 1 - upsert: { $$unsetOrMatches: false } - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-unacknowledged.yml deleted file mode 100644 index 9f152973858..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint-unacknowledged.yml +++ /dev/null @@ -1,96 +0,0 @@ -description: updateMany-hint-unacknowledged - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - writeConcern: { w: 0 } - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: &documents - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: "Unacknowledged updateMany with hint string fails with client-side error on pre-4.2 server" - runOnRequirements: - - maxServerVersion: "4.0.99" - operations: - - object: *collection0 - name: updateMany - arguments: - filter: &filter { _id: { $gt: 1 } } - update: &update { $inc: { x: 1 } } - hint: _id_ - expectError: - isClientError: true - expectEvents: &noEvents - - client: *client0 - events: [] - - - description: "Unacknowledged updateMany with hint document fails with client-side error on pre-4.2 server" - runOnRequirements: - - maxServerVersion: "4.0.99" - operations: - - object: *collection0 - name: updateMany - arguments: - filter: *filter - update: *update - hint: { _id: 1 } - expectError: - isClientError: true - expectEvents: *noEvents - - - description: "Unacknowledged updateMany with hint string on 4.2+ server" - runOnRequirements: - - minServerVersion: "4.2.0" - operations: - - object: *collection0 - name: updateMany - arguments: - filter: *filter - update: *update - hint: _id_ - expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } - expectEvents: &events - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: *filter - u: *update - multi: true - upsert: { $$unsetOrMatches: false } - hint: { $$type: [ string, object ]} - writeConcern: { w: 0 } - - - description: "Unacknowledged updateMany with hint document on 4.2+ server" - runOnRequirements: - - minServerVersion: "4.2.0" - operations: - - object: *collection0 - name: updateMany - arguments: - filter: *filter - update: *update - hint: { _id: 1 } - expectResult: *unacknowledgedResult - expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint.yml deleted file mode 100644 index e5950309236..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateMany-hint.yml +++ /dev/null @@ -1,112 +0,0 @@ -description: updateMany-hint -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.2.0 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_updatemany_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - _id: 3 - x: 33 -tests: - - - description: 'UpdateMany with hint string' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: &filter - _id: - $gt: 1 - update: &update - $inc: - x: 1 - hint: _id_ - expectResult: &result - matchedCount: 2 - modifiedCount: 2 - upsertedCount: 0 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *filter - u: *update - multi: true - hint: _id_ - upsert: { $$unsetOrMatches: false } - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 23 - - - _id: 3 - x: 34 - - - description: 'UpdateMany with hint document' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: *filter - update: *update - hint: - _id: 1 - expectResult: *result - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *filter - u: *update - multi: true - hint: - _id: 1 - upsert: { $$unsetOrMatches: false } - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-let.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-let.yml deleted file mode 100644 index 402000967bf..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateMany-let.yml +++ /dev/null @@ -1,107 +0,0 @@ -description: "updateMany-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2, name: "name" } - - { _id: 3, name: "name" } - - -tests: - - description: "updateMany with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: updateMany - object: *collection0 - arguments: - filter: &filter - $expr: - $eq: [ "$name", "$$name" ] - update: &update - - $set: {x: "$$x", y: "$$y" } - let: &let0 - name: name - x: foo - y: { $literal: "bar" } - expectResult: - matchedCount: 2 - modifiedCount: 2 - upsertedCount: 0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter - u: *update - multi: true - upsert: { $$unsetOrMatches: false } - let: *let0 - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2, name: "name", x: "foo", y: "bar" } - - { _id: 3, name: "name", x: "foo", y: "bar" } - - - description: "updateMany with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "4.2.0" - maxServerVersion: "4.4.99" - operations: - - name: updateMany - object: *collection0 - arguments: - filter: &filter1 - _id: 1 - update: &update1 - - $set: {x: "$$x"} - let: &let1 - x: foo - expectError: - errorContains: "'update.let' is an unknown field" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter1 - u: *update1 - multi: true - upsert: { $$unsetOrMatches: false } - let: *let1 - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2, name: "name" } - - { _id: 3, name: "name" } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany-validation.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany-validation.yml deleted file mode 100644 index 4e86eff1f37..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateMany-validation.yml +++ /dev/null @@ -1,39 +0,0 @@ -description: "updateMany-validation" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: "UpdateMany requires atomic modifiers" - operations: - - name: updateMany - object: *collection0 - arguments: - filter: { _id: { $gt: 1 } } - update: { x: 44 } - expectError: - isClientError: true - expectEvents: - - client: *client0 - events: [] - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateMany.yml b/driver-core/src/test/resources/unified-test-format/crud/updateMany.yml deleted file mode 100644 index 98f29d45e85..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateMany.yml +++ /dev/null @@ -1,120 +0,0 @@ -description: updateMany - -schemaVersion: '1.0' - -runOnRequirements: - - - minServerVersion: '2.6' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - - description: 'UpdateMany when many documents match' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: { _id: { $gt: 1 } } - update: { $inc: { x: 1 } } - expectResult: - matchedCount: 2 - modifiedCount: 2 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 23 } - - { _id: 3, x: 34 } - - - description: 'UpdateMany when one document matches' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: { _id: 1 } - update: { $inc: { x: 1 } } - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 12 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - - description: 'UpdateMany when no documents match' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: { _id: 4 } - update: { $inc: { x: 1 } } - expectResult: - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - - description: 'UpdateMany with upsert when no documents match' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: { _id: 4 } - update: { $inc: { x: 1 } } - upsert: true - expectResult: - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 1 - upsertedId: 4 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 1 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-arrayFilters.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-arrayFilters.yml deleted file mode 100644 index 8d5b238befb..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateOne-arrayFilters.yml +++ /dev/null @@ -1,150 +0,0 @@ -description: updateOne-arrayFilters - -schemaVersion: '1.0' - -runOnRequirements: - - - minServerVersion: 3.5.6 - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } - - { _id: 3, y: [ { b: 5, c: [ { d: 2 }, { d: 1 } ] } ] } - -tests: - - - description: 'UpdateOne when no document matches arrayFilters' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: { } - update: { $set: { 'y.$[i].b': 2 } } - arrayFilters: - - { i.b: 4 } - expectResult: - matchedCount: 1 - modifiedCount: 0 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } - - { _id: 3, y: [ { b: 5, c: [ { d: 2 }, { d: 1 } ] } ] } - - - description: 'UpdateOne when one document matches arrayFilters' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: { } - update: { $set: { 'y.$[i].b': 2 } } - arrayFilters: - - { i.b: 3 } - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 2 }, { b: 1 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } - - { _id: 3, y: [ { b: 5, c: [ { d: 2 }, { d: 1 } ] } ] } - - - description: 'UpdateOne when multiple documents match arrayFilters' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: { } - update: { $set: { 'y.$[i].b': 2 } } - arrayFilters: - - { i.b: 1 } - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 3 }, { b: 2 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } - - { _id: 3, y: [ { b: 5, c: [ { d: 2 }, { d: 1 } ] } ] } - - - description: 'UpdateOne when no documents match multiple arrayFilters' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: { _id: 3 } - update: { $set: { 'y.$[i].c.$[j].d': 0 } } - arrayFilters: - - { i.b: 5 } - - { j.d: 3 } - expectResult: - matchedCount: 1 - modifiedCount: 0 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } - - { _id: 3, y: [ { b: 5, c: [ { d: 2 }, { d: 1 } ] } ] } - - - description: 'UpdateOne when one document matches multiple arrayFilters' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: { _id: 3 } - update: { $set: { 'y.$[i].c.$[j].d': 0 } } - arrayFilters: - - { i.b: 5 } - - { j.d: 1 } - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, y: [ { b: 3 }, { b: 1 } ] } - - { _id: 2, y: [ { b: 0 }, { b: 1 } ] } - - { _id: 3, y: [ { b: 5, c: [ { d: 2 }, { d: 0 } ] } ] } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-collation.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-collation.yml deleted file mode 100644 index 85c2b552959..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateOne-collation.yml +++ /dev/null @@ -1,57 +0,0 @@ -description: updateOne-collation - -schemaVersion: '1.4' - -runOnRequirements: - - - minServerVersion: '3.4' - serverless: forbid - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: ping } - -tests: - - - description: 'UpdateOne when one document matches with collation' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: { x: PING } - update: { $set: { x: pong } } - # https://www.mongodb.com/docs/manual/reference/collation/#collation-document - collation: - locale: en_US - strength: 2 - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: pong } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-comment.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-comment.yml deleted file mode 100644 index a176d620ebd..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateOne-comment.yml +++ /dev/null @@ -1,104 +0,0 @@ -description: "updateOne-comment" -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - -tests: - - description: "UpdateOne with string comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: updateOne - object: *collection0 - arguments: - filter: &filter { _id: 1 } - update: &update { $set: {x: 22} } - comment: "comment" - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter - u: *update - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - comment: "comment" - outcome: &outcome - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 22 } - - - description: "UpdateOne with document comment" - runOnRequirements: - - minServerVersion: "4.4" - operations: - - name: updateOne - object: *collection0 - arguments: - filter: *filter - update: *update - comment: &comment { key: "value" } - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter - u: *update - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - comment: *comment - outcome: *outcome - - - description: "UpdateOne with comment - pre 4.4" - runOnRequirements: - - minServerVersion: "3.4.0" - maxServerVersion: "4.2.99" - operations: - - name: updateOne - object: *collection0 - arguments: - filter: *filter - update: *update - comment: "comment" - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter - u: *update - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - comment: "comment" - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-dots_and_dollars.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-dots_and_dollars.yml deleted file mode 100644 index 9ff8a38d736..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateOne-dots_and_dollars.yml +++ /dev/null @@ -1,138 +0,0 @@ -description: "updateOne-dots_and_dollars" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {} } - -tests: - - description: "Updating document to set top-level dollar-prefixed key on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: updateOne - object: *collection0 - arguments: - filter: { _id: 1 } - update: &dollarPrefixedKey - - { $replaceWith: { $setField: { field: { $literal: $a }, value: 1, input: $$ROOT } } } - expectResult: &updateResult - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dollarPrefixedKey - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {}, $a: 1 } - - - description: "Updating document to set top-level dotted key on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: updateOne - object: *collection0 - arguments: - filter: { _id: 1 } - update: &dottedKey - - { $replaceWith: { $setField: { field: { $literal: a.b }, value: 1, input: $$ROOT } } } - expectResult: *updateResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dottedKey - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: {}, a.b: 1 } - - - description: "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: updateOne - object: *collection0 - arguments: - filter: { _id: 1 } - update: &dollarPrefixedKeyInEmbedded - - { $set: { foo: { $setField: { field: { $literal: $a }, value: 1, input: $foo } } } } - expectResult: *updateResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dollarPrefixedKeyInEmbedded - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: { $a: 1 } } - - - description: "Updating document to set dotted key in embedded doc on 5.0+ server" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: updateOne - object: *collection0 - arguments: - filter: { _id: 1 } - update: &dottedKeyInEmbedded - - { $set: { foo: { $setField: { field: { $literal: a.b }, value: 1, input: $foo } } } } - expectResult: *updateResult - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: 1 } - u: *dottedKeyInEmbedded - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, foo: { a.b: 1 } } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-errorResponse.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-errorResponse.yml deleted file mode 100644 index 6d42195b0bc..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateOne-errorResponse.yml +++ /dev/null @@ -1,47 +0,0 @@ -description: "updateOne-errorResponse" - -schemaVersion: "1.12" - -createEntities: - - client: - id: &client0 client0 - useMultipleMongoses: false - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name test - -tests: - # Some drivers may still need to skip this test because the CRUD spec does not - # prescribe how drivers should formulate a WriteException beyond collecting a - # write or write concern error. - - description: "update operations support errorResponse assertions" - runOnRequirements: - - minServerVersion: "4.0.0" - topologies: [ single, replicaset ] - - minServerVersion: "4.2.0" - topologies: [ sharded ] - operations: - - name: failPoint - object: testRunner - arguments: - client: *client0 - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: [ update ] - errorCode: &errorCode 8 # UnknownError - - name: updateOne - object: *collection0 - arguments: - filter: { _id: 1 } - update: { $set: { x: 1 } } - expectError: - errorCode: *errorCode - errorResponse: - code: *errorCode diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-clientError.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-clientError.yml deleted file mode 100644 index 5107b5f4b50..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-clientError.yml +++ /dev/null @@ -1,82 +0,0 @@ -description: updateOne-hint-clientError -schemaVersion: '1.0' -runOnRequirements: - - - maxServerVersion: 3.3.99 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_updateone_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'UpdateOne with hint string unsupported (client-side error)' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: &filter - _id: - $gt: 1 - update: &update - $inc: - x: 1 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - description: 'UpdateOne with hint document unsupported (client-side error)' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: *filter - update: *update - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: [] - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-serverError.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-serverError.yml deleted file mode 100644 index f9681ab8257..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-serverError.yml +++ /dev/null @@ -1,106 +0,0 @@ -description: updateOne-hint-serverError -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 3.4.0 - maxServerVersion: 4.1.9 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_updateone_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'UpdateOne with hint string unsupported (server-side error)' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: &filter - _id: - $gt: 1 - update: &update - $inc: - x: 1 - hint: _id_ - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *filter - u: *update - hint: _id_ - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 - - - description: 'UpdateOne with hint document unsupported (server-side error)' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: *filter - update: *update - hint: - _id: 1 - expectError: - isError: true - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *filter - u: *update - hint: - _id: 1 - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-unacknowledged.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-unacknowledged.yml deleted file mode 100644 index 77802db0012..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint-unacknowledged.yml +++ /dev/null @@ -1,95 +0,0 @@ -description: updateOne-hint-unacknowledged - -schemaVersion: '1.0' - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name db0 - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - collectionOptions: - writeConcern: { w: 0 } - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: &documents - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - -tests: - - description: "Unacknowledged updateOne with hint string fails with client-side error on pre-4.2 server" - runOnRequirements: - - maxServerVersion: "4.0.99" - operations: - - object: *collection0 - name: updateOne - arguments: - filter: &filter { _id: { $gt: 1 } } - update: &update { $inc: { x: 1 } } - hint: _id_ - expectError: - isClientError: true - expectEvents: &noEvents - - client: *client0 - events: [] - - - description: "Unacknowledged updateOne with hint document fails with client-side error on pre-4.2 server" - runOnRequirements: - - maxServerVersion: "4.0.99" - operations: - - object: *collection0 - name: updateOne - arguments: - filter: *filter - update: *update - hint: { _id: 1 } - expectError: - isClientError: true - expectEvents: *noEvents - - - description: "Unacknowledged updateOne with hint string on 4.2+ server" - runOnRequirements: - - minServerVersion: "4.2.0" - operations: - - object: *collection0 - name: updateOne - arguments: - filter: *filter - update: *update - hint: _id_ - expectResult: &unacknowledgedResult { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } - expectEvents: &events - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: *filter - u: *update - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - hint: { $$type: [ string, object ]} - writeConcern: { w: 0 } - - - description: "Unacknowledged updateOne with hint document on 4.2+ server" - runOnRequirements: - - minServerVersion: "4.2.0" - operations: - - object: *collection0 - name: updateOne - arguments: - filter: *filter - update: *update - hint: { _id: 1 } - expectResult: *unacknowledgedResult - expectEvents: *events diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint.yml deleted file mode 100644 index bd60cd7a199..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateOne-hint.yml +++ /dev/null @@ -1,106 +0,0 @@ -description: updateOne-hint -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.2.0 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v2 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test_updateone_hint -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 22 -tests: - - - description: 'UpdateOne with hint string' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: &filter - _id: - $gt: 1 - update: &update - $inc: - x: 1 - hint: _id_ - expectResult: &result - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *filter - u: *update - hint: _id_ - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: &outcome - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 11 - - - _id: 2 - x: 23 - - - description: 'UpdateOne with hint document' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: *filter - update: *update - hint: - _id: 1 - expectResult: *result - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: *filter - u: *update - hint: - _id: 1 - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: *outcome diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-let.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-let.yml deleted file mode 100644 index 0044fdac66d..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateOne-let.yml +++ /dev/null @@ -1,102 +0,0 @@ -description: "updateOne-let" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } - -tests: - - description: "UpdateOne with let option" - runOnRequirements: - - minServerVersion: "5.0" - operations: - - name: updateOne - object: *collection0 - arguments: - filter: &filter - $expr: - $eq: [ "$_id", "$$id" ] - update: &update - - $set: {x: "$$x" } - let: &let0 - id: 1 - x: "foo" - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter - u: *update - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - let: *let0 - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: "foo" } - - { _id: 2 } - - - description: "UpdateOne with let option unsupported (server-side error)" - runOnRequirements: - - minServerVersion: "4.2.0" - maxServerVersion: "4.4.99" - operations: - - name: updateOne - object: *collection0 - arguments: - filter: &filter1 - _id: 1 - update: &update1 - - $set: {x: "$$x"} - let: &let1 - x: foo - expectError: - errorContains: "'update.let' is an unknown field" - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - - q: *filter1 - u: *update1 - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - let: *let1 - outcome: - - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1 } - - { _id: 2 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-sort.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-sort.yml deleted file mode 100644 index a14e1df1d2b..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateOne-sort.yml +++ /dev/null @@ -1,96 +0,0 @@ -description: updateOne-sort - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - commandSucceededEvent - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - description: UpdateOne with sort option - runOnRequirements: - - minServerVersion: "8.0" - operations: - - name: updateOne - object: *collection0 - arguments: - filter: { _id: { $gt: 1 } } - sort: { _id: -1 } - update: { $inc: { x: 1 } } - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: { $gt: 1 } } - u: { $inc: { x: 1 } } - sort: { _id: -1 } - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - - commandSucceededEvent: - reply: { ok: 1, n: 1 } - commandName: update - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 34 } - - - description: updateOne with sort option unsupported (server-side error) - runOnRequirements: - - maxServerVersion: "7.99" - operations: - - name: updateOne - object: *collection0 - arguments: - filter: { _id: { $gt: 1 } } - sort: { _id: -1 } - update: { $inc: { x: 1 } } - expectError: - isClientError: false - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - update: *collection0Name - updates: - - q: { _id: { $gt: 1 } } - u: { $inc: { x: 1 } } - sort: { _id: -1 } - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - outcome: - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne-validation.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne-validation.yml deleted file mode 100644 index b6f49a65683..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateOne-validation.yml +++ /dev/null @@ -1,37 +0,0 @@ -description: "updateOne-validation" - -schemaVersion: "1.0" - -createEntities: - - client: - id: &client0 client0 - observeEvents: [ commandStartedEvent ] - - database: - id: &database0 database0 - client: *client0 - databaseName: &database0Name crud-tests - - collection: - id: &collection0 collection0 - database: *database0 - collectionName: &collection0Name coll0 - -initialData: &initialData - - collectionName: *collection0Name - databaseName: *database0Name - documents: - - { _id: 1, x: 11 } - -tests: - - description: "UpdateOne requires atomic modifiers" - operations: - - name: updateOne - object: *collection0 - arguments: - filter: { _id: 1 } - update: { x: 22 } - expectError: - isClientError: true - expectEvents: - - client: *client0 - events: [] - outcome: *initialData diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateOne.yml b/driver-core/src/test/resources/unified-test-format/crud/updateOne.yml deleted file mode 100644 index 2f8f6a91815..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateOne.yml +++ /dev/null @@ -1,114 +0,0 @@ -description: updateOne - -schemaVersion: '1.0' - -runOnRequirements: - - - minServerVersion: '2.6' - -createEntities: - - - client: - id: &client0 client0 - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-v1 - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name coll - -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - -tests: - - - # This test doesn't verify the output collection because we cannot assume - # which document gets updated. - description: 'UpdateOne when many documents match' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: { _id: { $gt: 1 } } - update: { $inc: { x: 1 } } - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - - - description: 'UpdateOne when one document matches' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: { _id: 1 } - update: { $inc: { x: 1 } } - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 12 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - - description: 'UpdateOne when no documents match' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: { _id: 4 } - update: { $inc: { x: 1 } } - expectResult: - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - - description: 'UpdateOne with upsert when no documents match' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: { _id: 4 } - update: { $inc: { x: 1 } } - upsert: true - expectResult: - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 1 - upsertedId: 4 - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - { _id: 1, x: 11 } - - { _id: 2, x: 22 } - - { _id: 3, x: 33 } - - { _id: 4, x: 1 } diff --git a/driver-core/src/test/resources/unified-test-format/crud/updateWithPipelines.yml b/driver-core/src/test/resources/unified-test-format/crud/updateWithPipelines.yml deleted file mode 100644 index e0b580c0ef7..00000000000 --- a/driver-core/src/test/resources/unified-test-format/crud/updateWithPipelines.yml +++ /dev/null @@ -1,296 +0,0 @@ -description: updateWithPipelines -schemaVersion: '1.0' -runOnRequirements: - - - minServerVersion: 4.1.11 -createEntities: - - - client: - id: &client0 client0 - observeEvents: - - commandStartedEvent - - - database: - id: &database0 database0 - client: client0 - databaseName: &database_name crud-tests - - - collection: - id: &collection0 collection0 - database: database0 - collectionName: &collection_name test -initialData: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 1 - 'y': 1 - t: - u: - v: 1 - - - _id: 2 - x: 2 - 'y': 1 -tests: - - - description: 'UpdateOne using pipelines' - operations: - - - object: *collection0 - name: updateOne - arguments: - filter: - _id: 1 - update: - - - $replaceRoot: - newRoot: $t - - - $addFields: - foo: 1 - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: - _id: 1 - u: - - { $replaceRoot: { newRoot: $t } } - - { $addFields: { foo: 1 } } - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - commandName: update - databaseName: *database_name - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - u: - v: 1 - foo: 1 - - - _id: 2 - x: 2 - 'y': 1 - - - description: 'UpdateMany using pipelines' - operations: - - - object: *collection0 - name: updateMany - arguments: - filter: { } - update: - - - $project: - x: 1 - - - $addFields: - foo: 1 - expectResult: - matchedCount: 2 - modifiedCount: 2 - upsertedCount: 0 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: { } - u: - - { $project: { x: 1 } } - - { $addFields: { foo: 1 } } - multi: true - upsert: { $$unsetOrMatches: false } - commandName: update - databaseName: *database_name - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 1 - foo: 1 - - - _id: 2 - x: 2 - foo: 1 - - - description: 'FindOneAndUpdate using pipelines' - operations: - - - object: *collection0 - name: findOneAndUpdate - arguments: - filter: - _id: 1 - update: - - - $project: - x: 1 - - - $addFields: - foo: 1 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - findAndModify: *collection_name - update: - - - $project: - x: 1 - - - $addFields: - foo: 1 - commandName: findAndModify - databaseName: *database_name - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 1 - foo: 1 - - - _id: 2 - x: 2 - 'y': 1 - - - description: 'UpdateOne in bulk write using pipelines' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - updateOne: - filter: - _id: 1 - update: - - - $replaceRoot: - newRoot: $t - - - $addFields: - foo: 1 - expectResult: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: - _id: 1 - u: - - { $replaceRoot: { newRoot: $t } } - - { $addFields: { foo: 1 } } - multi: { $$unsetOrMatches: false } - upsert: { $$unsetOrMatches: false } - commandName: update - databaseName: *database_name - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - u: - v: 1 - foo: 1 - - - _id: 2 - x: 2 - 'y': 1 - - - description: 'UpdateMany in bulk write using pipelines' - operations: - - - object: *collection0 - name: bulkWrite - arguments: - requests: - - - updateMany: - filter: { } - update: - - - $project: - x: 1 - - - $addFields: - foo: 1 - expectResult: - matchedCount: 2 - modifiedCount: 2 - upsertedCount: 0 - expectEvents: - - - client: *client0 - events: - - - commandStartedEvent: - command: - update: *collection_name - updates: - - - q: { } - u: - - { $project: { x: 1 } } - - { $addFields: { foo: 1 } } - multi: true - upsert: { $$unsetOrMatches: false } - commandName: update - databaseName: *database_name - outcome: - - - collectionName: *collection_name - databaseName: *database_name - documents: - - - _id: 1 - x: 1 - foo: 1 - - - _id: 2 - x: 2 - foo: 1 From 5e1b984093b686ca0594df9ee761e4b671a947e0 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Wed, 30 Oct 2024 15:28:56 +0000 Subject: [PATCH 4/7] PR feedback --- .../crud/bulkWrite-comment.json | 30 +++++++++++++++++-- .../client/unified/UnifiedCrudTest.java | 14 +++++---- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.json b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.json index 0b2addc8505..d88ffb7a33e 100644 --- a/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.json +++ b/driver-core/src/test/resources/unified-test-format/crud/bulkWrite-comment.json @@ -122,6 +122,7 @@ "expectEvents": [ { "client": "client0", + "note": "Events split due to : JAVA-4537 ", "events": [ { "commandStartedEvent": { @@ -157,7 +158,18 @@ "upsert": { "$$unsetOrMatches": false } - }, + } + ], + "ordered": true, + "comment": "comment" + } + } + }, + { + "commandStartedEvent": { + "command": { + "update": "BulkWrite_comment", + "updates": [ { "q": { "_id": 2 @@ -299,6 +311,7 @@ "expectEvents": [ { "client": "client0", + "note": "Events split due to : JAVA-4537 ", "events": [ { "commandStartedEvent": { @@ -336,7 +349,20 @@ "upsert": { "$$unsetOrMatches": false } - }, + } + ], + "ordered": true, + "comment": { + "key": "value" + } + } + } + }, + { + "commandStartedEvent": { + "command": { + "update": "BulkWrite_comment", + "updates": [ { "q": { "_id": 2 diff --git a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java index 6fe33fcdbc5..51df5d98b56 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java @@ -43,12 +43,14 @@ public static void doSkips(final String fileDescription, final String testDescri assumeFalse(testDescription.equals("Aggregate with $out includes read preference for 5.0+ server")); assumeFalse(testDescription.equals("Database-level aggregate with $out includes read preference for 5.0+ server")); } - assumeFalse(testDescription.toLowerCase().contains("updateone with sort option"), "Skipping until JAVA-5622 is implemented"); - assumeFalse(testDescription.toLowerCase().contains("replaceone with sort option"), "Skipping until JAVA-5622 is implemented"); - assumeFalse(testDescription.equals("BulkWrite with string comment"), "Skipping until we decide " - + "whether to update the spec or test https://mongodb.slack.com/archives/C72LB5RPV/p1730225657999979"); - assumeFalse(testDescription.equals("BulkWrite with document comment"), "Skipping until we decide " - + "whether to update the spec or test https://mongodb.slack.com/archives/C72LB5RPV/p1730225657999979"); + assumeFalse(fileDescription.equals("updateOne-sort") && testDescription.equals("updateOne with sort option unsupported " + + "(server-side error)")); + assumeFalse(fileDescription.equals("replaceOne-sort") && testDescription.equals("replaceOne with sort option unsupported " + + "(server-side error)")); + assumeFalse(fileDescription.equals("BulkWrite updateOne-sort") && testDescription.equals( + "BulkWrite updateOne with sort option unsupported (server-side error)")); + assumeFalse(fileDescription.equals("BulkWrite replaceOne-sort") && testDescription.equals( + "BulkWrite replaceOne with sort option unsupported (server-side error)")); } @Override From 0fbdaed3ce340fa82d7eb7a679c42183801f377e Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Wed, 30 Oct 2024 16:23:32 +0000 Subject: [PATCH 5/7] Skipping more tests by file description --- .../client/unified/UnifiedCrudTest.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java index 51df5d98b56..627fe5b104e 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java @@ -43,14 +43,22 @@ public static void doSkips(final String fileDescription, final String testDescri assumeFalse(testDescription.equals("Aggregate with $out includes read preference for 5.0+ server")); assumeFalse(testDescription.equals("Database-level aggregate with $out includes read preference for 5.0+ server")); } - assumeFalse(fileDescription.equals("updateOne-sort") && testDescription.equals("updateOne with sort option unsupported " - + "(server-side error)")); - assumeFalse(fileDescription.equals("replaceOne-sort") && testDescription.equals("replaceOne with sort option unsupported " - + "(server-side error)")); - assumeFalse(fileDescription.equals("BulkWrite updateOne-sort") && testDescription.equals( - "BulkWrite updateOne with sort option unsupported (server-side error)")); - assumeFalse(fileDescription.equals("BulkWrite replaceOne-sort") && testDescription.equals( - "BulkWrite replaceOne with sort option unsupported (server-side error)")); + if (fileDescription.equals("updateOne-sort")) { + assumeFalse(testDescription.equals("updateOne with sort option")); + assumeFalse(testDescription.equals("updateOne with sort option unsupported (server-side error)")); + } + if (fileDescription.equals("replaceOne-sort")) { + assumeFalse(testDescription.equals("replaceOne with sort option")); + assumeFalse(testDescription.equals("replaceOne with sort option unsupported (server-side error)")); + } + if (fileDescription.equals("BulkWrite updateOne-sort")) { + assumeFalse(testDescription.equals("BulkWrite updateOne with sort option")); + assumeFalse(testDescription.equals("BulkWrite updateOne with sort option unsupported (server-side error)")); + } + if (fileDescription.equals("BulkWrite replaceOne-sort")) { + assumeFalse(testDescription.equals("BulkWrite replaceOne with sort option")); + assumeFalse(testDescription.equals("BulkWrite replaceOne with sort option unsupported (server-side error)")); + } } @Override From 7cbaceecebb4b506efc9bac851c04486fd64355c Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Wed, 30 Oct 2024 16:46:50 +0000 Subject: [PATCH 6/7] Fixing typo in test description --- .../com/mongodb/client/unified/UnifiedCrudTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java index 627fe5b104e..50fc0b52452 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java @@ -44,11 +44,11 @@ public static void doSkips(final String fileDescription, final String testDescri assumeFalse(testDescription.equals("Database-level aggregate with $out includes read preference for 5.0+ server")); } if (fileDescription.equals("updateOne-sort")) { - assumeFalse(testDescription.equals("updateOne with sort option")); + assumeFalse(testDescription.equals("UpdateOne with sort option")); assumeFalse(testDescription.equals("updateOne with sort option unsupported (server-side error)")); } if (fileDescription.equals("replaceOne-sort")) { - assumeFalse(testDescription.equals("replaceOne with sort option")); + assumeFalse(testDescription.equals("ReplaceOne with sort option")); assumeFalse(testDescription.equals("replaceOne with sort option unsupported (server-side error)")); } if (fileDescription.equals("BulkWrite updateOne-sort")) { From d89aa2847ace09ba030b4844f809e9497f33c616 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Wed, 30 Oct 2024 20:57:24 +0000 Subject: [PATCH 7/7] Adding skip message reason --- .../mongodb/client/unified/UnifiedCrudTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java index 50fc0b52452..22c5a5e3807 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudTest.java @@ -44,20 +44,20 @@ public static void doSkips(final String fileDescription, final String testDescri assumeFalse(testDescription.equals("Database-level aggregate with $out includes read preference for 5.0+ server")); } if (fileDescription.equals("updateOne-sort")) { - assumeFalse(testDescription.equals("UpdateOne with sort option")); - assumeFalse(testDescription.equals("updateOne with sort option unsupported (server-side error)")); + assumeFalse(testDescription.equals("UpdateOne with sort option"), "Skipping until JAVA-5622 is implemented"); + assumeFalse(testDescription.equals("updateOne with sort option unsupported (server-side error)"), "Skipping until JAVA-5622 is implemented"); } if (fileDescription.equals("replaceOne-sort")) { - assumeFalse(testDescription.equals("ReplaceOne with sort option")); - assumeFalse(testDescription.equals("replaceOne with sort option unsupported (server-side error)")); + assumeFalse(testDescription.equals("ReplaceOne with sort option"), "Skipping until JAVA-5622 is implemented"); + assumeFalse(testDescription.equals("replaceOne with sort option unsupported (server-side error)"), "Skipping until JAVA-5622 is implemented"); } if (fileDescription.equals("BulkWrite updateOne-sort")) { - assumeFalse(testDescription.equals("BulkWrite updateOne with sort option")); - assumeFalse(testDescription.equals("BulkWrite updateOne with sort option unsupported (server-side error)")); + assumeFalse(testDescription.equals("BulkWrite updateOne with sort option"), "Skipping until JAVA-5622 is implemented"); + assumeFalse(testDescription.equals("BulkWrite updateOne with sort option unsupported (server-side error)"), "Skipping until JAVA-5622 is implemented"); } if (fileDescription.equals("BulkWrite replaceOne-sort")) { - assumeFalse(testDescription.equals("BulkWrite replaceOne with sort option")); - assumeFalse(testDescription.equals("BulkWrite replaceOne with sort option unsupported (server-side error)")); + assumeFalse(testDescription.equals("BulkWrite replaceOne with sort option"), "Skipping until JAVA-5622 is implemented"); + assumeFalse(testDescription.equals("BulkWrite replaceOne with sort option unsupported (server-side error)"), "Skipping until JAVA-5622 is implemented"); } }