diff --git a/source/crud/tests/unified/client-bulkWrite-delete-options.json b/source/crud/tests/unified/client-bulkWrite-delete-options.json index d9987897dc..26cb3435dd 100644 --- a/source/crud/tests/unified/client-bulkWrite-delete-options.json +++ b/source/crud/tests/unified/client-bulkWrite-delete-options.json @@ -263,6 +263,123 @@ "documents": [] } ] + }, + { + "description": "client bulkWrite delete with non-Int32 hint", + "operations": [ + { + "object": "client0", + "name": "clientBulkWrite", + "arguments": { + "models": [ + { + "deleteOne": { + "namespace": "crud-tests.coll0", + "filter": { + "_id": 1 + }, + "hint": { + "_id": { + "$numberLong": "1" + } + } + } + }, + { + "deleteMany": { + "namespace": "crud-tests.coll0", + "filter": { + "_id": { + "$gt": 1 + } + }, + "hint": { + "_id": { + "$numberLong": "1" + } + } + } + } + ], + "verboseResults": true + }, + "expectResult": { + "insertedCount": 0, + "upsertedCount": 0, + "matchedCount": 0, + "modifiedCount": 0, + "deletedCount": 3, + "insertResults": {}, + "updateResults": {}, + "deleteResults": { + "0": { + "deletedCount": 1 + }, + "1": { + "deletedCount": 2 + } + } + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "commandName": "bulkWrite", + "databaseName": "admin", + "command": { + "bulkWrite": 1, + "errorsOnly": false, + "ordered": true, + "ops": [ + { + "delete": 0, + "filter": { + "_id": 1 + }, + "hint": { + "_id": { + "$numberLong": "1" + } + }, + "multi": false + }, + { + "delete": 0, + "filter": { + "_id": { + "$gt": 1 + } + }, + "hint": { + "_id": { + "$numberLong": "1" + } + }, + "multi": true + } + ], + "nsInfo": [ + { + "ns": "crud-tests.coll0" + } + ] + } + } + } + ] + } + ], + "outcome": [ + { + "databaseName": "crud-tests", + "collectionName": "coll0", + "documents": [] + } + ] } ] } diff --git a/source/crud/tests/unified/client-bulkWrite-delete-options.yml b/source/crud/tests/unified/client-bulkWrite-delete-options.yml index 9297838535..77c29fc65b 100644 --- a/source/crud/tests/unified/client-bulkWrite-delete-options.yml +++ b/source/crud/tests/unified/client-bulkWrite-delete-options.yml @@ -135,3 +135,56 @@ tests: - databaseName: *database0Name collectionName: *collection0Name documents: [] + - description: "client bulkWrite delete with non-Int32 hint" + operations: + - object: *client0 + name: clientBulkWrite + arguments: + models: + - deleteOne: + namespace: *namespace + filter: { _id: 1 } + hint: { _id: { $numberLong: "1" } } + - deleteMany: + namespace: *namespace + filter: { _id: { $gt: 1 } } + hint: { _id: { $numberLong: "1" } } + verboseResults: true + expectResult: + insertedCount: 0 + upsertedCount: 0 + matchedCount: 0 + modifiedCount: 0 + deletedCount: 3 + insertResults: {} + updateResults: {} + deleteResults: + 0: + deletedCount: 1 + 1: + deletedCount: 2 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + commandName: bulkWrite + databaseName: admin + command: + bulkWrite: 1 + errorsOnly: false + ordered: true + ops: + - delete: 0 + filter: { _id: 1 } + hint: { _id: { $numberLong: "1" } } + multi: false + - delete: 0 + filter: { _id: { $gt: 1 } } + hint: { _id: { $numberLong: "1" } } + multi: true + nsInfo: + - ns: *namespace + outcome: + - databaseName: *database0Name + collectionName: *collection0Name + documents: [] diff --git a/source/crud/tests/unified/client-bulkWrite-options.json b/source/crud/tests/unified/client-bulkWrite-options.json index 708fe4e85b..1b17faf446 100644 --- a/source/crud/tests/unified/client-bulkWrite-options.json +++ b/source/crud/tests/unified/client-bulkWrite-options.json @@ -711,6 +711,149 @@ ] } ] + }, + { + "description": "client bulkWrite with unacknowledged write concern (w:0) and ordered:true - expected to return an error", + "runOnRequirements": [ + { + "minServerVersion": "8.0", + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "client0", + "name": "clientBulkWrite", + "arguments": { + "models": [ + { + "insertOne": { + "namespace": "crud-tests.coll0", + "document": { + "_id": 5, + "x": 55 + } + } + }, + { + "insertOne": { + "namespace": "crud-tests.coll0", + "document": { + "_id": 6, + "x": 66 + } + } + } + ], + "verboseResults": false, + "ordered": true, + "writeConcern": { + "w": 0 + } + }, + "expectError": { + "isClientError": true, + "errorContains": "Cannot request unacknowledged write concern and ordered writes" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ] + }, + { + "description": "client bulkWrite with unacknowledged write concern (w:0) for all batches with ordered=false", + "runOnRequirements": [ + { + "minServerVersion": "8.0", + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "client0", + "name": "clientBulkWrite", + "arguments": { + "models": [ + { + "insertOne": { + "namespace": "crud-tests.coll0", + "document": { + "_id": 5, + "x": 55 + } + } + }, + { + "insertOne": { + "namespace": "crud-tests.coll0", + "document": { + "_id": 6, + "x": 66 + } + } + } + ], + "verboseResults": false, + "ordered": false, + "writeConcern": { + "w": 0 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "acknowledged": { + "$$unsetOrMatches": false + } + } + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "commandName": "bulkWrite", + "databaseName": "admin", + "command": { + "bulkWrite": 1, + "errorsOnly": false, + "ordered": false, + "ops": [ + { + "insert": 0, + "document": { + "_id": 5, + "x": 55 + } + }, + { + "insert": 0, + "document": { + "_id": 6, + "x": 66 + } + } + ], + "nsInfo": [ + { + "ns": "crud-tests.coll0" + } + ], + "writeConcern": { + "w": 0 + } + } + } + } + ] + } + ] } ] } diff --git a/source/crud/tests/unified/client-bulkWrite-options.yml b/source/crud/tests/unified/client-bulkWrite-options.yml index e0cbe747b3..080f61a776 100644 --- a/source/crud/tests/unified/client-bulkWrite-options.yml +++ b/source/crud/tests/unified/client-bulkWrite-options.yml @@ -349,3 +349,64 @@ tests: document: { _id: 3, x: 33 } nsInfo: - ns: *namespace + - description: "client bulkWrite with unacknowledged write concern (w:0) and ordered:true should return an error" + runOnRequirements: + - minServerVersion: "8.0" + serverless: forbid + operations: + - object: *client0 + name: clientBulkWrite + arguments: + models: + - insertOne: + namespace: *namespace + document: { _id: 5, x: 55 } + - insertOne: + namespace: *namespace + document: { _id: 6, x: 66 } + verboseResults: false + ordered: true + writeConcern: { w: 0 } + expectError: + isClientError: true + errorContains: "Cannot request unacknowledged write concern and ordered writes" + expectEvents: + - client: *client0 + events: [] + - description: "client bulkWrite with unacknowledged write concern (w:0) for all batches with ordered=false" + runOnRequirements: + - minServerVersion: "8.0" + serverless: forbid + operations: + - object: *client0 + name: clientBulkWrite + arguments: + models: + - insertOne: + namespace: *namespace + document: { _id: 5, x: 55 } + - insertOne: + namespace: *namespace + document: { _id: 6, x: 66 } + verboseResults: false + ordered: false + writeConcern: { w: 0 } + expectResult: { $$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } } } + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + commandName: bulkWrite + databaseName: admin + command: + bulkWrite: 1 + errorsOnly: false + ordered: false + ops: + - insert: 0 + document: { _id: 5, x: 55 } + - insert: 0 + document: { _id: 6, x: 66 } + nsInfo: + - ns: *namespace + writeConcern: { w: 0 } diff --git a/source/crud/tests/unified/client-bulkWrite-update-options.json b/source/crud/tests/unified/client-bulkWrite-update-options.json index ce6241c681..52710d1d6e 100644 --- a/source/crud/tests/unified/client-bulkWrite-update-options.json +++ b/source/crud/tests/unified/client-bulkWrite-update-options.json @@ -944,6 +944,218 @@ ] } ] + }, + { + "description": "client bulkWrite update with non-Int32 hint", + "operations": [ + { + "object": "client0", + "name": "clientBulkWrite", + "arguments": { + "models": [ + { + "updateOne": { + "namespace": "crud-tests.coll0", + "filter": { + "_id": 1 + }, + "update": { + "$set": { + "array": [ + 1, + 2, + 4 + ] + } + }, + "hint": { + "_id": { + "$numberLong": "1" + } + } + } + }, + { + "updateMany": { + "namespace": "crud-tests.coll0", + "filter": { + "$and": [ + { + "_id": { + "$gt": 1 + } + }, + { + "_id": { + "$lte": 3 + } + } + ] + }, + "update": { + "$set": { + "array": [ + 1, + 2, + 5 + ] + } + }, + "hint": { + "_id": { + "$numberLong": "1" + } + } + } + } + ], + "verboseResults": true + }, + "expectResult": { + "insertedCount": 0, + "upsertedCount": 0, + "matchedCount": 3, + "modifiedCount": 3, + "deletedCount": 0, + "insertResults": {}, + "updateResults": { + "0": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedId": { + "$$exists": false + } + }, + "1": { + "matchedCount": 2, + "modifiedCount": 2, + "upsertedId": { + "$$exists": false + } + } + }, + "deleteResults": {} + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "commandName": "bulkWrite", + "databaseName": "admin", + "command": { + "bulkWrite": 1, + "errorsOnly": false, + "ordered": true, + "ops": [ + { + "update": 0, + "filter": { + "_id": 1 + }, + "updateMods": { + "$set": { + "array": [ + 1, + 2, + 4 + ] + } + }, + "hint": { + "_id": { + "$numberLong": "1" + } + }, + "multi": false + }, + { + "update": 0, + "filter": { + "$and": [ + { + "_id": { + "$gt": 1 + } + }, + { + "_id": { + "$lte": 3 + } + } + ] + }, + "updateMods": { + "$set": { + "array": [ + 1, + 2, + 5 + ] + } + }, + "hint": { + "_id": { + "$numberLong": "1" + } + }, + "multi": true + } + ], + "nsInfo": [ + { + "ns": "crud-tests.coll0" + } + ] + } + } + } + ] + } + ], + "outcome": [ + { + "databaseName": "crud-tests", + "collectionName": "coll0", + "documents": [ + { + "_id": 1, + "array": [ + 1, + 2, + 4 + ] + }, + { + "_id": 2, + "array": [ + 1, + 2, + 5 + ] + }, + { + "_id": 3, + "array": [ + 1, + 2, + 5 + ] + }, + { + "_id": 4, + "array": [ + 1, + 2, + 3 + ] + } + ] + } + ] } ] } diff --git a/source/crud/tests/unified/client-bulkWrite-update-options.yml b/source/crud/tests/unified/client-bulkWrite-update-options.yml index c5cc20d480..bb006320d8 100644 --- a/source/crud/tests/unified/client-bulkWrite-update-options.yml +++ b/source/crud/tests/unified/client-bulkWrite-update-options.yml @@ -336,3 +336,70 @@ tests: - { _id: 4, array: [ 1, 2, 3 ] } - { _id: 5, array: [ 1, 2, 4 ] } - { _id: 6, array: [ 1, 2, 6 ] } + - description: "client bulkWrite update with non-Int32 hint" + operations: + - object: *client0 + name: clientBulkWrite + arguments: + models: + - updateOne: + namespace: *namespace + filter: { _id: 1 } + update: { $set: { array: [ 1, 2, 4 ] } } + hint: { _id: { $numberLong: "1" } } + - updateMany: + namespace: *namespace + filter: + $and: [ { _id: { $gt: 1 } }, { _id: { $lte: 3 } } ] + update: { $set: { array: [ 1, 2, 5 ] } } + hint: { _id: { $numberLong: "1" } } + verboseResults: true + expectResult: + insertedCount: 0 + upsertedCount: 0 + matchedCount: 3 + modifiedCount: 3 + deletedCount: 0 + insertResults: {} + updateResults: + 0: + matchedCount: 1 + modifiedCount: 1 + upsertedId: { $$exists: false } + 1: + matchedCount: 2 + modifiedCount: 2 + upsertedId: { $$exists: false } + deleteResults: {} + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + commandName: bulkWrite + databaseName: admin + command: + bulkWrite: 1 + errorsOnly: false + ordered: true + ops: + - update: 0 + filter: { _id: 1 } + updateMods: { $set: { array: [ 1, 2, 4 ] } } + hint: { _id: { $numberLong: "1" } } + multi: false + - update: 0 + filter: + $and: [ { _id: { $gt: 1 } }, { _id: { $lte: 3 } } ] + updateMods: { $set: { array: [ 1, 2, 5 ] } } + hint: { _id: { $numberLong: "1" } } + multi: true + nsInfo: + - ns: *namespace + outcome: + - databaseName: *database0Name + collectionName: *collection0Name + documents: + - { _id: 1, array: [ 1, 2, 4 ] } + - { _id: 2, array: [ 1, 2, 5 ] } + - { _id: 3, array: [ 1, 2, 5 ] } + - { _id: 4, array: [ 1, 2, 3 ] }