diff --git a/source/client-side-encryption/tests/unified/localSchema.json b/source/client-side-encryption/tests/unified/localSchema.json index a7acccac44..aee323d949 100644 --- a/source/client-side-encryption/tests/unified/localSchema.json +++ b/source/client-side-encryption/tests/unified/localSchema.json @@ -333,7 +333,8 @@ } }, "expectError": { - "isClientError": true + "isError": true, + "errorContains": "JSON schema keyword 'required' is only allowed with a remote schema" } } ] diff --git a/source/client-side-encryption/tests/unified/localSchema.yml b/source/client-side-encryption/tests/unified/localSchema.yml index 9a7cbf92d5..495b2774eb 100644 --- a/source/client-side-encryption/tests/unified/localSchema.yml +++ b/source/client-side-encryption/tests/unified/localSchema.yml @@ -99,4 +99,5 @@ tests: arguments: document: &doc0 { _id: 1, encrypted_string: "string0" } expectError: - isClientError: true \ No newline at end of file + isError: true + errorContains: "JSON schema keyword 'required' is only allowed with a remote schema" diff --git a/source/collection-management/tests/listCollections-rawdata.json b/source/collection-management/tests/listCollections-rawdata.json new file mode 100644 index 0000000000..ec09ec31db --- /dev/null +++ b/source/collection-management/tests/listCollections-rawdata.json @@ -0,0 +1,97 @@ +{ + "description": "listCollections-rawData", + "schemaVersion": "1.4", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "database0" + } + } + ], + "tests": [ + { + "description": "listCollections with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0", + "auth": false + } + ], + "operations": [ + { + "name": "listCollections", + "object": "database0", + "arguments": { + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "listCollections": 1, + "filter": { + "$$unsetOrMatches": {} + }, + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "listCollections with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99", + "auth": false + } + ], + "operations": [ + { + "name": "listCollections", + "object": "database0", + "arguments": { + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "listCollections": 1, + "filter": { + "$$unsetOrMatches": {} + }, + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/collection-management/tests/listCollections-rawdata.yml b/source/collection-management/tests/listCollections-rawdata.yml new file mode 100644 index 0000000000..0a9f24cfac --- /dev/null +++ b/source/collection-management/tests/listCollections-rawdata.yml @@ -0,0 +1,49 @@ +description: "listCollections-rawData" + +schemaVersion: "1.4" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name database0 + +tests: + - description: "listCollections with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + auth: false + operations: + - name: listCollections + object: *database0 + arguments: + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + listCollections: 1 + filter: { $$unsetOrMatches: {} } + rawData: *rawdata + - description: "listCollections with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + auth: false + operations: + - name: listCollections + object: *database0 + arguments: + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + listCollections: 1 + filter: { $$unsetOrMatches: {} } + rawData: + $$exists: false diff --git a/source/crud/bulk-write.md b/source/crud/bulk-write.md index 285a5bb338..28c5b847fd 100644 --- a/source/crud/bulk-write.md +++ b/source/crud/bulk-write.md @@ -309,6 +309,16 @@ class BulkWriteOptions { */ comment: Optional; + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; + /** * Whether detailed results for each successful operation should be included in the returned * BulkWriteResult. @@ -538,6 +548,7 @@ The `bulkWrite` server command has the following format: "bypassDocumentValidation": Optional, "comment": Optional, "let": Optional, + "rawData": Optional, ...additional operation-agnostic fields } ``` @@ -917,6 +928,8 @@ error in this specific situation does not seem helpful enough to require size ch ## **Changelog** +- 2025-06-27: Added `rawData` option. + - 2024-11-05: Updated the requirements regarding the size validation. - 2024-10-07: Error if `w:0` is used with `ordered=true` or `verboseResults=true`. diff --git a/source/crud/crud.md b/source/crud/crud.md index 91de6b2e96..e3cb258d27 100644 --- a/source/crud/crud.md +++ b/source/crud/crud.md @@ -319,6 +319,16 @@ class AggregateOptions { * @see https://www.mongodb.com/docs/manual/reference/command/aggregate/ */ let: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } class CountOptions { @@ -371,6 +381,16 @@ class CountOptions { * and providing one will result in a server-side error. */ comment: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } class EstimatedDocumentCountOptions { @@ -395,6 +415,16 @@ class EstimatedDocumentCountOptions { * comment may result in a server-side error. */ comment: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } class DistinctOptions { @@ -439,6 +469,16 @@ class DistinctOptions { * @see https://www.mongodb.com/docs/manual/reference/command/find/ */ hint: Optional<(String | Document)>; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } enum CursorType { @@ -713,6 +753,16 @@ class FindOptions { * @see https://www.mongodb.com/docs/manual/reference/command/find/ */ let: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } type FindOneOptions = Omit; @@ -985,6 +1035,16 @@ class BulkWriteOptions { * The value of let will be passed to all update and delete, but not insert, commands. */ let: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } class InsertOneOptions { @@ -1007,6 +1067,16 @@ class InsertOneOptions { * and providing one will result in a server-side error. */ comment: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } class InsertManyOptions { @@ -1036,6 +1106,16 @@ class InsertManyOptions { * and providing one will result in a server-side error. */ comment: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } class UpdateOptions { @@ -1127,6 +1207,16 @@ class UpdateOptions { * @see https://www.mongodb.com/docs/manual/reference/command/update/ */ sort: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } class ReplaceOptions { @@ -1206,6 +1296,16 @@ class ReplaceOptions { * @see https://www.mongodb.com/docs/manual/reference/command/update/ */ sort: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } class DeleteOptions { @@ -1256,6 +1356,16 @@ class DeleteOptions { * and providing one will result in a server-side error. */ comment: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } ``` @@ -2009,6 +2119,16 @@ class FindOneAndDeleteOptions { * and providing one will result in a server-side error. */ comment: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } class FindOneAndReplaceOptions { @@ -2117,6 +2237,16 @@ class FindOneAndReplaceOptions { * and providing one will result in a server-side error. */ comment: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } class FindOneAndUpdateOptions { @@ -2234,6 +2364,16 @@ class FindOneAndUpdateOptions { * and providing one will result in a server-side error. */ comment: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } ``` @@ -2512,6 +2652,8 @@ aforementioned allowance in the SemVer spec. ## Changelog +- 2025-06-27: Added `rawData` options. + - 2024-11-13: Define `findOne` operation as optional, and add guidance on `limit` and `batchSize` for `find` operations. - 2024-11-04: Always send a value for `bypassDocumentValidation` if it was specified. diff --git a/source/crud/tests/unified/aggregate-rawdata.json b/source/crud/tests/unified/aggregate-rawdata.json new file mode 100644 index 0000000000..d34a359f9d --- /dev/null +++ b/source/crud/tests/unified/aggregate-rawdata.json @@ -0,0 +1,116 @@ +{ + "description": "aggregate-rawData", + "schemaVersion": "1.4", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "Aggregate with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "name": "aggregate", + "object": "collection0", + "arguments": { + "pipeline": [ + { + "$match": {} + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "coll0", + "pipeline": [ + { + "$match": {} + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "Aggregate with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "name": "aggregate", + "object": "collection0", + "arguments": { + "pipeline": [ + { + "$match": {} + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "coll0", + "pipeline": [ + { + "$match": {} + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/aggregate-rawdata.yml b/source/crud/tests/unified/aggregate-rawdata.yml new file mode 100644 index 0000000000..11a398e08a --- /dev/null +++ b/source/crud/tests/unified/aggregate-rawdata.yml @@ -0,0 +1,55 @@ +description: "aggregate-rawData" + +schemaVersion: "1.4" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "Aggregate with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - name: aggregate + object: *collection0 + arguments: + pipeline: &pipeline0 + - $match: {} + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *pipeline0 + rawData: *rawdata + - description: "Aggregate with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - name: aggregate + object: *collection0 + arguments: + pipeline: &pipeline0 + - $match: {} + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: *pipeline0 + rawData: + $$exists: false diff --git a/source/crud/tests/unified/bulkWrite-deleteMany-rawdata.json b/source/crud/tests/unified/bulkWrite-deleteMany-rawdata.json new file mode 100644 index 0000000000..a74149e979 --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-deleteMany-rawdata.json @@ -0,0 +1,122 @@ +{ + "description": "BulkWrite deleteMany-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "BulkWrite deleteMany with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "deleteMany": { + "filter": {} + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": {}, + "limit": 0 + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "BulkWrite deleteMany with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "deleteMany": { + "filter": {} + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": {}, + "limit": 0 + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/bulkWrite-deleteMany-rawdata.yml b/source/crud/tests/unified/bulkWrite-deleteMany-rawdata.yml new file mode 100644 index 0000000000..f1722058af --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-deleteMany-rawdata.yml @@ -0,0 +1,61 @@ +description: "BulkWrite deleteMany-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "BulkWrite deleteMany with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteMany: + filter: &filter {} + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 0 + rawData: *rawdata + - description: "BulkWrite deleteMany with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteMany: + filter: &filter {} + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 0 + rawData: + $$exists: false diff --git a/source/crud/tests/unified/bulkWrite-deleteOne-rawdata.json b/source/crud/tests/unified/bulkWrite-deleteOne-rawdata.json new file mode 100644 index 0000000000..534e62c9e8 --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-deleteOne-rawdata.json @@ -0,0 +1,122 @@ +{ + "description": "BulkWrite deleteOne-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "BulkWrite deleteOne with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "deleteOne": { + "filter": {} + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": {}, + "limit": 1 + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "BulkWrite deleteOne with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "deleteOne": { + "filter": {} + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": {}, + "limit": 1 + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/bulkWrite-deleteOne-rawdata.yml b/source/crud/tests/unified/bulkWrite-deleteOne-rawdata.yml new file mode 100644 index 0000000000..75a66bf851 --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-deleteOne-rawdata.yml @@ -0,0 +1,61 @@ +description: "BulkWrite deleteOne-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "BulkWrite deleteOne with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteOne: + filter: &filter {} + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 1 + rawData: *rawdata + - description: "BulkWrite deleteOne with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - deleteOne: + filter: &filter {} + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: *filter + limit: 1 + rawData: + $$exists: false diff --git a/source/crud/tests/unified/bulkWrite-replaceOne-rawdata.json b/source/crud/tests/unified/bulkWrite-replaceOne-rawdata.json new file mode 100644 index 0000000000..50403fc5c3 --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-replaceOne-rawdata.json @@ -0,0 +1,136 @@ +{ + "description": "BulkWrite replaceOne-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "BulkWrite replaceOne with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "replaceOne": { + "filter": {}, + "replacement": {} + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": {}, + "u": {}, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "BulkWrite replaceOne with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "replaceOne": { + "filter": {}, + "replacement": {} + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": {}, + "u": {}, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/bulkWrite-replaceOne-rawdata.yml b/source/crud/tests/unified/bulkWrite-replaceOne-rawdata.yml new file mode 100644 index 0000000000..60f3af8c9b --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-replaceOne-rawdata.yml @@ -0,0 +1,71 @@ +description: "BulkWrite replaceOne-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "BulkWrite replaceOne with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - replaceOne: + filter: &filter {} + replacement: &replacement {} + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *replacement + multi: + $$unsetOrMatches: false + upsert: + $$unsetOrMatches: false + rawData: *rawdata + - description: "BulkWrite replaceOne with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - replaceOne: + filter: &filter {} + replacement: &replacement {} + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *replacement + multi: + $$unsetOrMatches: false + upsert: + $$unsetOrMatches: false + rawData: + $$exists: false diff --git a/source/crud/tests/unified/bulkWrite-updateMany-rawdata.json b/source/crud/tests/unified/bulkWrite-updateMany-rawdata.json new file mode 100644 index 0000000000..4f807ae42a --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-updateMany-rawdata.json @@ -0,0 +1,157 @@ +{ + "description": "BulkWrite updateMany-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "BulkWrite updateMany with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "updateMany": { + "filter": {}, + "update": [ + { + "$set": { + "x": 1 + } + } + ] + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": {}, + "u": [ + { + "$set": { + "x": 1 + } + } + ], + "multi": true, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "BulkWrite updateMany with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "minServerVersion": "4.2.0", + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "updateMany": { + "filter": {}, + "update": [ + { + "$set": { + "x": 1 + } + } + ] + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": {}, + "u": [ + { + "$set": { + "x": 1 + } + } + ], + "multi": true, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/bulkWrite-updateMany-rawdata.yml b/source/crud/tests/unified/bulkWrite-updateMany-rawdata.yml new file mode 100644 index 0000000000..ac5d67fb45 --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-updateMany-rawdata.yml @@ -0,0 +1,72 @@ +description: "BulkWrite updateMany-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "BulkWrite updateMany with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateMany: + filter: &filter {} + update: &update + - $set: + x: 1 + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *update + multi: true + upsert: { $$unsetOrMatches: false } + rawData: *rawdata + - description: "BulkWrite updateMany with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - minServerVersion: "4.2.0" + maxServerVersion: "8.1.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateMany: + filter: &filter {} + update: &update + - $set: + x: 1 + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *update + multi: true + upsert: { $$unsetOrMatches: false } + rawData: + $$exists: false diff --git a/source/crud/tests/unified/bulkWrite-updateOne-rawdata.json b/source/crud/tests/unified/bulkWrite-updateOne-rawdata.json new file mode 100644 index 0000000000..32b53cbf29 --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-updateOne-rawdata.json @@ -0,0 +1,161 @@ +{ + "description": "BulkWrite updateOne-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "BulkWrite updateOne with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "updateOne": { + "filter": {}, + "update": [ + { + "$set": { + "x": 1 + } + } + ] + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": {}, + "u": [ + { + "$set": { + "x": 1 + } + } + ], + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "BulkWrite updateOne with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "minServerVersion": "4.2.0", + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "updateOne": { + "filter": {}, + "update": [ + { + "$set": { + "x": 1 + } + } + ] + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": {}, + "u": [ + { + "$set": { + "x": 1 + } + } + ], + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/bulkWrite-updateOne-rawdata.yml b/source/crud/tests/unified/bulkWrite-updateOne-rawdata.yml new file mode 100644 index 0000000000..86415a5412 --- /dev/null +++ b/source/crud/tests/unified/bulkWrite-updateOne-rawdata.yml @@ -0,0 +1,76 @@ +description: "BulkWrite updateOne-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "BulkWrite updateOne with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateOne: + filter: &filter {} + update: &update + - $set: + x: 1 + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *update + multi: + $$unsetOrMatches: false + upsert: + $$unsetOrMatches: false + rawData: *rawdata + - description: "BulkWrite updateOne with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - minServerVersion: "4.2.0" + maxServerVersion: "8.1.99" + operations: + - object: *collection0 + name: bulkWrite + arguments: + requests: + - updateOne: + filter: &filter {} + update: &update + - $set: + x: 1 + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: *filter + u: *update + multi: + $$unsetOrMatches: false + upsert: + $$unsetOrMatches: false + rawData: + $$exists: false diff --git a/source/crud/tests/unified/client-bulkWrite-delete-rawdata.json b/source/crud/tests/unified/client-bulkWrite-delete-rawdata.json new file mode 100644 index 0000000000..a9f476cfa4 --- /dev/null +++ b/source/crud/tests/unified/client-bulkWrite-delete-rawdata.json @@ -0,0 +1,171 @@ +{ + "description": "client bulkWrite delete-rawData", + "schemaVersion": "1.4", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "_yamlAnchors": { + "namespace": "crud-tests.coll0", + "filter": {} + }, + "tests": [ + { + "description": "client bulk write delete with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0", + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "client0", + "name": "clientBulkWrite", + "arguments": { + "models": [ + { + "deleteOne": { + "namespace": "crud-tests.coll0", + "filter": {} + } + }, + { + "deleteMany": { + "namespace": "crud-tests.coll0", + "filter": {} + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "commandName": "bulkWrite", + "databaseName": "admin", + "command": { + "bulkWrite": 1, + "ordered": true, + "ops": [ + { + "delete": 0, + "filter": {}, + "multi": false + }, + { + "delete": 0, + "filter": {}, + "multi": true + } + ], + "nsInfo": [ + { + "ns": "crud-tests.coll0" + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "client bulk write delete with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "minServerVersion": "8.0", + "maxServerVersion": "8.1.99", + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "client0", + "name": "clientBulkWrite", + "arguments": { + "models": [ + { + "deleteOne": { + "namespace": "crud-tests.coll0", + "filter": {} + } + }, + { + "deleteMany": { + "namespace": "crud-tests.coll0", + "filter": {} + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "commandName": "bulkWrite", + "databaseName": "admin", + "command": { + "bulkWrite": 1, + "ordered": true, + "ops": [ + { + "delete": 0, + "filter": {}, + "multi": false + }, + { + "delete": 0, + "filter": {}, + "multi": true + } + ], + "nsInfo": [ + { + "ns": "crud-tests.coll0" + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/client-bulkWrite-delete-rawdata.yml b/source/crud/tests/unified/client-bulkWrite-delete-rawdata.yml new file mode 100644 index 0000000000..9c7e9dc3aa --- /dev/null +++ b/source/crud/tests/unified/client-bulkWrite-delete-rawdata.yml @@ -0,0 +1,94 @@ +description: "client bulkWrite delete-rawData" + +schemaVersion: "1.4" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +_yamlAnchors: + namespace: &namespace "crud-tests.coll0" + filter: &filter {} + +tests: + - description: "client bulk write delete with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + serverless: forbid + operations: + - object: *client0 + name: clientBulkWrite + arguments: + models: + - deleteOne: + namespace: *namespace + filter: *filter + - deleteMany: + namespace: *namespace + filter: *filter + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + commandName: bulkWrite + databaseName: admin + command: + bulkWrite: 1 + ordered: true + ops: + - delete: 0 + filter: *filter + multi: false + - delete: 0 + filter: *filter + multi: true + nsInfo: + - ns: *namespace + rawData: *rawdata + - description: "client bulk write delete with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - minServerVersion: "8.0" + maxServerVersion: "8.1.99" + serverless: forbid + operations: + - object: *client0 + name: clientBulkWrite + arguments: + models: + - deleteOne: + namespace: *namespace + filter: *filter + - deleteMany: + namespace: *namespace + filter: *filter + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + commandName: bulkWrite + databaseName: admin + command: + bulkWrite: 1 + ordered: true + ops: + - delete: 0 + filter: *filter + multi: false + - delete: 0 + filter: *filter + multi: true + nsInfo: + - ns: *namespace + rawData: + $$exists: false diff --git a/source/crud/tests/unified/client-bulkWrite-replaceOne-rawdata.json b/source/crud/tests/unified/client-bulkWrite-replaceOne-rawdata.json new file mode 100644 index 0000000000..22da494366 --- /dev/null +++ b/source/crud/tests/unified/client-bulkWrite-replaceOne-rawdata.json @@ -0,0 +1,169 @@ +{ + "description": "client bulkWrite replaceOne-rawData", + "schemaVersion": "1.4", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "_yamlAnchors": { + "namespace": "crud-tests.coll0" + }, + "tests": [ + { + "description": "client bulkWrite replaceOne with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0", + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "client0", + "name": "clientBulkWrite", + "arguments": { + "models": [ + { + "replaceOne": { + "namespace": "crud-tests.coll0", + "filter": {}, + "replacement": { + "x": 1 + } + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "commandName": "bulkWrite", + "databaseName": "admin", + "command": { + "bulkWrite": 1, + "ops": [ + { + "update": 0, + "filter": {}, + "updateMods": { + "x": 1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "nsInfo": [ + { + "ns": "crud-tests.coll0" + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "client bulk write replaceOne with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "minServerVersion": "8.0", + "maxServerVersion": "8.1.99", + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "client0", + "name": "clientBulkWrite", + "arguments": { + "models": [ + { + "replaceOne": { + "namespace": "crud-tests.coll0", + "filter": {}, + "replacement": { + "x": 1 + } + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "commandName": "bulkWrite", + "databaseName": "admin", + "command": { + "bulkWrite": 1, + "ordered": true, + "ops": [ + { + "update": 0, + "filter": {}, + "updateMods": { + "x": 1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "nsInfo": [ + { + "ns": "crud-tests.coll0" + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/client-bulkWrite-replaceOne-rawdata.yml b/source/crud/tests/unified/client-bulkWrite-replaceOne-rawdata.yml new file mode 100644 index 0000000000..c0cd568194 --- /dev/null +++ b/source/crud/tests/unified/client-bulkWrite-replaceOne-rawdata.yml @@ -0,0 +1,92 @@ +description: "client bulkWrite replaceOne-rawData" + +schemaVersion: "1.4" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +_yamlAnchors: + namespace: &namespace "crud-tests.coll0" + +tests: + - description: "client bulkWrite replaceOne with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + serverless: forbid + operations: + - object: *client0 + name: clientBulkWrite + arguments: + models: + - replaceOne: + namespace: *namespace + filter: &filter {} + replacement: &replacement + x: 1 + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + commandName: bulkWrite + databaseName: admin + command: + bulkWrite: 1 + ops: + - update: 0 + filter: *filter + updateMods: *replacement + multi: + $$unsetOrMatches: false + upsert: + $$unsetOrMatches: false + nsInfo: + - ns: *namespace + rawData: *rawdata + - description: "client bulk write replaceOne with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - minServerVersion: "8.0" + maxServerVersion: "8.1.99" + serverless: forbid + operations: + - object: *client0 + name: clientBulkWrite + arguments: + models: + - replaceOne: + namespace: *namespace + filter: &filter {} + replacement: &replacement + x: 1 + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + commandName: bulkWrite + databaseName: admin + command: + bulkWrite: 1 + ordered: true + ops: + - update: 0 + filter: *filter + updateMods: *replacement + multi: + $$unsetOrMatches: false + upsert: + $$unsetOrMatches: false + nsInfo: + - ns: *namespace + rawData: + $$exists: false diff --git a/source/crud/tests/unified/client-bulkWrite-update-rawdata.json b/source/crud/tests/unified/client-bulkWrite-update-rawdata.json new file mode 100644 index 0000000000..63f86f19d9 --- /dev/null +++ b/source/crud/tests/unified/client-bulkWrite-update-rawdata.json @@ -0,0 +1,198 @@ +{ + "description": "client bulkWrite update-rawData", + "schemaVersion": "1.4", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "_yamlAnchors": { + "namespace": "crud-tests.coll0", + "filter": {}, + "update": { + "$set": {} + } + }, + "tests": [ + { + "description": "client bulk write update with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0", + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "client0", + "name": "clientBulkWrite", + "arguments": { + "models": [ + { + "updateOne": { + "namespace": "crud-tests.coll0", + "filter": {}, + "update": { + "$set": {} + } + } + }, + { + "updateMany": { + "namespace": "crud-tests.coll0", + "filter": {}, + "update": { + "$set": {} + } + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "commandName": "bulkWrite", + "databaseName": "admin", + "command": { + "bulkWrite": 1, + "ordered": true, + "ops": [ + { + "update": 0, + "filter": {}, + "updateMods": { + "$set": {} + }, + "multi": false + }, + { + "update": 0, + "filter": {}, + "updateMods": { + "$set": {} + }, + "multi": true + } + ], + "nsInfo": [ + { + "ns": "crud-tests.coll0" + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "client bulk write update with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "minServerVersion": "8.0", + "maxServerVersion": "8.1.99", + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "client0", + "name": "clientBulkWrite", + "arguments": { + "models": [ + { + "updateOne": { + "namespace": "crud-tests.coll0", + "filter": {}, + "update": { + "$set": {} + } + } + }, + { + "updateMany": { + "namespace": "crud-tests.coll0", + "filter": {}, + "update": { + "$set": {} + } + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "commandName": "bulkWrite", + "databaseName": "admin", + "command": { + "bulkWrite": 1, + "ordered": true, + "ops": [ + { + "update": 0, + "filter": {}, + "updateMods": { + "$set": {} + }, + "multi": false + }, + { + "update": 0, + "filter": {}, + "updateMods": { + "$set": {} + }, + "multi": true + } + ], + "nsInfo": [ + { + "ns": "crud-tests.coll0" + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/client-bulkWrite-update-rawdata.yml b/source/crud/tests/unified/client-bulkWrite-update-rawdata.yml new file mode 100644 index 0000000000..f53f7c958c --- /dev/null +++ b/source/crud/tests/unified/client-bulkWrite-update-rawdata.yml @@ -0,0 +1,103 @@ +description: "client bulkWrite update-rawData" +schemaVersion: "1.4" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +_yamlAnchors: + namespace: &namespace "crud-tests.coll0" + filter: &filter {} + update: &update + $set: {} + +tests: + - description: "client bulk write update with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + serverless: forbid + operations: + - object: *client0 + name: clientBulkWrite + arguments: + models: + - updateOne: + namespace: *namespace + filter: *filter + update: *update + - updateMany: + namespace: *namespace + filter: *filter + update: *update + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + commandName: bulkWrite + databaseName: admin + command: + bulkWrite: 1 + ordered: true + ops: + - update: 0 + filter: *filter + updateMods: *update + multi: false + - update: 0 + filter: *filter + updateMods: *update + multi: true + nsInfo: + - ns: *namespace + rawData: *rawdata + - description: "client bulk write update with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - minServerVersion: "8.0" + maxServerVersion: "8.1.99" + serverless: forbid + operations: + - object: *client0 + name: clientBulkWrite + arguments: + models: + - updateOne: + namespace: *namespace + filter: *filter + update: *update + - updateMany: + namespace: *namespace + filter: *filter + update: *update + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + commandName: bulkWrite + databaseName: admin + command: + bulkWrite: 1 + ordered: true + ops: + - update: 0 + filter: *filter + updateMods: *update + multi: false + - update: 0 + filter: *filter + updateMods: *update + multi: true + nsInfo: + - ns: *namespace + rawData: + $$exists: false diff --git a/source/crud/tests/unified/count-rawdata.json b/source/crud/tests/unified/count-rawdata.json new file mode 100644 index 0000000000..44772d40fb --- /dev/null +++ b/source/crud/tests/unified/count-rawdata.json @@ -0,0 +1,100 @@ +{ + "description": "count-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "Deprecated count with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "object": "collection0", + "name": "count", + "arguments": { + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "count": "coll0", + "rawData": true + }, + "databaseName": "crud-tests" + } + } + ] + } + ] + }, + { + "description": "Deprecated count with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "object": "collection0", + "name": "count", + "arguments": { + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "count": "coll0", + "rawData": { + "$$exists": false + } + }, + "databaseName": "crud-tests" + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/count-rawdata.yml b/source/crud/tests/unified/count-rawdata.yml new file mode 100644 index 0000000000..845606c9dd --- /dev/null +++ b/source/crud/tests/unified/count-rawdata.yml @@ -0,0 +1,53 @@ +description: "count-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "Deprecated count with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - object: *collection0 + name: count + arguments: + filter: {} + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + count: *collection0Name + rawData: *rawdata + databaseName: *database0Name + - description: "Deprecated count with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - object: *collection0 + name: count + arguments: + filter: {} + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + count: *collection0Name + rawData: + $$exists: false + databaseName: *database0Name diff --git a/source/crud/tests/unified/countDocuments-rawdata.json b/source/crud/tests/unified/countDocuments-rawdata.json new file mode 100644 index 0000000000..1651a7fe2d --- /dev/null +++ b/source/crud/tests/unified/countDocuments-rawdata.json @@ -0,0 +1,128 @@ +{ + "description": "countDocuments-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "Count documents with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "object": "collection0", + "name": "countDocuments", + "arguments": { + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "coll0", + "pipeline": [ + { + "$match": {} + }, + { + "$group": { + "_id": 1, + "n": { + "$sum": 1 + } + } + } + ], + "rawData": true + }, + "commandName": "aggregate", + "databaseName": "crud-tests" + } + } + ] + } + ] + }, + { + "description": "Count documents with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "object": "collection0", + "name": "countDocuments", + "arguments": { + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "coll0", + "pipeline": [ + { + "$match": {} + }, + { + "$group": { + "_id": 1, + "n": { + "$sum": 1 + } + } + } + ], + "rawData": { + "$$exists": false + } + }, + "commandName": "aggregate", + "databaseName": "crud-tests" + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/countDocuments-rawdata.yml b/source/crud/tests/unified/countDocuments-rawdata.yml new file mode 100644 index 0000000000..b0a7408267 --- /dev/null +++ b/source/crud/tests/unified/countDocuments-rawdata.yml @@ -0,0 +1,61 @@ +description: "countDocuments-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "Count documents with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - object: *collection0 + name: countDocuments + arguments: + filter: {} + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: + - $match: {} + - $group: { _id: 1, n: { $sum: 1 } } + rawData: *rawdata + commandName: aggregate + databaseName: *database0Name + - description: "Count documents with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - object: *collection0 + name: countDocuments + arguments: + filter: {} + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0Name + pipeline: + - $match: {} + - $group: { _id: 1, n: { $sum: 1 } } + rawData: + $$exists: false + commandName: aggregate + databaseName: *database0Name diff --git a/source/crud/tests/unified/db-aggregate-rawdata.json b/source/crud/tests/unified/db-aggregate-rawdata.json new file mode 100644 index 0000000000..61e22b9fbe --- /dev/null +++ b/source/crud/tests/unified/db-aggregate-rawdata.json @@ -0,0 +1,177 @@ +{ + "description": "db-aggregate-rawdata", + "schemaVersion": "1.4", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "admin" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "crud-v2" + } + } + ], + "tests": [ + { + "description": "Aggregate with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0", + "topologies": [ + "replicaset" + ], + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "database0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$listLocalSessions": {} + }, + { + "$limit": 1 + }, + { + "$addFields": { + "dummy": "dummy field" + } + }, + { + "$project": { + "_id": 0, + "dummy": 1 + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": 1, + "pipeline": [ + { + "$listLocalSessions": {} + }, + { + "$limit": 1 + }, + { + "$addFields": { + "dummy": "dummy field" + } + }, + { + "$project": { + "_id": 0, + "dummy": 1 + } + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "Aggregate with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99", + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "database0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$listLocalSessions": {} + }, + { + "$limit": 1 + }, + { + "$addFields": { + "dummy": "dummy field" + } + }, + { + "$project": { + "_id": 0, + "dummy": 1 + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": 1, + "pipeline": [ + { + "$listLocalSessions": {} + }, + { + "$limit": 1 + }, + { + "$addFields": { + "dummy": "dummy field" + } + }, + { + "$project": { + "_id": 0, + "dummy": 1 + } + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/db-aggregate-rawdata.yml b/source/crud/tests/unified/db-aggregate-rawdata.yml new file mode 100644 index 0000000000..1a6b21ca29 --- /dev/null +++ b/source/crud/tests/unified/db-aggregate-rawdata.yml @@ -0,0 +1,64 @@ +description: "db-aggregate-rawdata" + +schemaVersion: "1.4" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name admin + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collectionName crud-v2 + +tests: + - description: "Aggregate with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + topologies: [ replicaset ] + serverless: forbid + operations: + - object: *database0 + name: aggregate + arguments: + pipeline: &pipeline + - { $listLocalSessions: {} } + - { $limit: 1 } + - { $addFields: { dummy: 'dummy field' } } + - { $project: { _id: 0, dummy: 1 } } + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: 1 + pipeline: *pipeline + rawData: *rawdata + - description: "Aggregate with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + serverless: forbid + operations: + - object: *database0 + name: aggregate + arguments: + pipeline: &pipeline + - { $listLocalSessions: {} } + - { $limit: 1 } + - { $addFields: { dummy: 'dummy field' } } + - { $project: { _id: 0, dummy: 1 } } + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: 1 + pipeline: *pipeline + rawData: + $$exists: false diff --git a/source/crud/tests/unified/deleteMany-rawdata.json b/source/crud/tests/unified/deleteMany-rawdata.json new file mode 100644 index 0000000000..fbdc852708 --- /dev/null +++ b/source/crud/tests/unified/deleteMany-rawdata.json @@ -0,0 +1,110 @@ +{ + "description": "deleteMany-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "deleteMany with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "name": "deleteMany", + "object": "collection0", + "arguments": { + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": {}, + "limit": 0 + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "deleteMany with with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "name": "deleteMany", + "object": "collection0", + "arguments": { + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": {}, + "limit": 0 + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/deleteMany-rawdata.yml b/source/crud/tests/unified/deleteMany-rawdata.yml new file mode 100644 index 0000000000..d6c1f33478 --- /dev/null +++ b/source/crud/tests/unified/deleteMany-rawdata.yml @@ -0,0 +1,57 @@ +description: "deleteMany-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "deleteMany with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - name: deleteMany + object: *collection0 + arguments: + filter: {} + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: {} + limit: 0 + rawData: *rawdata + - description: "deleteMany with with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - name: deleteMany + object: *collection0 + arguments: + filter: {} + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: {} + limit: 0 + rawData: + $$exists: false diff --git a/source/crud/tests/unified/deleteOne-rawdata.json b/source/crud/tests/unified/deleteOne-rawdata.json new file mode 100644 index 0000000000..4347548583 --- /dev/null +++ b/source/crud/tests/unified/deleteOne-rawdata.json @@ -0,0 +1,110 @@ +{ + "description": "deleteOne-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "deleteOne with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "name": "deleteOne", + "object": "collection0", + "arguments": { + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": {}, + "limit": 1 + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "deleteOne with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "name": "deleteOne", + "object": "collection0", + "arguments": { + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "coll0", + "deletes": [ + { + "q": {}, + "limit": 1 + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/deleteOne-rawdata.yml b/source/crud/tests/unified/deleteOne-rawdata.yml new file mode 100644 index 0000000000..6d9eb72f82 --- /dev/null +++ b/source/crud/tests/unified/deleteOne-rawdata.yml @@ -0,0 +1,57 @@ +description: "deleteOne-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "deleteOne with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - name: deleteOne + object: *collection0 + arguments: + filter: {} + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: {} + limit: 1 + rawData: *rawdata + - description: "deleteOne with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - name: deleteOne + object: *collection0 + arguments: + filter: {} + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + delete: *collection0Name + deletes: + - q: {} + limit: 1 + rawData: + $$exists: false diff --git a/source/crud/tests/unified/distinct-rawdata.json b/source/crud/tests/unified/distinct-rawdata.json new file mode 100644 index 0000000000..d1a4abc7f7 --- /dev/null +++ b/source/crud/tests/unified/distinct-rawdata.json @@ -0,0 +1,104 @@ +{ + "description": "distinct-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "distinct with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "name": "distinct", + "object": "collection0", + "arguments": { + "fieldName": "x", + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "distinct": "coll0", + "key": "x", + "query": {}, + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "distinct with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "name": "distinct", + "object": "collection0", + "arguments": { + "fieldName": "x", + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "distinct": "coll0", + "key": "x", + "query": {}, + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/distinct-rawdata.yml b/source/crud/tests/unified/distinct-rawdata.yml new file mode 100644 index 0000000000..b6eeab9552 --- /dev/null +++ b/source/crud/tests/unified/distinct-rawdata.yml @@ -0,0 +1,57 @@ +description: "distinct-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "distinct with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - name: distinct + object: *collection0 + arguments: + fieldName: &fieldName x + filter: &filter {} + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + distinct: *collection0Name + key: *fieldName + query: *filter + rawData: *rawdata + - description: "distinct with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - name: distinct + object: *collection0 + arguments: + fieldName: &fieldName x + filter: &filter {} + rawData: true + expectEvents: + - client: client0 + events: + - commandStartedEvent: + command: + distinct: *collection0Name + key: *fieldName + query: *filter + rawData: + $$exists: false diff --git a/source/crud/tests/unified/estimatedDocumentCount-rawdata.json b/source/crud/tests/unified/estimatedDocumentCount-rawdata.json new file mode 100644 index 0000000000..4c79863e98 --- /dev/null +++ b/source/crud/tests/unified/estimatedDocumentCount-rawdata.json @@ -0,0 +1,100 @@ +{ + "description": "estimatedDocumentCount-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "Estimated document count with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "object": "collection0", + "name": "estimatedDocumentCount", + "arguments": { + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "count": "coll0", + "rawData": true + }, + "commandName": "count", + "databaseName": "crud-tests" + } + } + ] + } + ] + }, + { + "description": "Estimated document count with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "object": "collection0", + "name": "estimatedDocumentCount", + "arguments": { + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "count": "coll0", + "rawData": { + "$$exists": false + } + }, + "commandName": "count", + "databaseName": "crud-tests" + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/estimatedDocumentCount-rawdata.yml b/source/crud/tests/unified/estimatedDocumentCount-rawdata.yml new file mode 100644 index 0000000000..7c07a56990 --- /dev/null +++ b/source/crud/tests/unified/estimatedDocumentCount-rawdata.yml @@ -0,0 +1,53 @@ +description: "estimatedDocumentCount-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "Estimated document count with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - object: *collection0 + name: estimatedDocumentCount + arguments: + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + count: *collection0Name + rawData: *rawdata + commandName: count + databaseName: *database0Name + - description: "Estimated document count with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - object: *collection0 + name: estimatedDocumentCount + arguments: + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + count: *collection0Name + rawData: + $$exists: false + commandName: count + databaseName: *database0Name diff --git a/source/crud/tests/unified/find-rawdata.json b/source/crud/tests/unified/find-rawdata.json new file mode 100644 index 0000000000..778e289880 --- /dev/null +++ b/source/crud/tests/unified/find-rawdata.json @@ -0,0 +1,100 @@ +{ + "description": "find-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "Find with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "name": "find", + "object": "collection0", + "arguments": { + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "coll0", + "filter": {}, + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "Find with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "name": "find", + "object": "collection0", + "arguments": { + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "coll0", + "filter": {}, + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/find-rawdata.yml b/source/crud/tests/unified/find-rawdata.yml new file mode 100644 index 0000000000..f260d33943 --- /dev/null +++ b/source/crud/tests/unified/find-rawdata.yml @@ -0,0 +1,53 @@ +description: "find-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "Find with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - name: find + object: *collection0 + arguments: + filter: {} + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: {} + rawData: *rawdata + - description: "Find with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - name: find + object: *collection0 + arguments: + filter: {} + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: {} + rawData: + $$exists: false diff --git a/source/crud/tests/unified/findOneAndDelete-rawdata.json b/source/crud/tests/unified/findOneAndDelete-rawdata.json new file mode 100644 index 0000000000..1ace780b74 --- /dev/null +++ b/source/crud/tests/unified/findOneAndDelete-rawdata.json @@ -0,0 +1,102 @@ +{ + "description": "findOneAndDelete-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "findOneAndDelete with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "name": "findOneAndDelete", + "object": "collection0", + "arguments": { + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": {}, + "remove": true, + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "findOneAndDelete with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "name": "findOneAndDelete", + "object": "collection0", + "arguments": { + "filter": {}, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": {}, + "remove": true, + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/findOneAndDelete-rawdata.yml b/source/crud/tests/unified/findOneAndDelete-rawdata.yml new file mode 100644 index 0000000000..27f52321ed --- /dev/null +++ b/source/crud/tests/unified/findOneAndDelete-rawdata.yml @@ -0,0 +1,55 @@ +description: "findOneAndDelete-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "findOneAndDelete with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - name: findOneAndDelete + object: *collection0 + arguments: + filter: {} + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: {} + remove: true + rawData: *rawdata + - description: "findOneAndDelete with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - name: findOneAndDelete + object: *collection0 + arguments: + filter: {} + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: {} + remove: true + rawData: + $$exists: false diff --git a/source/crud/tests/unified/findOneAndReplace-rawdata.json b/source/crud/tests/unified/findOneAndReplace-rawdata.json new file mode 100644 index 0000000000..b48a2a4210 --- /dev/null +++ b/source/crud/tests/unified/findOneAndReplace-rawdata.json @@ -0,0 +1,112 @@ +{ + "description": "findOneAndReplace-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "findOneAndReplace with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "name": "findOneAndReplace", + "object": "collection0", + "arguments": { + "filter": {}, + "replacement": { + "x": "x" + }, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": {}, + "update": { + "x": "x" + }, + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "findOneAndReplace with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "name": "findOneAndReplace", + "object": "collection0", + "arguments": { + "filter": {}, + "replacement": { + "x": "x" + }, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": {}, + "update": { + "x": "x" + }, + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/findOneAndReplace-rawdata.yml b/source/crud/tests/unified/findOneAndReplace-rawdata.yml new file mode 100644 index 0000000000..4007a0fe53 --- /dev/null +++ b/source/crud/tests/unified/findOneAndReplace-rawdata.yml @@ -0,0 +1,57 @@ +description: "findOneAndReplace-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "findOneAndReplace with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: {} + replacement: &replacement { x: x } + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: {} + update: *replacement + rawData: *rawdata + - description: "findOneAndReplace with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - name: findOneAndReplace + object: *collection0 + arguments: + filter: {} + replacement: &replacement { x: x } + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: {} + update: *replacement + rawData: + $$exists: false diff --git a/source/crud/tests/unified/findOneAndUpdate-rawdata.json b/source/crud/tests/unified/findOneAndUpdate-rawdata.json new file mode 100644 index 0000000000..a689e73f7b --- /dev/null +++ b/source/crud/tests/unified/findOneAndUpdate-rawdata.json @@ -0,0 +1,129 @@ +{ + "description": "findOneAndUpdate-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "findOneAndUpdate with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "name": "findOneAndUpdate", + "object": "collection0", + "arguments": { + "filter": {}, + "update": [ + { + "$set": { + "x": 1 + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": {}, + "update": [ + { + "$set": { + "x": 1 + } + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "findOneAndUpdate with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "minServerVersion": "4.2.0", + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "name": "findOneAndUpdate", + "object": "collection0", + "arguments": { + "filter": {}, + "update": [ + { + "$set": { + "x": 1 + } + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "coll0", + "query": {}, + "update": [ + { + "$set": { + "x": 1 + } + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/findOneAndUpdate-rawdata.yml b/source/crud/tests/unified/findOneAndUpdate-rawdata.yml new file mode 100644 index 0000000000..fb99905e2d --- /dev/null +++ b/source/crud/tests/unified/findOneAndUpdate-rawdata.yml @@ -0,0 +1,57 @@ +description: "findOneAndUpdate-rawData" +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "findOneAndUpdate with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: {} + update: &update [ $set: { x: 1 } ] + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: {} + update: *update + rawData: *rawdata + - description: "findOneAndUpdate with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - minServerVersion: "4.2.0" + maxServerVersion: "8.1.99" + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: {} + update: &update [ $set: { x: 1 } ] + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + findAndModify: *collection0Name + query: {} + update: *update + rawData: + $$exists: false diff --git a/source/crud/tests/unified/insertMany-rawdata.json b/source/crud/tests/unified/insertMany-rawdata.json new file mode 100644 index 0000000000..50852592df --- /dev/null +++ b/source/crud/tests/unified/insertMany-rawdata.json @@ -0,0 +1,120 @@ +{ + "description": "insertMany-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "insertMany with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "name": "insertMany", + "object": "collection0", + "arguments": { + "documents": [ + { + "_id": 2, + "x": 22 + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "coll0", + "documents": [ + { + "_id": 2, + "x": 22 + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "insertMany with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "name": "insertMany", + "object": "collection0", + "arguments": { + "documents": [ + { + "_id": 2, + "x": 22 + } + ], + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "coll0", + "documents": [ + { + "_id": 2, + "x": 22 + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/insertMany-rawdata.yml b/source/crud/tests/unified/insertMany-rawdata.yml new file mode 100644 index 0000000000..562be344d8 --- /dev/null +++ b/source/crud/tests/unified/insertMany-rawdata.yml @@ -0,0 +1,53 @@ +description: "insertMany-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "insertMany with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - name: insertMany + object: *collection0 + arguments: + documents: &documents [ { _id: 2, x: 22 } ] + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: *documents + rawData: *rawdata + - description: "insertMany with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - name: insertMany + object: *collection0 + arguments: + documents: &documents [ { _id: 2, x: 22 } ] + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: *documents + rawData: + $$exists: false diff --git a/source/crud/tests/unified/insertOne-rawdata.json b/source/crud/tests/unified/insertOne-rawdata.json new file mode 100644 index 0000000000..d010c2daac --- /dev/null +++ b/source/crud/tests/unified/insertOne-rawdata.json @@ -0,0 +1,116 @@ +{ + "description": "insertOne-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "insertOne with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "name": "insertOne", + "object": "collection0", + "arguments": { + "document": { + "_id": 2, + "x": 22 + }, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "coll0", + "documents": [ + { + "_id": 2, + "x": 22 + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "insertOne with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "name": "insertOne", + "object": "collection0", + "arguments": { + "document": { + "_id": 2, + "x": 22 + }, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "coll0", + "documents": [ + { + "_id": 2, + "x": 22 + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/insertOne-rawdata.yml b/source/crud/tests/unified/insertOne-rawdata.yml new file mode 100644 index 0000000000..7b14fd6e28 --- /dev/null +++ b/source/crud/tests/unified/insertOne-rawdata.yml @@ -0,0 +1,53 @@ +description: "insertOne-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "insertOne with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - name: insertOne + object: *collection0 + arguments: + document: &document { _id: 2, x: 22 } + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: [ *document ] + rawData: *rawdata + - description: "insertOne with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - name: insertOne + object: *collection0 + arguments: + document: &document { _id: 2, x: 22 } + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection0Name + documents: [ *document ] + rawData: + $$exists: false diff --git a/source/crud/tests/unified/replaceOne-rawdata.json b/source/crud/tests/unified/replaceOne-rawdata.json new file mode 100644 index 0000000000..632404491c --- /dev/null +++ b/source/crud/tests/unified/replaceOne-rawdata.json @@ -0,0 +1,132 @@ +{ + "description": "replaceOne-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "ReplaceOne with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "object": "collection0", + "name": "replaceOne", + "arguments": { + "filter": {}, + "replacement": { + "x": 22 + }, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": {}, + "u": { + "x": 22 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "ReplaceOne with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "object": "collection0", + "name": "replaceOne", + "arguments": { + "filter": {}, + "replacement": { + "x": 22 + }, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": {}, + "u": { + "x": 22 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/replaceOne-rawdata.yml b/source/crud/tests/unified/replaceOne-rawdata.yml new file mode 100644 index 0000000000..1b81c1f3f6 --- /dev/null +++ b/source/crud/tests/unified/replaceOne-rawdata.yml @@ -0,0 +1,67 @@ +description: "replaceOne-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "ReplaceOne with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - object: *collection0 + name: replaceOne + arguments: + filter: {} + replacement: &replacement { x: 22 } + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: {} + u: *replacement + multi: + $$unsetOrMatches: false + upsert: + $$unsetOrMatches: false + rawData: *rawdata + - description: "ReplaceOne with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - object: *collection0 + name: replaceOne + arguments: + filter: {} + replacement: &replacement { x: 22 } + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: {} + u: *replacement + multi: + $$unsetOrMatches: false + upsert: + $$unsetOrMatches: false + rawData: + $$exists: false diff --git a/source/crud/tests/unified/updateMany-rawdata.json b/source/crud/tests/unified/updateMany-rawdata.json new file mode 100644 index 0000000000..20417e0770 --- /dev/null +++ b/source/crud/tests/unified/updateMany-rawdata.json @@ -0,0 +1,136 @@ +{ + "description": "updateMany-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "updateMany with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "name": "updateMany", + "object": "collection0", + "arguments": { + "filter": {}, + "update": { + "$set": { + "x": 1 + } + }, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": {}, + "u": { + "$set": { + "x": 1 + } + }, + "multi": true, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "updateMany with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "name": "updateMany", + "object": "collection0", + "arguments": { + "filter": {}, + "update": { + "$set": { + "x": 1 + } + }, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": {}, + "u": { + "$set": { + "x": 1 + } + }, + "multi": true, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/updateMany-rawdata.yml b/source/crud/tests/unified/updateMany-rawdata.yml new file mode 100644 index 0000000000..75b2587fa3 --- /dev/null +++ b/source/crud/tests/unified/updateMany-rawdata.yml @@ -0,0 +1,65 @@ +description: "updateMany-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "updateMany with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: {} + update: &update { $set: {x: 1} } + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: {} + u: *update + multi: true + upsert: + $$unsetOrMatches: false + rawData: *rawdata + - description: "updateMany with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - name: updateMany + object: *collection0 + arguments: + filter: {} + update: &update { $set: {x: 1} } + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: {} + u: *update + multi: true + upsert: + $$unsetOrMatches: false + rawData: + $$exists: false diff --git a/source/crud/tests/unified/updateOne-rawdata.json b/source/crud/tests/unified/updateOne-rawdata.json new file mode 100644 index 0000000000..8f703d9a40 --- /dev/null +++ b/source/crud/tests/unified/updateOne-rawdata.json @@ -0,0 +1,140 @@ +{ + "description": "updateOne-rawData", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "crud-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "tests": [ + { + "description": "UpdateOne with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "name": "updateOne", + "object": "collection0", + "arguments": { + "filter": {}, + "update": { + "$set": { + "x": 1 + } + }, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": {}, + "u": { + "$set": { + "x": 1 + } + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "UpdateOne with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "name": "updateOne", + "object": "collection0", + "arguments": { + "filter": {}, + "update": { + "$set": { + "x": 1 + } + }, + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "coll0", + "updates": [ + { + "q": {}, + "u": { + "$set": { + "x": 1 + } + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/crud/tests/unified/updateOne-rawdata.yml b/source/crud/tests/unified/updateOne-rawdata.yml new file mode 100644 index 0000000000..a22110d376 --- /dev/null +++ b/source/crud/tests/unified/updateOne-rawdata.yml @@ -0,0 +1,67 @@ +description: "updateOne-rawData" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name crud-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "UpdateOne with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: {} + update: &update { $set: { x: 1 } } + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: {} + u: *update + multi: + $$unsetOrMatches: false + upsert: + $$unsetOrMatches: false + rawData: *rawdata + - description: "UpdateOne with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - name: updateOne + object: *collection0 + arguments: + filter: {} + update: &update { $set: { x: 1 } } + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + update: *collection0Name + updates: + - q: {} + u: *update + multi: + $$unsetOrMatches: false + upsert: + $$unsetOrMatches: false + rawData: + $$exists: false diff --git a/source/index-management/index-management.md b/source/index-management/index-management.md index 3d6b87c73e..2bdb13bcdc 100644 --- a/source/index-management/index-management.md +++ b/source/index-management/index-management.md @@ -214,6 +214,16 @@ interface CreateIndexOptions { */ maxTimeMS: Optional; + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; + /** * Enables users to specify an arbitrary comment to help trace the operation through * the database profiler, currentOp and logs. The default is to not send a value. @@ -238,6 +248,16 @@ interface DropIndexOptions { maxTimeMS: Optional; /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; + +/** * Enables users to specify an arbitrary comment to help trace the operation through * the database profiler, currentOp and logs. The default is to not send a value. * @@ -803,6 +823,16 @@ interface ListIndexesOptions { * @note drivers MAY chose to support batchSize on the ListIndexesOptions. */ batchSize: Optional; + + /** + * This option MAY be implemented by drivers that need to grant access to underlying namespaces + * for time-series collections. Drivers SHOULD NOT implement this option unless asked to do so. + * + * @note This option MUST NOT be sent when connected to pre-8.2 servers. + * + * @since MongoDB 8.2 + */ + rawData: Optional; } ``` @@ -1147,6 +1177,8 @@ from mistakenly specifying this option, drivers manually verify it is only sent #### Changelog +- 2025-06-27: Added `rawData` option to CreateIndexOptions, DropIndexOptions and ListIndexesOptions. + - 2024-09-05: Moved options in SearchIndexModel to SearchIndexOptions for consistency with IndexModel and IndexOptions. - 2024-03-06: Added `type` option to SearchIndexOptions. diff --git a/source/index-management/tests/index-rawdata.json b/source/index-management/tests/index-rawdata.json new file mode 100644 index 0000000000..791a643a0f --- /dev/null +++ b/source/index-management/tests/index-rawdata.json @@ -0,0 +1,186 @@ +{ + "description": "index management-rawData", + "schemaVersion": "1.4", + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "database0" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "collection0" + } + } + ], + "tests": [ + { + "description": "index management with rawData option", + "runOnRequirements": [ + { + "minServerVersion": "8.2.0" + } + ], + "operations": [ + { + "object": "collection0", + "name": "createIndex", + "arguments": { + "keys": { + "x": 1 + }, + "rawData": true + } + }, + { + "object": "collection0", + "name": "listIndexes", + "arguments": { + "rawData": true + } + }, + { + "object": "collection0", + "name": "dropIndex", + "arguments": { + "name": "x_1", + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "createIndexes": "collection0", + "indexes": [ + { + "name": "x_1", + "key": { + "x": 1 + } + } + ], + "rawData": true + } + } + }, + { + "commandStartedEvent": { + "command": { + "listIndexes": "collection0", + "rawData": true + } + } + }, + { + "commandStartedEvent": { + "command": { + "dropIndexes": "collection0", + "index": "x_1", + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "index management with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "object": "collection0", + "name": "createIndex", + "arguments": { + "keys": { + "x": 1 + }, + "rawData": true + } + }, + { + "object": "collection0", + "name": "listIndexes", + "arguments": { + "rawData": true + } + }, + { + "object": "collection0", + "name": "dropIndex", + "arguments": { + "name": "x_1", + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "createIndexes": "collection0", + "indexes": [ + { + "name": "x_1", + "key": { + "x": 1 + } + } + ], + "rawData": { + "$$exists": false + } + } + } + }, + { + "commandStartedEvent": { + "command": { + "listIndexes": "collection0", + "rawData": { + "$$exists": false + } + } + } + }, + { + "commandStartedEvent": { + "command": { + "dropIndexes": "collection0", + "index": "x_1", + "rawData": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/index-management/tests/index-rawdata.yml b/source/index-management/tests/index-rawdata.yml new file mode 100644 index 0000000000..b0b692b664 --- /dev/null +++ b/source/index-management/tests/index-rawdata.yml @@ -0,0 +1,95 @@ +description: "index management-rawData" + +schemaVersion: "1.4" + +createEntities: + - client: + id: &client0 client0 + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name database0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name collection0 + +tests: + - description: "index management with rawData option" + runOnRequirements: + - minServerVersion: "8.2.0" + operations: + - object: *collection0 + name: createIndex + arguments: + keys: &key { x: 1 } + rawData: true + - object: *collection0 + name: listIndexes + arguments: + rawData: true + - object: *collection0 + name: dropIndex + arguments: + name: &name x_1 + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + createIndexes: *collection0 + indexes: + - name: x_1 + key: *key + rawData: true + - commandStartedEvent: + command: + listIndexes: *collection0 + rawData: true + - commandStartedEvent: + command: + dropIndexes: *collection0 + index: *name + rawData: true + - description: "index management with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - object: *collection0 + name: createIndex + arguments: + keys: &key { x: 1 } + rawData: true + - object: *collection0 + name: listIndexes + arguments: + rawData: true + - object: *collection0 + name: dropIndex + arguments: + name: &name x_1 + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + createIndexes: *collection0 + indexes: + - name: x_1 + key: *key + rawData: + $$exists: false + - commandStartedEvent: + command: + listIndexes: *collection0 + rawData: + $$exists: false + - commandStartedEvent: + command: + dropIndexes: *collection0 + index: *name + rawData: + $$exists: false diff --git a/source/index.md b/source/index.md index fcf33d1933..29b2a51e86 100644 --- a/source/index.md +++ b/source/index.md @@ -36,6 +36,7 @@ - [MongoDB Handshake](mongodb-handshake/handshake.md) - [OCSP Support](ocsp-support/ocsp-support.md) - [OP_MSG](message/OP_MSG.md) +- [OpenTelemetry](open-telemetry/open-telemetry.md) - [Performance Benchmarking](benchmarking/benchmarking.md) - [Polling SRV Records for mongos Discovery](polling-srv-records-for-mongos-discovery/polling-srv-records-for-mongos-discovery.md) - [Read and Write Concern](read-write-concern/read-write-concern.md) diff --git a/source/open-telemetry/open-telemetry.md b/source/open-telemetry/open-telemetry.md new file mode 100644 index 0000000000..1fb47480c8 --- /dev/null +++ b/source/open-telemetry/open-telemetry.md @@ -0,0 +1,251 @@ +# OpenTelemetry + +- Title: OpenTelemetry +- Status: Accepted +- Minimum Server Version: N/A + +______________________________________________________________________ + +## Abstract + +This specification defines requirements for drivers' OpenTelemetry integration and behavior. Drivers will trace database +commands and driver operations with a pre-defined set of attributes when OpenTelemetry is enabled and configured in an +application. + +## META + +The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and +"OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt). + +## Specification + +### Terms + +**Host Application** + +An application that uses the MongoDB driver. + +**Span** + +A Span represents a single operation within a trace. Spans can be nested to form a trace tree. Each trace contains a +root span, which typically describes the entire operation and, optionally, one or more sub-spans for its sub-operations. + +Spans encapsulate: + +- The span name +- An immutable SpanContext that uniquely identifies the Span +- A parent span in the form of a Span, SpanContext, or null +- A SpanKind +- A start timestamp +- An end timestamp +- Attributes +- A list of Links to other Spans +- A list of timestamped Events +- A Status. + +**Tracer** + +A Tracer is responsible for creating spans, and using a tracer is the only way to create a span. A Tracer is not +responsible for configuration; this should be the responsibility of the TracerProvider instead. + +**OpenTelemetry API and SDK** + +OpenTelemetry offers two components for implementing instrumentation – API and SDK. The OpenTelemetry API provides all +the necessary types and method signatures. If there is no OpenTelemetry SDK available at runtime, API methods are no-op. +OpenTelemetry SDK is an actual implementation of the API. If the SDK is available, API methods do work. + +### Implementation Requirements + +#### External Dependencies + +Drivers MAY add a dependency to the corresponding OpenTelemetry API. This is the recommended way for implementing +OpenTelemetry in libraries. Alternatively, drivers can implement OpenTelemetry support using any suitable tools within +the driver ecosystem. Drivers MUST NOT add a dependency to OpenTelemetry SDK. + +#### Enabling and Disabling OpenTelemetry + +OpenTelemetry SHOULD be disabled by default. + +Drivers SHOULD support configuring OpenTelemetry on multiple levels. + +- **MongoClient Level**: Drivers SHOULD provide a configuration option for `MongoClient`'s Configuration/Settings that + enables or disables tracing for operations and commands executed with this client. This option MUST override + settings on higher levels. This configuration can be implemented with a `MongoClient` option, for example, + `tracing.enabled`. +- **Driver Level**: Drivers SHOULD provide a global setting that enables or disables OpenTelemetry for all `MongoClient` + instances (excluding those that explicitly override the setting). This configuration can be implemented with an + environment variable `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_ENABLED`. Drivers MAY provide other means to globally + disable OpenTelemetry that are more suitable for their language ecosystem. This option MUST override settings on the + higher level. +- **Host Application Level**: If the host application enables OpenTelemetry for all available instrumentations (e.g., + Ruby), and a driver can detect this, OpenTelemetry SHOULD be enabled in the driver. + +Drivers MUST NOT try to detect whether the OpenTelemetry SDK library is available, and enable tracing based on this. + +#### Tracer Attributes + +If a driver creates a Tracer using OpenTelemetry API, drivers MUST use the following attributes: + +- `name`: A string that identifies the driver. It can be the name of a driver's component (e.g., "mongo", "PyMongo") or + a package name (e.g., "com.mongo.Driver"). Drivers SHOULD select a name that is idiomatic for their language and + ecosystem. Drivers SHOULD follow the Instrumentation Scope guidance. +- `version`: The version of the driver. + +#### Instrumenting Driver Operations + +When a user calls the driver's public API, the driver MUST create a span for every driver operation. Drivers MUST start +the span as soon as possible so that the span’s duration reflects all activities made by the driver, such as server +selection and serialization/deserialization. + +The span for the operation MUST be created within the current span of the host application, with the exceptions listed +below. + +##### Cursors + +If the driver operation returns a cursor, spans for all the subsequent operations on the cursor SHOULD be nested into +the operation span. This includes operations such as `getMore`, `next`, `close`. + +##### `withTransaction` + +The `withTransaction` operation is a special case because it may include other operations that are executed "in scope" +of `withTransaction`. In this case, spans for operations that are executed inside the callbacks SHOULD be nested into +the `withTransaction` span. + +##### Span Name + +The span name SHOULD be: + +- `driver_operation_name db.collection_name` if the command is executed on a collection (e.g., + `findOneAndDelete warehouse.users`). +- `db.driver_operation_name` if there is no specific collection for the command (e.g., `warehouse.runCommand`). + +##### Span Kind + +Span kind MUST be "client". + +##### Span Attributes + +Spans SHOULD have the following attributes: + +| Attribute | Type | Description | Requirement Level | +| :--------------------- | :------- | :------------------------------------------------------------------------- | :-------------------- | +| `db.system` | `string` | MUST be 'mongodb' | Required | +| `db.namespace` | `string` | The database name | Required if available | +| `db.collection.name` | `string` | The collection being accessed within the database stated in `db.namespace` | Required if available | +| `db.operation.name` | `string` | The name of the driver operation being executed | Required | +| `db.operation.summary` | `string` | Equivalent to span name | Required | +| `db.mongodb.cursor_id` | `int64` | If a cursor is created or used in the operation | Required if available | + +Not all attributes are available at the moment of span creation. Drivers need to add attributes at later stages, which +requires an operation span to be available throughout the complete operation lifecycle. + +##### Exceptions + +If the driver operation fails with an exception, drivers MUST record an exception to the current operation span. When +recording an exception, drivers SHOULD add the following attributes to the span, when the content for the attribute if +available: + +- `exception.message` +- `exception.type` +- `exception.stacktrace` + +#### Instrumenting Server Commands + +Drivers MUST create a span for every server command sent to the server as a result of a public API call, except for +sensitive commands as listed in the command logging and monitoring specification. + +Spans for commands MUST be nested to the span for the corresponding driver operation span. If the command is being +retried, the driver MUST create a separate span for each retry; all the retries MUST be nested to the same operation +span. + +##### Span Name + +The span name SHOULD be: + +- `server_command db.collection_name` if the command is executed on a collection (e.g., + `findAndModify warehouse.users`). +- `db.server_command` if there is no specific collection for the command. + +##### Span Kind + +Span kind MUST be "client". + +##### Span Attributes + +Spans SHOULD have the following attributes: + +| Attribute | Type | Description | Requirement Level | +| :-------------------------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------- | +| `db.system` | `string` | MUST be 'mongodb' | Required | +| `db.namespace` | `string` | The database name | Required if available | +| `db.collection.name` | `string` | The collection being accessed within the database stated in `db.namespace` | Required if available | +| `db.command.name` | `string` | The name of the server command being executed | Required | +| `db.response.status_code` | `string` | MongoDB error code represented as a string. This attribute should be added only if an error happens. | Required if an error happens | +| `error.type` | `string` | Describes a class of error the operation ended with. This attribute should be added only if an error happens. Examples: `timeout; java.net.UnknownHostException; server_certificate_invalid; 500`. | Required if an error happens | +| `server.port` | `int64` | Server port number | Required | +| `server.address` | `string` | Name of the database host, or IP address if name is not known | Required | +| `network.transport` | `string` | MUST be 'tcp' or 'unix' depending on the protocol | Required | +| `db.query.summary` | `string` | Equivalent to span name | Required | +| `db.mongodb.server_connection_id` | `int64` | Server connection id | Required if available | +| `db.mongodb.driver_connection_id` | `int64` | Local connection id | Required if available | +| `db.query.text` | `string` | Database command that was sent to the server. Content should be equivalent to the `document` field of the CommandStartedEvent of the command monitoring. | Conditional | +| `db.mongodb.cursor_id` | `int64` | If a cursor is created or used in the operation | Required if available | + +##### db.response.status_code and error.type + +These attributes should be added only if the command was not successful. The content of `error.type` is language +specific; a driver decides what best describes the error. + +##### db.query.text + +This attribute contains the full database command executed serialized to JSON. If not truncated, the content of this +attribute SHOULD be equivalent to the `document` field of the CommandStartedEvent of the command monitoring excluding +the following fields: `lsid`, `$db`, `$clusterTime`, `signature`. + +Drivers MUST NOT add this attribute by default. Drivers MUST provide a toggle to enable this attribute. This +configuration can be implemented with an environment variable +`OTEL_#{LANG}_INSTRUMENTATION_MONGODB_QUERY_TEXT_MAX_LENGTH` set to a positive integer value. The attribute will be +added and truncated to the provided value (similar to the Logging specification). + +On the `MongoClient` level this configuration can be implemented with a `MongoClient` option, for example, +`tracing.query_text_max_length`. + +##### db.mongodb.cursor_id + +If the command returns a cursor, or uses a cursor, the `cursor_id` attribute SHOULD be added. + +##### Exception Handling + +Exceptions MUST be added to the parent span of the command span, which is the driver operation span. + +## Motivation for Change + +A common complaint from our support team is that they don't know how to easily get debugging information from drivers. +Some drivers provide debug logging, but others do not. For drivers that do provide it, the log messages produced and the +mechanisms for enabling debug logging are inconsistent. + +Although users can implement their own debug logging support via existing driver events (SDAM, APM, etc), this requires +code changes. It is often difficult to quickly implement and deploy such changes in production at the time they are +needed, and to remove the changes afterward. Additionally, there are useful scenarios to log that do not correspond to +existing events. Standardizing on debug log messages that drivers produce and how to enable/configure logging will +provide TSEs, CEs, and MongoDB users an easier way to get debugging information out of our drivers, facilitate support +of drivers for our internal teams, and improve our documentation around troubleshooting. + +## Test Plan + +TODO + +## Backwards Compatibility + +Introduction of OpenTelemetry in new driver versions should not significantly affect existing applications that do not +enable OpenTelemetry. However, since the no-op tracing operation may introduce some performance degradation (though it +should be negligible), customers should be informed of this feature and how to disable it completely. + +If a driver is used in an application that has OpenTelemetry enabled, customers will see traces from the driver in their +OpenTelemetry backends. This may be unexpected and MAY cause negative effects in some cases (e.g., the OpenTelemetry +backend MAY not have enough capacity to process new traces). Customers should be informed of this feature and how to +disable it completely. + +## Security Implication + +Drivers MUST take care to avoid exposing sensitive information (e.g. authentication credentials) in traces. diff --git a/source/unified-test-format/unified-test-format.md b/source/unified-test-format/unified-test-format.md index 2fd2094640..e8944e14f9 100644 --- a/source/unified-test-format/unified-test-format.md +++ b/source/unified-test-format/unified-test-format.md @@ -530,6 +530,9 @@ The structure of this object is as follows: - `schemaMap`: Optional object. Maps namespaces to CSFLE schemas. - `encryptedFieldsMap`: Optional object. Maps namespaces to QE schemas. - `extraOptions`: Optional object. Configuration options for the encryption library. + - If `extraOptions` is not present or omits `cryptSharedLibPath`, test runners MAY set `cryptSharedLibPath` to the + path of [crypt_shared](../client-side-encryption/client-side-encryption.md#crypt_shared) being tested. This + can avoid test errors loading crypt_shared from different paths. - `bypassQueryAnalysis`: Optional. Disables analysis of outgoing commands. Defaults to `false`. - `keyExpirationMS`: The same as in [`clientEncryption`](#entity_clientEncryption). @@ -3413,6 +3416,8 @@ other specs *and* collating spec changes developed in parallel or during the sam ## Changelog +- 2025-07-15: Clarify test runner may apply a default `cryptSharedLibPath`. + - 2025-06-10: **Schema version 1.24.** Deprecate `storeEventsAsEntities` option for client entities and `loop` operation in the schema and remove them from