diff --git a/source/crud/tests/unified/bulkWrite-updateMany-pipeline.json b/source/crud/tests/unified/bulkWrite-updateMany-pipeline.json new file mode 100644 index 0000000000..6c8fab4608 --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-updateMany-pipeline.json @@ -0,0 +1,198 @@ +{ + "description": "bulkWrite-updateMany-pipeline", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "minServerVersion": "4.1.11" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 1, + "y": 1, + "t": { + "u": { + "v": 1 + } + } + }, + { + "_id": 2, + "x": 2, + "y": 1 + } + ] + } + ], + "tests": [ + { + "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": "test", + "updates": [ + { + "q": {}, + "u": [ + { + "$project": { + "x": 1 + } + }, + { + "$addFields": { + "foo": 1 + } + } + ], + "multi": true, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + }, + "commandName": "update", + "databaseName": "crud-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 1, + "foo": 1 + }, + { + "_id": 2, + "x": 2, + "foo": 1 + } + ] + } + ] + }, + { + "description": "UpdateMany in bulk write using empty pipeline", + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "updateMany": { + "filter": {}, + "update": [] + } + } + ] + }, + "expectResult": { + "matchedCount": 2, + "modifiedCount": 0, + "upsertedCount": 0 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": {}, + "u": [], + "multi": true, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + }, + "commandName": "update", + "databaseName": "crud-tests" + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/bulkWrite-updateMany-pipeline.yml b/source/crud/tests/unified/bulkWrite-updateMany-pipeline.yml new file mode 100644 index 0000000000..726c581f50 --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-updateMany-pipeline.yml @@ -0,0 +1,94 @@ +description: bulkWrite-updateMany-pipeline + +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: '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 } + - + description: 'UpdateMany in bulk write using empty pipeline' + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateMany: + filter: { } + update: [] + expectResult: + matchedCount: 2 + modifiedCount: 0 + upsertedCount: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection_name + updates: + - q: { } + u: [] + multi: true + upsert: { $$unsetOrMatches: false } + commandName: update + databaseName: *database_name diff --git a/source/crud/tests/unified/bulkWrite-updateOne-pipeline.json b/source/crud/tests/unified/bulkWrite-updateOne-pipeline.json new file mode 100644 index 0000000000..46c131713f --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-updateOne-pipeline.json @@ -0,0 +1,212 @@ +{ + "description": "bulkWrite-updateOne-pipeline", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "minServerVersion": "4.1.11" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 1, + "y": 1, + "t": { + "u": { + "v": 1 + } + } + }, + { + "_id": 2, + "x": 2, + "y": 1 + } + ] + } + ], + "tests": [ + { + "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": "test", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": [ + { + "$replaceRoot": { + "newRoot": "$t" + } + }, + { + "$addFields": { + "foo": 1 + } + } + ], + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + }, + "commandName": "update", + "databaseName": "crud-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "u": { + "v": 1 + }, + "foo": 1 + }, + { + "_id": 2, + "x": 2, + "y": 1 + } + ] + } + ] + }, + { + "description": "UpdateOne in bulk write using empty pipeline", + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "updateOne": { + "filter": { + "_id": 1 + }, + "update": [] + } + } + ] + }, + "expectResult": { + "matchedCount": 1, + "modifiedCount": 0, + "upsertedCount": 0 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": [], + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + }, + "commandName": "update", + "databaseName": "crud-tests" + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/bulkWrite-updateOne-pipeline.yml b/source/crud/tests/unified/bulkWrite-updateOne-pipeline.yml new file mode 100644 index 0000000000..7774dbfc65 --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-updateOne-pipeline.yml @@ -0,0 +1,93 @@ +description: bulkWrite-updateOne-pipeline + +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 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: 'UpdateOne in bulk write using empty pipeline' + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateOne: + filter: { _id: 1 } + update: [] + expectResult: + matchedCount: 1 + modifiedCount: 0 + upsertedCount: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection_name + updates: + - q: { _id: 1 } + u: [] + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + commandName: update + databaseName: *database_name diff --git a/source/crud/tests/unified/findOneAndUpdate-pipeline.json b/source/crud/tests/unified/findOneAndUpdate-pipeline.json new file mode 100644 index 0000000000..036de4274e --- /dev/null +++ b/source/crud/tests/unified/findOneAndUpdate-pipeline.json @@ -0,0 +1,162 @@ +{ + "description": "findOneAndUpdate-pipeline", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "minServerVersion": "4.1.11" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 1, + "y": 1, + "t": { + "u": { + "v": 1 + } + } + }, + { + "_id": 2, + "x": 2, + "y": 1 + } + ] + } + ], + "tests": [ + { + "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": "test", + "update": [ + { + "$project": { + "x": 1 + } + }, + { + "$addFields": { + "foo": 1 + } + } + ] + }, + "commandName": "findAndModify", + "databaseName": "crud-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 1, + "foo": 1 + }, + { + "_id": 2, + "x": 2, + "y": 1 + } + ] + } + ] + }, + { + "description": "FindOneAndUpdate using empty pipeline", + "operations": [ + { + "object": "collection0", + "name": "findOneAndUpdate", + "arguments": { + "filter": { + "_id": 1 + }, + "update": [] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "update": [] + }, + "commandName": "findAndModify", + "databaseName": "crud-tests" + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/findOneAndUpdate-pipeline.yml b/source/crud/tests/unified/findOneAndUpdate-pipeline.yml new file mode 100644 index 0000000000..afa11dd08d --- /dev/null +++ b/source/crud/tests/unified/findOneAndUpdate-pipeline.yml @@ -0,0 +1,73 @@ +description: findOneAndUpdate-pipeline + +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: '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: 'FindOneAndUpdate using empty pipeline' + operations: + - object: *collection0 + name: findOneAndUpdate + arguments: + filter: { _id: 1 } + update: [] + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection_name + update: [] + commandName: findAndModify + databaseName: *database_name diff --git a/source/crud/tests/unified/updateMany-pipeline.json b/source/crud/tests/unified/updateMany-pipeline.json new file mode 100644 index 0000000000..2e09eb88f4 --- /dev/null +++ b/source/crud/tests/unified/updateMany-pipeline.json @@ -0,0 +1,186 @@ +{ + "description": "updateMany-pipeline", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "minServerVersion": "4.1.11" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 1, + "y": 1, + "t": { + "u": { + "v": 1 + } + } + }, + { + "_id": 2, + "x": 2, + "y": 1 + } + ] + } + ], + "tests": [ + { + "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": "test", + "updates": [ + { + "q": {}, + "u": [ + { + "$project": { + "x": 1 + } + }, + { + "$addFields": { + "foo": 1 + } + } + ], + "multi": true, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + }, + "commandName": "update", + "databaseName": "crud-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "x": 1, + "foo": 1 + }, + { + "_id": 2, + "x": 2, + "foo": 1 + } + ] + } + ] + }, + { + "description": "UpdateMany using empty pipeline", + "operations": [ + { + "object": "collection0", + "name": "updateMany", + "arguments": { + "filter": {}, + "update": [] + }, + "expectResult": { + "matchedCount": 2, + "modifiedCount": 0, + "upsertedCount": 0 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": {}, + "u": [], + "multi": true, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + }, + "commandName": "update", + "databaseName": "crud-tests" + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/updateMany-pipeline.yml b/source/crud/tests/unified/updateMany-pipeline.yml new file mode 100644 index 0000000000..3e35f25641 --- /dev/null +++ b/source/crud/tests/unified/updateMany-pipeline.yml @@ -0,0 +1,90 @@ +description: updateMany-pipeline + +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: '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: 'UpdateMany using empty pipeline' + operations: + - object: *collection0 + name: updateMany + arguments: + filter: { } + update: [] + expectResult: + matchedCount: 2 + modifiedCount: 0 + upsertedCount: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection_name + updates: + - q: { } + u: [] + multi: true + upsert: { $$unsetOrMatches: false } + commandName: update + databaseName: *database_name diff --git a/source/crud/tests/unified/updateOne-pipeline.json b/source/crud/tests/unified/updateOne-pipeline.json new file mode 100644 index 0000000000..b3e50727d6 --- /dev/null +++ b/source/crud/tests/unified/updateOne-pipeline.json @@ -0,0 +1,200 @@ +{ + "description": "updateOne-pipeline", + "schemaVersion": "1.0", + "runOnRequirements": [ + { + "minServerVersion": "4.1.11" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "crud-tests", + "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": "test", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": [ + { + "$replaceRoot": { + "newRoot": "$t" + } + }, + { + "$addFields": { + "foo": 1 + } + } + ], + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + }, + "commandName": "update", + "databaseName": "crud-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "crud-tests", + "documents": [ + { + "_id": 1, + "u": { + "v": 1 + }, + "foo": 1 + }, + { + "_id": 2, + "x": 2, + "y": 1 + } + ] + } + ] + }, + { + "description": "UpdateOne using empty pipeline", + "operations": [ + { + "object": "collection0", + "name": "updateOne", + "arguments": { + "filter": { + "_id": 1 + }, + "update": [] + }, + "expectResult": { + "matchedCount": 1, + "modifiedCount": 0, + "upsertedCount": 0 + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": [], + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ] + }, + "commandName": "update", + "databaseName": "crud-tests" + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/updateOne-pipeline.yml b/source/crud/tests/unified/updateOne-pipeline.yml new file mode 100644 index 0000000000..94abb2f21f --- /dev/null +++ b/source/crud/tests/unified/updateOne-pipeline.yml @@ -0,0 +1,89 @@ +description: updateOne-pipeline + +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: 'UpdateOne using empty pipeline' + operations: + - object: *collection0 + name: updateOne + arguments: + filter: { _id: 1 } + update: [] + expectResult: + matchedCount: 1 + modifiedCount: 0 + upsertedCount: 0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection_name + updates: + - q: { _id: 1 } + u: [] + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + commandName: update + databaseName: *database_name diff --git a/source/crud/tests/unified/updateWithPipelines.json b/source/crud/tests/unified/updateWithPipelines.json deleted file mode 100644 index 164f2f6a19..0000000000 --- a/source/crud/tests/unified/updateWithPipelines.json +++ /dev/null @@ -1,494 +0,0 @@ -{ - "description": "updateWithPipelines", - "schemaVersion": "1.0", - "runOnRequirements": [ - { - "minServerVersion": "4.1.11" - } - ], - "createEntities": [ - { - "client": { - "id": "client0", - "observeEvents": [ - "commandStartedEvent" - ] - } - }, - { - "database": { - "id": "database0", - "client": "client0", - "databaseName": "crud-tests" - } - }, - { - "collection": { - "id": "collection0", - "database": "database0", - "collectionName": "test" - } - } - ], - "initialData": [ - { - "collectionName": "test", - "databaseName": "crud-tests", - "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": "test", - "updates": [ - { - "q": { - "_id": 1 - }, - "u": [ - { - "$replaceRoot": { - "newRoot": "$t" - } - }, - { - "$addFields": { - "foo": 1 - } - } - ], - "multi": { - "$$unsetOrMatches": false - }, - "upsert": { - "$$unsetOrMatches": false - } - } - ] - }, - "commandName": "update", - "databaseName": "crud-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "test", - "databaseName": "crud-tests", - "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": "test", - "updates": [ - { - "q": {}, - "u": [ - { - "$project": { - "x": 1 - } - }, - { - "$addFields": { - "foo": 1 - } - } - ], - "multi": true, - "upsert": { - "$$unsetOrMatches": false - } - } - ] - }, - "commandName": "update", - "databaseName": "crud-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "test", - "databaseName": "crud-tests", - "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": "test", - "update": [ - { - "$project": { - "x": 1 - } - }, - { - "$addFields": { - "foo": 1 - } - } - ] - }, - "commandName": "findAndModify", - "databaseName": "crud-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "test", - "databaseName": "crud-tests", - "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": "test", - "updates": [ - { - "q": { - "_id": 1 - }, - "u": [ - { - "$replaceRoot": { - "newRoot": "$t" - } - }, - { - "$addFields": { - "foo": 1 - } - } - ], - "multi": { - "$$unsetOrMatches": false - }, - "upsert": { - "$$unsetOrMatches": false - } - } - ] - }, - "commandName": "update", - "databaseName": "crud-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "test", - "databaseName": "crud-tests", - "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": "test", - "updates": [ - { - "q": {}, - "u": [ - { - "$project": { - "x": 1 - } - }, - { - "$addFields": { - "foo": 1 - } - } - ], - "multi": true, - "upsert": { - "$$unsetOrMatches": false - } - } - ] - }, - "commandName": "update", - "databaseName": "crud-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "test", - "databaseName": "crud-tests", - "documents": [ - { - "_id": 1, - "x": 1, - "foo": 1 - }, - { - "_id": 2, - "x": 2, - "foo": 1 - } - ] - } - ] - } - ] -} diff --git a/source/crud/tests/unified/updateWithPipelines.yml b/source/crud/tests/unified/updateWithPipelines.yml deleted file mode 100644 index e0b580c0ef..0000000000 --- a/source/crud/tests/unified/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