From 984fc168fde404b2e5b19dc58f32df3342a6563b Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Fri, 22 Mar 2024 12:21:37 -0400 Subject: [PATCH 1/2] Reformat updateWithPipelines.yml --- .../tests/unified/updateWithPipelines.yml | 219 +++++------------- 1 file changed, 62 insertions(+), 157 deletions(-) diff --git a/source/crud/tests/unified/updateWithPipelines.yml b/source/crud/tests/unified/updateWithPipelines.yml index e0b580c0ef..3331b4e7f5 100644 --- a/source/crud/tests/unified/updateWithPipelines.yml +++ b/source/crud/tests/unified/updateWithPipelines.yml @@ -1,73 +1,54 @@ description: updateWithPipelines + schemaVersion: '1.0' + runOnRequirements: - - - minServerVersion: 4.1.11 + - minServerVersion: 4.1.11 + createEntities: - - - client: + - client: id: &client0 client0 observeEvents: - commandStartedEvent - - - database: + - database: id: &database0 database0 client: client0 databaseName: &database_name crud-tests - - - collection: + - collection: id: &collection0 collection0 database: database0 collectionName: &collection_name test + initialData: - - - collectionName: *collection_name + - collectionName: *collection_name databaseName: *database_name documents: - - - _id: 1 - x: 1 - 'y': 1 - t: - u: - v: 1 - - - _id: 2 - x: 2 - 'y': 1 + - { _id: 1, x: 1, y: 1, t: { u: { v: 1 } } } + - { _id: 2, x: 2, y: 1 } + tests: - description: 'UpdateOne using pipelines' operations: - - - object: *collection0 + - object: *collection0 name: updateOne arguments: - filter: - _id: 1 + filter: { _id: 1 } update: - - - $replaceRoot: - newRoot: $t - - - $addFields: - foo: 1 + - { $replaceRoot: { newRoot: $t } } + - { $addFields: { foo: 1 } } expectResult: matchedCount: 1 modifiedCount: 1 upsertedCount: 0 expectEvents: - - - client: *client0 + - client: *client0 events: - - - commandStartedEvent: + - commandStartedEvent: command: update: *collection_name updates: - - - q: - _id: 1 + - q: { _id: 1 } u: - { $replaceRoot: { newRoot: $t } } - { $addFields: { foo: 1 } } @@ -76,49 +57,33 @@ tests: commandName: update databaseName: *database_name outcome: - - - collectionName: *collection_name + - collectionName: *collection_name databaseName: *database_name documents: - - - _id: 1 - u: - v: 1 - foo: 1 - - - _id: 2 - x: 2 - 'y': 1 + - { _id: 1, u: { v: 1 }, foo: 1 } + - { _id: 2, x: 2, y: 1 } - description: 'UpdateMany using pipelines' operations: - - - object: *collection0 + - object: *collection0 name: updateMany arguments: filter: { } update: - - - $project: - x: 1 - - - $addFields: - foo: 1 + - { $project: { x: 1 } } + - { $addFields: { foo: 1 } } expectResult: matchedCount: 2 modifiedCount: 2 upsertedCount: 0 expectEvents: - - - client: *client0 + - client: *client0 events: - - - commandStartedEvent: + - commandStartedEvent: command: update: *collection_name updates: - - - q: { } + - q: { } u: - { $project: { x: 1 } } - { $addFields: { foo: 1 } } @@ -127,99 +92,62 @@ tests: commandName: update databaseName: *database_name outcome: - - - collectionName: *collection_name + - collectionName: *collection_name databaseName: *database_name documents: - - - _id: 1 - x: 1 - foo: 1 - - - _id: 2 - x: 2 - foo: 1 + - { _id: 1, x: 1, foo: 1 } + - { _id: 2, x: 2, foo: 1 } - description: 'FindOneAndUpdate using pipelines' operations: - - - object: *collection0 + - object: *collection0 name: findOneAndUpdate arguments: - filter: - _id: 1 + filter: { _id: 1 } update: - - - $project: - x: 1 - - - $addFields: - foo: 1 + - { $project: { x: 1 } } + - { $addFields: { foo: 1 } } expectEvents: - - - client: *client0 + - client: *client0 events: - - - commandStartedEvent: + - commandStartedEvent: command: findAndModify: *collection_name update: - - - $project: - x: 1 - - - $addFields: - foo: 1 + - { $project: { x: 1 } } + - { $addFields: { foo: 1 } } commandName: findAndModify databaseName: *database_name outcome: - - - collectionName: *collection_name + - collectionName: *collection_name databaseName: *database_name documents: - - - _id: 1 - x: 1 - foo: 1 - - - _id: 2 - x: 2 - 'y': 1 + - { _id: 1, x: 1, foo: 1 } + - { _id: 2, x: 2, y: 1 } - description: 'UpdateOne in bulk write using pipelines' operations: - - - object: *collection0 + - object: *collection0 name: bulkWrite arguments: requests: - - - updateOne: - filter: - _id: 1 + - updateOne: + filter: { _id: 1 } update: - - - $replaceRoot: - newRoot: $t - - - $addFields: - foo: 1 + - { $replaceRoot: { newRoot: $t } } + - { $addFields: { foo: 1 } } expectResult: matchedCount: 1 modifiedCount: 1 upsertedCount: 0 expectEvents: - - - client: *client0 + - client: *client0 events: - - - commandStartedEvent: + - commandStartedEvent: command: update: *collection_name updates: - - - q: - _id: 1 + - q: { _id: 1 } u: - { $replaceRoot: { newRoot: $t } } - { $addFields: { foo: 1 } } @@ -228,52 +156,35 @@ tests: commandName: update databaseName: *database_name outcome: - - - collectionName: *collection_name + - collectionName: *collection_name databaseName: *database_name documents: - - - _id: 1 - u: - v: 1 - foo: 1 - - - _id: 2 - x: 2 - 'y': 1 + - { _id: 1, u: { v: 1 }, foo: 1 } + - { _id: 2, x: 2, y: 1 } - description: 'UpdateMany in bulk write using pipelines' operations: - - - object: *collection0 + - object: *collection0 name: bulkWrite arguments: requests: - - - updateMany: + - updateMany: filter: { } update: - - - $project: - x: 1 - - - $addFields: - foo: 1 + - { $project: { x: 1 } } + - { $addFields: { foo: 1 } } expectResult: matchedCount: 2 modifiedCount: 2 upsertedCount: 0 expectEvents: - - - client: *client0 + - client: *client0 events: - - - commandStartedEvent: + - commandStartedEvent: command: update: *collection_name updates: - - - q: { } + - q: { } u: - { $project: { x: 1 } } - { $addFields: { foo: 1 } } @@ -286,11 +197,5 @@ tests: collectionName: *collection_name databaseName: *database_name documents: - - - _id: 1 - x: 1 - foo: 1 - - - _id: 2 - x: 2 - foo: 1 + - { _id: 1, x: 1, foo: 1 } + - { _id: 2, x: 2, foo: 1 } From 0ff836840e25497571df7a46be27314dec481f8c Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Fri, 22 Mar 2024 12:22:14 -0400 Subject: [PATCH 2/2] Split updateWithPipelines and add tests for empty pipelines --- .../bulkWrite-updateMany-pipeline.json | 198 +++++++ .../unified/bulkWrite-updateMany-pipeline.yml | 94 ++++ .../unified/bulkWrite-updateOne-pipeline.json | 212 ++++++++ .../unified/bulkWrite-updateOne-pipeline.yml | 93 ++++ .../unified/findOneAndUpdate-pipeline.json | 162 ++++++ .../unified/findOneAndUpdate-pipeline.yml | 73 +++ .../tests/unified/updateMany-pipeline.json | 186 +++++++ .../tests/unified/updateMany-pipeline.yml | 90 ++++ .../tests/unified/updateOne-pipeline.json | 200 +++++++ .../crud/tests/unified/updateOne-pipeline.yml | 89 ++++ .../tests/unified/updateWithPipelines.json | 494 ------------------ .../tests/unified/updateWithPipelines.yml | 201 ------- 12 files changed, 1397 insertions(+), 695 deletions(-) create mode 100644 source/crud/tests/unified/bulkWrite-updateMany-pipeline.json create mode 100644 source/crud/tests/unified/bulkWrite-updateMany-pipeline.yml create mode 100644 source/crud/tests/unified/bulkWrite-updateOne-pipeline.json create mode 100644 source/crud/tests/unified/bulkWrite-updateOne-pipeline.yml create mode 100644 source/crud/tests/unified/findOneAndUpdate-pipeline.json create mode 100644 source/crud/tests/unified/findOneAndUpdate-pipeline.yml create mode 100644 source/crud/tests/unified/updateMany-pipeline.json create mode 100644 source/crud/tests/unified/updateMany-pipeline.yml create mode 100644 source/crud/tests/unified/updateOne-pipeline.json create mode 100644 source/crud/tests/unified/updateOne-pipeline.yml delete mode 100644 source/crud/tests/unified/updateWithPipelines.json delete mode 100644 source/crud/tests/unified/updateWithPipelines.yml 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 3331b4e7f5..0000000000 --- a/source/crud/tests/unified/updateWithPipelines.yml +++ /dev/null @@ -1,201 +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 }