{ "description": "client bulkWrite top-level options", "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "8.0", "serverless": "forbid" } ], "createEntities": [ { "client": { "id": "client0", "observeEvents": [ "commandStartedEvent" ] } }, { "client": { "id": "writeConcernClient", "uriOptions": { "w": 1 }, "observeEvents": [ "commandStartedEvent" ] } }, { "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 } ] } ], "_yamlAnchors": { "namespace": "crud-tests.coll0", "comment": { "bulk": "write" }, "let": { "id1": 1, "id2": 2 }, "writeConcern": { "w": "majority" } }, "tests": [ { "description": "client bulkWrite comment", "operations": [ { "object": "client0", "name": "clientBulkWrite", "arguments": { "models": [ { "insertOne": { "namespace": "crud-tests.coll0", "document": { "_id": 3, "x": 33 } } } ], "comment": { "bulk": "write" }, "verboseResults": true }, "expectResult": { "insertedCount": 1, "upsertedCount": 0, "matchedCount": 0, "modifiedCount": 0, "deletedCount": 0, "insertResults": { "0": { "insertedId": 3 } }, "updateResults": {}, "deleteResults": {} } } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "commandName": "bulkWrite", "databaseName": "admin", "command": { "bulkWrite": 1, "errorsOnly": false, "ordered": true, "comment": { "bulk": "write" }, "ops": [ { "insert": 0, "document": { "_id": 3, "x": 33 } } ], "nsInfo": [ { "ns": "crud-tests.coll0" } ] } } } ] } ], "outcome": [ { "collectionName": "coll0", "databaseName": "crud-tests", "documents": [ { "_id": 1, "x": 11 }, { "_id": 2, "x": 22 }, { "_id": 3, "x": 33 } ] } ] }, { "description": "client bulkWrite bypassDocumentValidation", "operations": [ { "object": "client0", "name": "clientBulkWrite", "arguments": { "models": [ { "insertOne": { "namespace": "crud-tests.coll0", "document": { "_id": 3, "x": 33 } } } ], "bypassDocumentValidation": true, "verboseResults": true }, "expectResult": { "insertedCount": 1, "upsertedCount": 0, "matchedCount": 0, "modifiedCount": 0, "deletedCount": 0, "insertResults": { "0": { "insertedId": 3 } }, "updateResults": {}, "deleteResults": {} } } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "commandName": "bulkWrite", "databaseName": "admin", "command": { "bulkWrite": 1, "errorsOnly": false, "ordered": true, "bypassDocumentValidation": true, "ops": [ { "insert": 0, "document": { "_id": 3, "x": 33 } } ], "nsInfo": [ { "ns": "crud-tests.coll0" } ] } } } ] } ], "outcome": [ { "collectionName": "coll0", "databaseName": "crud-tests", "documents": [ { "_id": 1, "x": 11 }, { "_id": 2, "x": 22 }, { "_id": 3, "x": 33 } ] } ] }, { "description": "client bulkWrite let", "operations": [ { "object": "client0", "name": "clientBulkWrite", "arguments": { "models": [ { "updateOne": { "namespace": "crud-tests.coll0", "filter": { "$expr": { "$eq": [ "$_id", "$$id1" ] } }, "update": { "$inc": { "x": 1 } } } }, { "deleteOne": { "namespace": "crud-tests.coll0", "filter": { "$expr": { "$eq": [ "$_id", "$$id2" ] } } } } ], "let": { "id1": 1, "id2": 2 }, "verboseResults": true }, "expectResult": { "insertedCount": 0, "upsertedCount": 0, "matchedCount": 1, "modifiedCount": 1, "deletedCount": 1, "insertResults": {}, "updateResults": { "0": { "matchedCount": 1, "modifiedCount": 1, "upsertedId": { "$$exists": false } } }, "deleteResults": { "1": { "deletedCount": 1 } } } } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "commandName": "bulkWrite", "databaseName": "admin", "command": { "bulkWrite": 1, "errorsOnly": false, "ordered": true, "let": { "id1": 1, "id2": 2 }, "ops": [ { "update": 0, "filter": { "$expr": { "$eq": [ "$_id", "$$id1" ] } }, "updateMods": { "$inc": { "x": 1 } }, "multi": false }, { "delete": 0, "filter": { "$expr": { "$eq": [ "$_id", "$$id2" ] } }, "multi": false } ], "nsInfo": [ { "ns": "crud-tests.coll0" } ] } } } ] } ], "outcome": [ { "databaseName": "crud-tests", "collectionName": "coll0", "documents": [ { "_id": 1, "x": 12 } ] } ] }, { "description": "client bulkWrite bypassDocumentValidation: false is sent", "operations": [ { "object": "client0", "name": "clientBulkWrite", "arguments": { "models": [ { "insertOne": { "namespace": "crud-tests.coll0", "document": { "_id": 3, "x": 33 } } } ], "bypassDocumentValidation": false, "verboseResults": true }, "expectResult": { "insertedCount": 1, "upsertedCount": 0, "matchedCount": 0, "modifiedCount": 0, "deletedCount": 0, "insertResults": { "0": { "insertedId": 3 } }, "updateResults": {}, "deleteResults": {} } } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "commandName": "bulkWrite", "databaseName": "admin", "command": { "bulkWrite": 1, "errorsOnly": false, "ordered": true, "bypassDocumentValidation": false, "ops": [ { "insert": 0, "document": { "_id": 3, "x": 33 } } ], "nsInfo": [ { "ns": "crud-tests.coll0" } ] } } } ] } ], "outcome": [ { "collectionName": "coll0", "databaseName": "crud-tests", "documents": [ { "_id": 1, "x": 11 }, { "_id": 2, "x": 22 }, { "_id": 3, "x": 33 } ] } ] }, { "description": "client bulkWrite writeConcern", "operations": [ { "object": "client0", "name": "clientBulkWrite", "arguments": { "models": [ { "insertOne": { "namespace": "crud-tests.coll0", "document": { "_id": 3, "x": 33 } } } ], "writeConcern": { "w": "majority" }, "verboseResults": true }, "expectResult": { "insertedCount": 1, "upsertedCount": 0, "matchedCount": 0, "modifiedCount": 0, "deletedCount": 0, "insertResults": { "0": { "insertedId": 3 } }, "updateResults": {}, "deleteResults": {} } } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "commandName": "bulkWrite", "databaseName": "admin", "command": { "bulkWrite": 1, "errorsOnly": false, "ordered": true, "writeConcern": { "w": "majority" }, "ops": [ { "insert": 0, "document": { "_id": 3, "x": 33 } } ], "nsInfo": [ { "ns": "crud-tests.coll0" } ] } } } ] } ] }, { "description": "client bulkWrite inherits writeConcern from client", "operations": [ { "object": "writeConcernClient", "name": "clientBulkWrite", "arguments": { "models": [ { "insertOne": { "namespace": "crud-tests.coll0", "document": { "_id": 3, "x": 33 } } } ], "verboseResults": true }, "expectResult": { "insertedCount": 1, "upsertedCount": 0, "matchedCount": 0, "modifiedCount": 0, "deletedCount": 0, "insertResults": { "0": { "insertedId": 3 } }, "updateResults": {}, "deleteResults": {} } } ], "expectEvents": [ { "client": "writeConcernClient", "events": [ { "commandStartedEvent": { "commandName": "bulkWrite", "databaseName": "admin", "command": { "bulkWrite": 1, "errorsOnly": false, "ordered": true, "writeConcern": { "w": 1 }, "ops": [ { "insert": 0, "document": { "_id": 3, "x": 33 } } ], "nsInfo": [ { "ns": "crud-tests.coll0" } ] } } } ] } ] }, { "description": "client bulkWrite writeConcern option overrides client writeConcern", "operations": [ { "object": "writeConcernClient", "name": "clientBulkWrite", "arguments": { "models": [ { "insertOne": { "namespace": "crud-tests.coll0", "document": { "_id": 3, "x": 33 } } } ], "writeConcern": { "w": "majority" }, "verboseResults": true }, "expectResult": { "insertedCount": 1, "upsertedCount": 0, "matchedCount": 0, "modifiedCount": 0, "deletedCount": 0, "insertResults": { "0": { "insertedId": 3 } }, "updateResults": {}, "deleteResults": {} } } ], "expectEvents": [ { "client": "writeConcernClient", "events": [ { "commandStartedEvent": { "commandName": "bulkWrite", "databaseName": "admin", "command": { "bulkWrite": 1, "errorsOnly": false, "ordered": true, "writeConcern": { "w": "majority" }, "ops": [ { "insert": 0, "document": { "_id": 3, "x": 33 } } ], "nsInfo": [ { "ns": "crud-tests.coll0" } ] } } } ] } ] } ] }