From aaef436d88a61121b12a126e595d8527a1ab3df0 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Fri, 29 Aug 2025 18:53:53 +0200 Subject: [PATCH 1/7] feat(NODE-6883): allow rawData option on time series collections --- src/cmap/wire_protocol/constants.ts | 6 +- src/operations/aggregate.ts | 3 +- .../client_bulk_write/client_bulk_write.ts | 3 +- src/operations/command.ts | 18 +- src/operations/count.ts | 2 +- src/operations/delete.ts | 6 +- src/operations/distinct.ts | 7 +- src/operations/estimated_document_count.ts | 3 +- src/operations/find.ts | 3 +- src/operations/find_and_modify.ts | 3 +- src/operations/indexes.ts | 7 +- src/operations/insert.ts | 12 +- src/operations/list_collections.ts | 3 +- src/operations/operation.ts | 3 +- src/operations/update.ts | 9 +- src/utils.ts | 15 +- .../listCollections-rawdata.json | 97 +++++++++ .../listCollections-rawdata.yml | 49 +++++ test/spec/crud/unified/aggregate-rawdata.json | 116 ++++++++++ test/spec/crud/unified/aggregate-rawdata.yml | 55 +++++ .../unified/bulkWrite-deleteMany-rawdata.json | 122 +++++++++++ .../unified/bulkWrite-deleteMany-rawdata.yml | 61 ++++++ .../unified/bulkWrite-deleteOne-rawdata.json | 122 +++++++++++ .../unified/bulkWrite-deleteOne-rawdata.yml | 61 ++++++ .../unified/bulkWrite-replaceOne-rawdata.json | 136 ++++++++++++ .../unified/bulkWrite-replaceOne-rawdata.yml | 71 +++++++ .../unified/bulkWrite-updateMany-rawdata.json | 157 ++++++++++++++ .../unified/bulkWrite-updateMany-rawdata.yml | 72 +++++++ .../unified/bulkWrite-updateOne-rawdata.json | 161 ++++++++++++++ .../unified/bulkWrite-updateOne-rawdata.yml | 76 +++++++ .../client-bulkWrite-delete-rawdata.json | 171 +++++++++++++++ .../client-bulkWrite-delete-rawdata.yml | 94 +++++++++ .../client-bulkWrite-replaceOne-rawdata.json | 169 +++++++++++++++ .../client-bulkWrite-replaceOne-rawdata.yml | 92 ++++++++ .../client-bulkWrite-update-rawdata.json | 198 ++++++++++++++++++ .../client-bulkWrite-update-rawdata.yml | 103 +++++++++ test/spec/crud/unified/count-rawdata.json | 100 +++++++++ test/spec/crud/unified/count-rawdata.yml | 53 +++++ .../crud/unified/countDocuments-rawdata.json | 128 +++++++++++ .../crud/unified/countDocuments-rawdata.yml | 61 ++++++ .../crud/unified/db-aggregate-rawdata.json | 177 ++++++++++++++++ .../crud/unified/db-aggregate-rawdata.yml | 64 ++++++ .../spec/crud/unified/deleteMany-rawdata.json | 110 ++++++++++ test/spec/crud/unified/deleteMany-rawdata.yml | 57 +++++ test/spec/crud/unified/deleteOne-rawdata.json | 110 ++++++++++ test/spec/crud/unified/deleteOne-rawdata.yml | 57 +++++ test/spec/crud/unified/distinct-rawdata.json | 104 +++++++++ test/spec/crud/unified/distinct-rawdata.yml | 57 +++++ .../estimatedDocumentCount-rawdata.json | 100 +++++++++ .../estimatedDocumentCount-rawdata.yml | 53 +++++ test/spec/crud/unified/find-rawdata.json | 100 +++++++++ test/spec/crud/unified/find-rawdata.yml | 53 +++++ .../unified/findOneAndDelete-rawdata.json | 102 +++++++++ .../crud/unified/findOneAndDelete-rawdata.yml | 55 +++++ .../unified/findOneAndReplace-rawdata.json | 112 ++++++++++ .../unified/findOneAndReplace-rawdata.yml | 57 +++++ .../unified/findOneAndUpdate-rawdata.json | 129 ++++++++++++ .../crud/unified/findOneAndUpdate-rawdata.yml | 57 +++++ .../spec/crud/unified/insertMany-rawdata.json | 120 +++++++++++ test/spec/crud/unified/insertMany-rawdata.yml | 53 +++++ test/spec/crud/unified/insertOne-rawdata.json | 116 ++++++++++ test/spec/crud/unified/insertOne-rawdata.yml | 53 +++++ .../spec/crud/unified/replaceOne-rawdata.json | 132 ++++++++++++ test/spec/crud/unified/replaceOne-rawdata.yml | 67 ++++++ .../spec/crud/unified/updateMany-rawdata.json | 136 ++++++++++++ test/spec/crud/unified/updateMany-rawdata.yml | 65 ++++++ test/spec/crud/unified/updateOne-rawdata.json | 140 +++++++++++++ test/spec/crud/unified/updateOne-rawdata.yml | 67 ++++++ test/spec/index-management/index-rawdata.json | 186 ++++++++++++++++ test/spec/index-management/index-rawdata.yml | 95 +++++++++ .../unit/cmap/wire_protocol/constants.test.ts | 4 +- 71 files changed, 5391 insertions(+), 25 deletions(-) create mode 100644 test/spec/collection-management/listCollections-rawdata.json create mode 100644 test/spec/collection-management/listCollections-rawdata.yml create mode 100644 test/spec/crud/unified/aggregate-rawdata.json create mode 100644 test/spec/crud/unified/aggregate-rawdata.yml create mode 100644 test/spec/crud/unified/bulkWrite-deleteMany-rawdata.json create mode 100644 test/spec/crud/unified/bulkWrite-deleteMany-rawdata.yml create mode 100644 test/spec/crud/unified/bulkWrite-deleteOne-rawdata.json create mode 100644 test/spec/crud/unified/bulkWrite-deleteOne-rawdata.yml create mode 100644 test/spec/crud/unified/bulkWrite-replaceOne-rawdata.json create mode 100644 test/spec/crud/unified/bulkWrite-replaceOne-rawdata.yml create mode 100644 test/spec/crud/unified/bulkWrite-updateMany-rawdata.json create mode 100644 test/spec/crud/unified/bulkWrite-updateMany-rawdata.yml create mode 100644 test/spec/crud/unified/bulkWrite-updateOne-rawdata.json create mode 100644 test/spec/crud/unified/bulkWrite-updateOne-rawdata.yml create mode 100644 test/spec/crud/unified/client-bulkWrite-delete-rawdata.json create mode 100644 test/spec/crud/unified/client-bulkWrite-delete-rawdata.yml create mode 100644 test/spec/crud/unified/client-bulkWrite-replaceOne-rawdata.json create mode 100644 test/spec/crud/unified/client-bulkWrite-replaceOne-rawdata.yml create mode 100644 test/spec/crud/unified/client-bulkWrite-update-rawdata.json create mode 100644 test/spec/crud/unified/client-bulkWrite-update-rawdata.yml create mode 100644 test/spec/crud/unified/count-rawdata.json create mode 100644 test/spec/crud/unified/count-rawdata.yml create mode 100644 test/spec/crud/unified/countDocuments-rawdata.json create mode 100644 test/spec/crud/unified/countDocuments-rawdata.yml create mode 100644 test/spec/crud/unified/db-aggregate-rawdata.json create mode 100644 test/spec/crud/unified/db-aggregate-rawdata.yml create mode 100644 test/spec/crud/unified/deleteMany-rawdata.json create mode 100644 test/spec/crud/unified/deleteMany-rawdata.yml create mode 100644 test/spec/crud/unified/deleteOne-rawdata.json create mode 100644 test/spec/crud/unified/deleteOne-rawdata.yml create mode 100644 test/spec/crud/unified/distinct-rawdata.json create mode 100644 test/spec/crud/unified/distinct-rawdata.yml create mode 100644 test/spec/crud/unified/estimatedDocumentCount-rawdata.json create mode 100644 test/spec/crud/unified/estimatedDocumentCount-rawdata.yml create mode 100644 test/spec/crud/unified/find-rawdata.json create mode 100644 test/spec/crud/unified/find-rawdata.yml create mode 100644 test/spec/crud/unified/findOneAndDelete-rawdata.json create mode 100644 test/spec/crud/unified/findOneAndDelete-rawdata.yml create mode 100644 test/spec/crud/unified/findOneAndReplace-rawdata.json create mode 100644 test/spec/crud/unified/findOneAndReplace-rawdata.yml create mode 100644 test/spec/crud/unified/findOneAndUpdate-rawdata.json create mode 100644 test/spec/crud/unified/findOneAndUpdate-rawdata.yml create mode 100644 test/spec/crud/unified/insertMany-rawdata.json create mode 100644 test/spec/crud/unified/insertMany-rawdata.yml create mode 100644 test/spec/crud/unified/insertOne-rawdata.json create mode 100644 test/spec/crud/unified/insertOne-rawdata.yml create mode 100644 test/spec/crud/unified/replaceOne-rawdata.json create mode 100644 test/spec/crud/unified/replaceOne-rawdata.yml create mode 100644 test/spec/crud/unified/updateMany-rawdata.json create mode 100644 test/spec/crud/unified/updateMany-rawdata.yml create mode 100644 test/spec/crud/unified/updateOne-rawdata.json create mode 100644 test/spec/crud/unified/updateOne-rawdata.yml create mode 100644 test/spec/index-management/index-rawdata.json create mode 100644 test/spec/index-management/index-rawdata.yml diff --git a/src/cmap/wire_protocol/constants.ts b/src/cmap/wire_protocol/constants.ts index 3c579528c50..60ebf6d68f8 100644 --- a/src/cmap/wire_protocol/constants.ts +++ b/src/cmap/wire_protocol/constants.ts @@ -1,9 +1,11 @@ export const MIN_SUPPORTED_SERVER_VERSION = '4.2'; -export const MAX_SUPPORTED_SERVER_VERSION = '8.0'; +export const MAX_SUPPORTED_SERVER_VERSION = '8.2'; export const MIN_SUPPORTED_WIRE_VERSION = 8; -export const MAX_SUPPORTED_WIRE_VERSION = 25; +export const MAX_SUPPORTED_WIRE_VERSION = 27; export const MIN_SUPPORTED_QE_WIRE_VERSION = 21; export const MIN_SUPPORTED_QE_SERVER_VERSION = '7.0'; +export const MIN_SUPPORTED_RAW_DATA_WIRE_VERSION = 27; +export const MIN_SUPPORTED_RAW_DATA_SERVER_VERSION = '8.2'; export const OP_REPLY = 1; export const OP_UPDATE = 2001; export const OP_INSERT = 2002; diff --git a/src/operations/aggregate.ts b/src/operations/aggregate.ts index 3d5731d4c5d..620ee4ea601 100644 --- a/src/operations/aggregate.ts +++ b/src/operations/aggregate.ts @@ -161,5 +161,6 @@ defineAspects(AggregateOperation, [ Aspect.READ_OPERATION, Aspect.RETRYABLE, Aspect.EXPLAINABLE, - Aspect.CURSOR_CREATING + Aspect.CURSOR_CREATING, + Aspect.SUPPORTS_RAW_DATA ]); diff --git a/src/operations/client_bulk_write/client_bulk_write.ts b/src/operations/client_bulk_write/client_bulk_write.ts index 6f9af73534a..0c78cb7cded 100644 --- a/src/operations/client_bulk_write/client_bulk_write.ts +++ b/src/operations/client_bulk_write/client_bulk_write.ts @@ -67,5 +67,6 @@ defineAspects(ClientBulkWriteOperation, [ Aspect.SKIP_COLLATION, Aspect.CURSOR_CREATING, Aspect.RETRYABLE, - Aspect.COMMAND_BATCHING + Aspect.COMMAND_BATCHING, + Aspect.SUPPORTS_RAW_DATA ]); diff --git a/src/operations/command.ts b/src/operations/command.ts index a4a2d1fbf9b..74c35ac4eb2 100644 --- a/src/operations/command.ts +++ b/src/operations/command.ts @@ -1,5 +1,6 @@ import { type Connection } from '..'; import type { BSONSerializeOptions, Document } from '../bson'; +import { MIN_SUPPORTED_RAW_DATA_WIRE_VERSION } from '../cmap/wire_protocol/constants'; import { MongoInvalidArgumentError } from '../error'; import { decorateWithExplain, @@ -12,7 +13,7 @@ import type { ReadPreference } from '../read_preference'; import type { ServerCommandOptions } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { type TimeoutContext } from '../timeout'; -import { commandSupportsReadConcern, MongoDBNamespace } from '../utils'; +import { commandSupportsReadConcern, maxWireVersion, MongoDBNamespace } from '../utils'; import { WriteConcern, type WriteConcernOptions } from '../write_concern'; import type { ReadConcernLike } from './../read_concern'; import { AbstractOperation, Aspect, type OperationOptions } from './operation'; @@ -63,6 +64,13 @@ export interface CommandOperationOptions * This option is deprecated and will be removed in an upcoming major version. */ noResponse?: boolean; + + /** + * Used when the command needs to grant access to the underlying namespaces for time series collections. + * Only available on server versions 8.2 and above. + * @public + **/ + rawData?: boolean; } /** @internal */ @@ -153,6 +161,14 @@ export abstract class CommandOperation extends AbstractOperation { command.maxTimeMS = this.options.maxTimeMS; } + if ( + this.options.rawData != null && + this.hasAspect(Aspect.SUPPORTS_RAW_DATA) && + maxWireVersion(connection) >= MIN_SUPPORTED_RAW_DATA_WIRE_VERSION + ) { + command.rawData = this.options.rawData; + } + if (this.hasAspect(Aspect.EXPLAINABLE) && this.explain) { return decorateWithExplain(command, this.explain); } diff --git a/src/operations/count.ts b/src/operations/count.ts index 08b4c9c66a1..5f4178ce599 100644 --- a/src/operations/count.ts +++ b/src/operations/count.ts @@ -71,4 +71,4 @@ export class CountOperation extends CommandOperation { } } -defineAspects(CountOperation, [Aspect.READ_OPERATION, Aspect.RETRYABLE]); +defineAspects(CountOperation, [Aspect.READ_OPERATION, Aspect.RETRYABLE, Aspect.SUPPORTS_RAW_DATA]); diff --git a/src/operations/delete.ts b/src/operations/delete.ts index 9f97f487be9..054ab8d6169 100644 --- a/src/operations/delete.ts +++ b/src/operations/delete.ts @@ -167,10 +167,12 @@ defineAspects(DeleteOneOperation, [ Aspect.RETRYABLE, Aspect.WRITE_OPERATION, Aspect.EXPLAINABLE, - Aspect.SKIP_COLLATION + Aspect.SKIP_COLLATION, + Aspect.SUPPORTS_RAW_DATA ]); defineAspects(DeleteManyOperation, [ Aspect.WRITE_OPERATION, Aspect.EXPLAINABLE, - Aspect.SKIP_COLLATION + Aspect.SKIP_COLLATION, + Aspect.SUPPORTS_RAW_DATA ]); diff --git a/src/operations/distinct.ts b/src/operations/distinct.ts index 1236fcf17a7..1ed3f80de1f 100644 --- a/src/operations/distinct.ts +++ b/src/operations/distinct.ts @@ -84,4 +84,9 @@ export class DistinctOperation extends CommandOperation { } } -defineAspects(DistinctOperation, [Aspect.READ_OPERATION, Aspect.RETRYABLE, Aspect.EXPLAINABLE]); +defineAspects(DistinctOperation, [ + Aspect.READ_OPERATION, + Aspect.RETRYABLE, + Aspect.EXPLAINABLE, + Aspect.SUPPORTS_RAW_DATA +]); diff --git a/src/operations/estimated_document_count.ts b/src/operations/estimated_document_count.ts index b32ab76f2d7..2541b69b2af 100644 --- a/src/operations/estimated_document_count.ts +++ b/src/operations/estimated_document_count.ts @@ -56,5 +56,6 @@ export class EstimatedDocumentCountOperation extends CommandOperation { defineAspects(EstimatedDocumentCountOperation, [ Aspect.READ_OPERATION, Aspect.RETRYABLE, - Aspect.CURSOR_CREATING + Aspect.CURSOR_CREATING, + Aspect.SUPPORTS_RAW_DATA ]); diff --git a/src/operations/find.ts b/src/operations/find.ts index 454a9b1e0c3..c78c7c05e8c 100644 --- a/src/operations/find.ts +++ b/src/operations/find.ts @@ -258,5 +258,6 @@ defineAspects(FindOperation, [ Aspect.READ_OPERATION, Aspect.RETRYABLE, Aspect.EXPLAINABLE, - Aspect.CURSOR_CREATING + Aspect.CURSOR_CREATING, + Aspect.SUPPORTS_RAW_DATA ]); diff --git a/src/operations/find_and_modify.ts b/src/operations/find_and_modify.ts index b8c573e3adc..ce8ac60a18f 100644 --- a/src/operations/find_and_modify.ts +++ b/src/operations/find_and_modify.ts @@ -314,5 +314,6 @@ export class FindOneAndUpdateOperation extends FindAndModifyOperation { defineAspects(FindAndModifyOperation, [ Aspect.WRITE_OPERATION, Aspect.RETRYABLE, - Aspect.EXPLAINABLE + Aspect.EXPLAINABLE, + Aspect.SUPPORTS_RAW_DATA ]); diff --git a/src/operations/indexes.ts b/src/operations/indexes.ts index ed761d2977e..d98f445c724 100644 --- a/src/operations/indexes.ts +++ b/src/operations/indexes.ts @@ -409,7 +409,8 @@ export class ListIndexesOperation extends CommandOperation { defineAspects(ListIndexesOperation, [ Aspect.READ_OPERATION, Aspect.RETRYABLE, - Aspect.CURSOR_CREATING + Aspect.CURSOR_CREATING, + Aspect.SUPPORTS_RAW_DATA ]); -defineAspects(CreateIndexesOperation, [Aspect.WRITE_OPERATION]); -defineAspects(DropIndexOperation, [Aspect.WRITE_OPERATION]); +defineAspects(CreateIndexesOperation, [Aspect.WRITE_OPERATION, Aspect.SUPPORTS_RAW_DATA]); +defineAspects(DropIndexOperation, [Aspect.WRITE_OPERATION, Aspect.SUPPORTS_RAW_DATA]); diff --git a/src/operations/insert.ts b/src/operations/insert.ts index 85269c8f922..45d470bf05c 100644 --- a/src/operations/insert.ts +++ b/src/operations/insert.ts @@ -96,5 +96,13 @@ export interface InsertManyResult { insertedIds: { [key: number]: InferIdType }; } -defineAspects(InsertOperation, [Aspect.RETRYABLE, Aspect.WRITE_OPERATION]); -defineAspects(InsertOneOperation, [Aspect.RETRYABLE, Aspect.WRITE_OPERATION]); +defineAspects(InsertOperation, [ + Aspect.RETRYABLE, + Aspect.WRITE_OPERATION, + Aspect.SUPPORTS_RAW_DATA +]); +defineAspects(InsertOneOperation, [ + Aspect.RETRYABLE, + Aspect.WRITE_OPERATION, + Aspect.SUPPORTS_RAW_DATA +]); diff --git a/src/operations/list_collections.ts b/src/operations/list_collections.ts index a96266e4138..df38c954cb9 100644 --- a/src/operations/list_collections.ts +++ b/src/operations/list_collections.ts @@ -103,5 +103,6 @@ export interface CollectionInfo extends Document { defineAspects(ListCollectionsOperation, [ Aspect.READ_OPERATION, Aspect.RETRYABLE, - Aspect.CURSOR_CREATING + Aspect.CURSOR_CREATING, + Aspect.SUPPORTS_RAW_DATA ]); diff --git a/src/operations/operation.ts b/src/operations/operation.ts index 0541175fea7..cb0181ee555 100644 --- a/src/operations/operation.ts +++ b/src/operations/operation.ts @@ -16,7 +16,8 @@ export const Aspect = { SKIP_COLLATION: Symbol('SKIP_COLLATION'), CURSOR_CREATING: Symbol('CURSOR_CREATING'), MUST_SELECT_SAME_SERVER: Symbol('MUST_SELECT_SAME_SERVER'), - COMMAND_BATCHING: Symbol('COMMAND_BATCHING') + COMMAND_BATCHING: Symbol('COMMAND_BATCHING'), + SUPPORTS_RAW_DATA: Symbol('SUPPORTS_RAW_DATA') } as const; /** @public */ diff --git a/src/operations/update.ts b/src/operations/update.ts index 089390fcf73..2d95b47a0ce 100644 --- a/src/operations/update.ts +++ b/src/operations/update.ts @@ -304,15 +304,18 @@ defineAspects(UpdateOneOperation, [ Aspect.RETRYABLE, Aspect.WRITE_OPERATION, Aspect.EXPLAINABLE, - Aspect.SKIP_COLLATION + Aspect.SKIP_COLLATION, + Aspect.SUPPORTS_RAW_DATA ]); defineAspects(UpdateManyOperation, [ Aspect.WRITE_OPERATION, Aspect.EXPLAINABLE, - Aspect.SKIP_COLLATION + Aspect.SKIP_COLLATION, + Aspect.SUPPORTS_RAW_DATA ]); defineAspects(ReplaceOneOperation, [ Aspect.RETRYABLE, Aspect.WRITE_OPERATION, - Aspect.SKIP_COLLATION + Aspect.SKIP_COLLATION, + Aspect.SUPPORTS_RAW_DATA ]); diff --git a/src/utils.ts b/src/utils.ts index c6f40fb43e9..f2e24d5d888 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -10,7 +10,10 @@ import { promisify } from 'util'; import { deserialize, type Document, ObjectId, resolveBSONOptions } from './bson'; import type { Connection } from './cmap/connection'; -import { MAX_SUPPORTED_WIRE_VERSION } from './cmap/wire_protocol/constants'; +import { + MAX_SUPPORTED_WIRE_VERSION, + MIN_SUPPORTED_RAW_DATA_WIRE_VERSION +} from './cmap/wire_protocol/constants'; import type { Collection } from './collection'; import { kDecoratedKeys, LEGACY_HELLO_COMMAND } from './constants'; import type { AbstractCursor } from './cursor/abstract_cursor'; @@ -1356,6 +1359,16 @@ export async function once(ee: EventEmitter, name: string, options?: Abortabl } } +export function decorateRawData( + command: Document, + rawData: boolean, + serverWireVersion: number +): void { + if (rawData && serverWireVersion >= MIN_SUPPORTED_RAW_DATA_WIRE_VERSION) { + command.rawData = rawData; + } +} + export function maybeAddIdToDocuments( collection: Collection, document: Document, diff --git a/test/spec/collection-management/listCollections-rawdata.json b/test/spec/collection-management/listCollections-rawdata.json new file mode 100644 index 00000000000..ec09ec31db8 --- /dev/null +++ b/test/spec/collection-management/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/test/spec/collection-management/listCollections-rawdata.yml b/test/spec/collection-management/listCollections-rawdata.yml new file mode 100644 index 00000000000..0a9f24cfac9 --- /dev/null +++ b/test/spec/collection-management/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/test/spec/crud/unified/aggregate-rawdata.json b/test/spec/crud/unified/aggregate-rawdata.json new file mode 100644 index 00000000000..d34a359f9d2 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/aggregate-rawdata.yml b/test/spec/crud/unified/aggregate-rawdata.yml new file mode 100644 index 00000000000..11a398e08a1 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/bulkWrite-deleteMany-rawdata.json b/test/spec/crud/unified/bulkWrite-deleteMany-rawdata.json new file mode 100644 index 00000000000..a74149e9797 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/bulkWrite-deleteMany-rawdata.yml b/test/spec/crud/unified/bulkWrite-deleteMany-rawdata.yml new file mode 100644 index 00000000000..f1722058afe --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/bulkWrite-deleteOne-rawdata.json b/test/spec/crud/unified/bulkWrite-deleteOne-rawdata.json new file mode 100644 index 00000000000..534e62c9e8d --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/bulkWrite-deleteOne-rawdata.yml b/test/spec/crud/unified/bulkWrite-deleteOne-rawdata.yml new file mode 100644 index 00000000000..75a66bf851b --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/bulkWrite-replaceOne-rawdata.json b/test/spec/crud/unified/bulkWrite-replaceOne-rawdata.json new file mode 100644 index 00000000000..50403fc5c39 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/bulkWrite-replaceOne-rawdata.yml b/test/spec/crud/unified/bulkWrite-replaceOne-rawdata.yml new file mode 100644 index 00000000000..60f3af8c9b3 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/bulkWrite-updateMany-rawdata.json b/test/spec/crud/unified/bulkWrite-updateMany-rawdata.json new file mode 100644 index 00000000000..4f807ae42a0 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/bulkWrite-updateMany-rawdata.yml b/test/spec/crud/unified/bulkWrite-updateMany-rawdata.yml new file mode 100644 index 00000000000..ac5d67fb458 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/bulkWrite-updateOne-rawdata.json b/test/spec/crud/unified/bulkWrite-updateOne-rawdata.json new file mode 100644 index 00000000000..32b53cbf298 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/bulkWrite-updateOne-rawdata.yml b/test/spec/crud/unified/bulkWrite-updateOne-rawdata.yml new file mode 100644 index 00000000000..86415a54129 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/client-bulkWrite-delete-rawdata.json b/test/spec/crud/unified/client-bulkWrite-delete-rawdata.json new file mode 100644 index 00000000000..a9f476cfa4e --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/client-bulkWrite-delete-rawdata.yml b/test/spec/crud/unified/client-bulkWrite-delete-rawdata.yml new file mode 100644 index 00000000000..9c7e9dc3aad --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/client-bulkWrite-replaceOne-rawdata.json b/test/spec/crud/unified/client-bulkWrite-replaceOne-rawdata.json new file mode 100644 index 00000000000..22da494366e --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/client-bulkWrite-replaceOne-rawdata.yml b/test/spec/crud/unified/client-bulkWrite-replaceOne-rawdata.yml new file mode 100644 index 00000000000..c0cd5681942 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/client-bulkWrite-update-rawdata.json b/test/spec/crud/unified/client-bulkWrite-update-rawdata.json new file mode 100644 index 00000000000..63f86f19d90 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/client-bulkWrite-update-rawdata.yml b/test/spec/crud/unified/client-bulkWrite-update-rawdata.yml new file mode 100644 index 00000000000..f53f7c958c3 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/count-rawdata.json b/test/spec/crud/unified/count-rawdata.json new file mode 100644 index 00000000000..44772d40fbe --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/count-rawdata.yml b/test/spec/crud/unified/count-rawdata.yml new file mode 100644 index 00000000000..845606c9dd0 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/countDocuments-rawdata.json b/test/spec/crud/unified/countDocuments-rawdata.json new file mode 100644 index 00000000000..1651a7fe2d4 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/countDocuments-rawdata.yml b/test/spec/crud/unified/countDocuments-rawdata.yml new file mode 100644 index 00000000000..b0a7408267d --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/db-aggregate-rawdata.json b/test/spec/crud/unified/db-aggregate-rawdata.json new file mode 100644 index 00000000000..61e22b9fbea --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/db-aggregate-rawdata.yml b/test/spec/crud/unified/db-aggregate-rawdata.yml new file mode 100644 index 00000000000..1a6b21ca291 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/deleteMany-rawdata.json b/test/spec/crud/unified/deleteMany-rawdata.json new file mode 100644 index 00000000000..fbdc8527082 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/deleteMany-rawdata.yml b/test/spec/crud/unified/deleteMany-rawdata.yml new file mode 100644 index 00000000000..d6c1f334781 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/deleteOne-rawdata.json b/test/spec/crud/unified/deleteOne-rawdata.json new file mode 100644 index 00000000000..43475485833 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/deleteOne-rawdata.yml b/test/spec/crud/unified/deleteOne-rawdata.yml new file mode 100644 index 00000000000..6d9eb72f82d --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/distinct-rawdata.json b/test/spec/crud/unified/distinct-rawdata.json new file mode 100644 index 00000000000..d1a4abc7f70 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/distinct-rawdata.yml b/test/spec/crud/unified/distinct-rawdata.yml new file mode 100644 index 00000000000..b6eeab9552e --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/estimatedDocumentCount-rawdata.json b/test/spec/crud/unified/estimatedDocumentCount-rawdata.json new file mode 100644 index 00000000000..4c79863e98f --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/estimatedDocumentCount-rawdata.yml b/test/spec/crud/unified/estimatedDocumentCount-rawdata.yml new file mode 100644 index 00000000000..7c07a569902 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/find-rawdata.json b/test/spec/crud/unified/find-rawdata.json new file mode 100644 index 00000000000..778e289880b --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/find-rawdata.yml b/test/spec/crud/unified/find-rawdata.yml new file mode 100644 index 00000000000..f260d339436 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/findOneAndDelete-rawdata.json b/test/spec/crud/unified/findOneAndDelete-rawdata.json new file mode 100644 index 00000000000..1ace780b74e --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/findOneAndDelete-rawdata.yml b/test/spec/crud/unified/findOneAndDelete-rawdata.yml new file mode 100644 index 00000000000..27f52321ed7 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/findOneAndReplace-rawdata.json b/test/spec/crud/unified/findOneAndReplace-rawdata.json new file mode 100644 index 00000000000..b48a2a4210a --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/findOneAndReplace-rawdata.yml b/test/spec/crud/unified/findOneAndReplace-rawdata.yml new file mode 100644 index 00000000000..4007a0fe53b --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/findOneAndUpdate-rawdata.json b/test/spec/crud/unified/findOneAndUpdate-rawdata.json new file mode 100644 index 00000000000..a689e73f7b5 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/findOneAndUpdate-rawdata.yml b/test/spec/crud/unified/findOneAndUpdate-rawdata.yml new file mode 100644 index 00000000000..fb99905e2dd --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/insertMany-rawdata.json b/test/spec/crud/unified/insertMany-rawdata.json new file mode 100644 index 00000000000..50852592df9 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/insertMany-rawdata.yml b/test/spec/crud/unified/insertMany-rawdata.yml new file mode 100644 index 00000000000..562be344d87 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/insertOne-rawdata.json b/test/spec/crud/unified/insertOne-rawdata.json new file mode 100644 index 00000000000..d010c2daac6 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/insertOne-rawdata.yml b/test/spec/crud/unified/insertOne-rawdata.yml new file mode 100644 index 00000000000..7b14fd6e280 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/replaceOne-rawdata.json b/test/spec/crud/unified/replaceOne-rawdata.json new file mode 100644 index 00000000000..632404491cf --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/replaceOne-rawdata.yml b/test/spec/crud/unified/replaceOne-rawdata.yml new file mode 100644 index 00000000000..1b81c1f3f6d --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/updateMany-rawdata.json b/test/spec/crud/unified/updateMany-rawdata.json new file mode 100644 index 00000000000..20417e0770a --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/updateMany-rawdata.yml b/test/spec/crud/unified/updateMany-rawdata.yml new file mode 100644 index 00000000000..75b2587fa33 --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/updateOne-rawdata.json b/test/spec/crud/unified/updateOne-rawdata.json new file mode 100644 index 00000000000..8f703d9a40a --- /dev/null +++ b/test/spec/crud/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/test/spec/crud/unified/updateOne-rawdata.yml b/test/spec/crud/unified/updateOne-rawdata.yml new file mode 100644 index 00000000000..a22110d3761 --- /dev/null +++ b/test/spec/crud/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/test/spec/index-management/index-rawdata.json b/test/spec/index-management/index-rawdata.json new file mode 100644 index 00000000000..791a643a0fb --- /dev/null +++ b/test/spec/index-management/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/test/spec/index-management/index-rawdata.yml b/test/spec/index-management/index-rawdata.yml new file mode 100644 index 00000000000..b0b692b6644 --- /dev/null +++ b/test/spec/index-management/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/test/unit/cmap/wire_protocol/constants.test.ts b/test/unit/cmap/wire_protocol/constants.test.ts index 1613bef3651..e43b2051926 100644 --- a/test/unit/cmap/wire_protocol/constants.test.ts +++ b/test/unit/cmap/wire_protocol/constants.test.ts @@ -16,7 +16,7 @@ describe('Wire Protocol Constants', function () { describe('MAX_SUPPORTED_SERVER_VERSION', function () { it('returns 8.0', function () { - expect(MAX_SUPPORTED_SERVER_VERSION).to.equal('8.0'); + expect(MAX_SUPPORTED_SERVER_VERSION).to.equal('8.2'); }); }); @@ -28,7 +28,7 @@ describe('Wire Protocol Constants', function () { describe('MAX_SUPPORTED_WIRE_VERSION', function () { it('returns 25', function () { - expect(MAX_SUPPORTED_WIRE_VERSION).to.equal(25); + expect(MAX_SUPPORTED_WIRE_VERSION).to.equal(27); }); }); }); From 31efb3afe7f09c6ae1d7fe21cad39ad690370e6b Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Fri, 29 Aug 2025 19:01:46 +0200 Subject: [PATCH 2/7] refactor: remove unused function --- src/utils.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index f2e24d5d888..c6f40fb43e9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -10,10 +10,7 @@ import { promisify } from 'util'; import { deserialize, type Document, ObjectId, resolveBSONOptions } from './bson'; import type { Connection } from './cmap/connection'; -import { - MAX_SUPPORTED_WIRE_VERSION, - MIN_SUPPORTED_RAW_DATA_WIRE_VERSION -} from './cmap/wire_protocol/constants'; +import { MAX_SUPPORTED_WIRE_VERSION } from './cmap/wire_protocol/constants'; import type { Collection } from './collection'; import { kDecoratedKeys, LEGACY_HELLO_COMMAND } from './constants'; import type { AbstractCursor } from './cursor/abstract_cursor'; @@ -1359,16 +1356,6 @@ export async function once(ee: EventEmitter, name: string, options?: Abortabl } } -export function decorateRawData( - command: Document, - rawData: boolean, - serverWireVersion: number -): void { - if (rawData && serverWireVersion >= MIN_SUPPORTED_RAW_DATA_WIRE_VERSION) { - command.rawData = rawData; - } -} - export function maybeAddIdToDocuments( collection: Collection, document: Document, From 513372388af16e698b4b0c4c72c6dd9786cbd374 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Fri, 29 Aug 2025 19:30:40 +0200 Subject: [PATCH 3/7] fix: collection bulk write --- src/operations/delete.ts | 6 +++++- src/operations/update.ts | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/operations/delete.ts b/src/operations/delete.ts index 054ab8d6169..570552e4e30 100644 --- a/src/operations/delete.ts +++ b/src/operations/delete.ts @@ -162,7 +162,11 @@ export function makeDeleteStatement( return op; } -defineAspects(DeleteOperation, [Aspect.RETRYABLE, Aspect.WRITE_OPERATION]); +defineAspects(DeleteOperation, [ + Aspect.RETRYABLE, + Aspect.WRITE_OPERATION, + Aspect.SUPPORTS_RAW_DATA +]); defineAspects(DeleteOneOperation, [ Aspect.RETRYABLE, Aspect.WRITE_OPERATION, diff --git a/src/operations/update.ts b/src/operations/update.ts index 2d95b47a0ce..23b3da42e36 100644 --- a/src/operations/update.ts +++ b/src/operations/update.ts @@ -299,7 +299,12 @@ export function makeUpdateStatement( return op; } -defineAspects(UpdateOperation, [Aspect.RETRYABLE, Aspect.WRITE_OPERATION, Aspect.SKIP_COLLATION]); +defineAspects(UpdateOperation, [ + Aspect.RETRYABLE, + Aspect.WRITE_OPERATION, + Aspect.SKIP_COLLATION, + Aspect.SUPPORTS_RAW_DATA +]); defineAspects(UpdateOneOperation, [ Aspect.RETRYABLE, Aspect.WRITE_OPERATION, From 2c6e5e76dafd953ad671c192e0f89b4e36143fe2 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Fri, 29 Aug 2025 20:17:52 +0200 Subject: [PATCH 4/7] fix: lb mode fixes --- src/utils.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index c6f40fb43e9..acb9025b8d3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -361,13 +361,8 @@ export function uuidV4(): Buffer { */ export function maxWireVersion(topologyOrServer?: Connection | Topology | Server): number { if (topologyOrServer) { - if (topologyOrServer.loadBalanced || topologyOrServer.serverApi?.version) { - // Since we do not have a monitor in the load balanced mode, - // we assume the load-balanced server is always pointed at the latest mongodb version. - // There is a risk that for on-prem deployments - // that don't upgrade immediately that this could alert to the - // application that a feature is available that is actually not. - // We also return the max supported wire version for serverAPI. + if (topologyOrServer.serverApi?.version) { + // We return the max supported wire version for serverAPI. return MAX_SUPPORTED_WIRE_VERSION; } if (topologyOrServer.hello) { @@ -388,6 +383,17 @@ export function maxWireVersion(topologyOrServer?: Connection | Topology | Server ) { return topologyOrServer.description.maxWireVersion; } + + // This is the fallback case for load balanced mode. If we are building commands the + // object being checked will be a connection, and we will have a hello response on + // it. For other cases, such as retryable writes, the object will be a server or + // topology, and there will be no hello response on those objects, so we return + // the max wire version so we support retryability. Once we have a min supported + // wire version of 9, then the needsRetryableWriteLabel() check can remove the + // usage of passing the wire version into it. + if (topologyOrServer.loadBalanced) { + return MAX_SUPPORTED_WIRE_VERSION; + } } return 0; From 19239dfbfec9418cf87f195bb792fe87bcbb84b6 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Fri, 29 Aug 2025 23:04:49 +0200 Subject: [PATCH 5/7] refactor: rename misleading param --- src/utils.ts | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index acb9025b8d3..6db4c3db339 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -359,29 +359,14 @@ export function uuidV4(): Buffer { * A helper function for determining `maxWireVersion` between legacy and new topology instances * @internal */ -export function maxWireVersion(topologyOrServer?: Connection | Topology | Server): number { - if (topologyOrServer) { - if (topologyOrServer.serverApi?.version) { +export function maxWireVersion(handshakeAware?: Connection | Topology | Server): number { + if (handshakeAware) { + if (handshakeAware.serverApi?.version) { // We return the max supported wire version for serverAPI. return MAX_SUPPORTED_WIRE_VERSION; } - if (topologyOrServer.hello) { - return topologyOrServer.hello.maxWireVersion; - } - - if ('lastHello' in topologyOrServer && typeof topologyOrServer.lastHello === 'function') { - const lastHello = topologyOrServer.lastHello(); - if (lastHello) { - return lastHello.maxWireVersion; - } - } - - if ( - topologyOrServer.description && - 'maxWireVersion' in topologyOrServer.description && - topologyOrServer.description.maxWireVersion != null - ) { - return topologyOrServer.description.maxWireVersion; + if (handshakeAware.hello) { + return handshakeAware.hello.maxWireVersion; } // This is the fallback case for load balanced mode. If we are building commands the @@ -391,9 +376,24 @@ export function maxWireVersion(topologyOrServer?: Connection | Topology | Server // the max wire version so we support retryability. Once we have a min supported // wire version of 9, then the needsRetryableWriteLabel() check can remove the // usage of passing the wire version into it. - if (topologyOrServer.loadBalanced) { + if (handshakeAware.loadBalanced) { return MAX_SUPPORTED_WIRE_VERSION; } + + if ('lastHello' in handshakeAware && typeof handshakeAware.lastHello === 'function') { + const lastHello = handshakeAware.lastHello(); + if (lastHello) { + return lastHello.maxWireVersion; + } + } + + if ( + handshakeAware.description && + 'maxWireVersion' in handshakeAware.description && + handshakeAware.description.maxWireVersion != null + ) { + return handshakeAware.description.maxWireVersion; + } } return 0; From 464fb450db81ae2696b5fb162084e10c34fa211c Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Thu, 4 Sep 2025 19:36:05 +0200 Subject: [PATCH 6/7] chore: comments --- src/operations/command.ts | 1 + src/operations/indexes.ts | 2 +- src/utils.ts | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/operations/command.ts b/src/operations/command.ts index 74c35ac4eb2..d4cde5b6478 100644 --- a/src/operations/command.ts +++ b/src/operations/command.ts @@ -69,6 +69,7 @@ export interface CommandOperationOptions * Used when the command needs to grant access to the underlying namespaces for time series collections. * Only available on server versions 8.2 and above. * @public + * @sinceServerVersion 8.2 **/ rawData?: boolean; } diff --git a/src/operations/indexes.ts b/src/operations/indexes.ts index d98f445c724..aa4b991025a 100644 --- a/src/operations/indexes.ts +++ b/src/operations/indexes.ts @@ -368,7 +368,7 @@ export class ListIndexesOperation extends CommandOperation { * This allows typescript to delete the key but will * not allow a writeConcern to be assigned as a property on options. */ - override options: ListIndexesOptions & { writeConcern?: never }; + override options: ListIndexesOptions & { writeConcern?: never; rawData?: boolean }; collectionNamespace: MongoDBNamespace; constructor(collection: Collection, options?: ListIndexesOptions) { diff --git a/src/utils.ts b/src/utils.ts index 6db4c3db339..cab65ce58fa 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -361,14 +361,14 @@ export function uuidV4(): Buffer { */ export function maxWireVersion(handshakeAware?: Connection | Topology | Server): number { if (handshakeAware) { - if (handshakeAware.serverApi?.version) { - // We return the max supported wire version for serverAPI. - return MAX_SUPPORTED_WIRE_VERSION; - } if (handshakeAware.hello) { return handshakeAware.hello.maxWireVersion; } + if (handshakeAware.serverApi?.version) { + // We return the max supported wire version for serverAPI. + return MAX_SUPPORTED_WIRE_VERSION; + } // This is the fallback case for load balanced mode. If we are building commands the // object being checked will be a connection, and we will have a hello response on // it. For other cases, such as retryable writes, the object will be a server or From af2592e206b8333b41cf6d6a1ad6917956706f4a Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Fri, 5 Sep 2025 06:57:34 +0200 Subject: [PATCH 7/7] chore: emit raw data from unsupported command options --- src/operations/create_collection.ts | 2 +- src/operations/drop.ts | 2 +- src/operations/list_databases.ts | 2 +- src/operations/profiling_level.ts | 2 +- src/operations/remove_user.ts | 2 +- src/operations/rename.ts | 2 +- src/operations/set_profiling_level.ts | 2 +- src/operations/stats.ts | 2 +- src/operations/validate_collection.ts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/operations/create_collection.ts b/src/operations/create_collection.ts index 8c35dfedcce..888f1077390 100644 --- a/src/operations/create_collection.ts +++ b/src/operations/create_collection.ts @@ -65,7 +65,7 @@ export interface ClusteredCollectionOptions extends Document { } /** @public */ -export interface CreateCollectionOptions extends CommandOperationOptions { +export interface CreateCollectionOptions extends Omit { /** Create a capped collection */ capped?: boolean; /** @deprecated Create an index on the _id field of the document. This option is deprecated in MongoDB 3.2+ and will be removed once no longer supported by the server. */ diff --git a/src/operations/drop.ts b/src/operations/drop.ts index afb7c5ff061..55312392626 100644 --- a/src/operations/drop.ts +++ b/src/operations/drop.ts @@ -11,7 +11,7 @@ import { executeOperation } from './execute_operation'; import { Aspect, defineAspects } from './operation'; /** @public */ -export interface DropCollectionOptions extends CommandOperationOptions { +export interface DropCollectionOptions extends Omit { /** @experimental */ encryptedFields?: Document; } diff --git a/src/operations/list_databases.ts b/src/operations/list_databases.ts index 1dc72d54bf2..b9f4e97dda7 100644 --- a/src/operations/list_databases.ts +++ b/src/operations/list_databases.ts @@ -16,7 +16,7 @@ export interface ListDatabasesResult { } /** @public */ -export interface ListDatabasesOptions extends CommandOperationOptions { +export interface ListDatabasesOptions extends Omit { /** A query predicate that determines which databases are listed */ filter?: Document; /** A flag to indicate whether the command should return just the database names, or return both database names and size information */ diff --git a/src/operations/profiling_level.ts b/src/operations/profiling_level.ts index d3493fe5754..8308db81812 100644 --- a/src/operations/profiling_level.ts +++ b/src/operations/profiling_level.ts @@ -6,7 +6,7 @@ import { MongoUnexpectedServerResponseError } from '../error'; import { CommandOperation, type CommandOperationOptions } from './command'; /** @public */ -export type ProfilingLevelOptions = CommandOperationOptions; +export type ProfilingLevelOptions = Omit; class ProfilingLevelResponse extends MongoDBResponse { get was() { diff --git a/src/operations/remove_user.ts b/src/operations/remove_user.ts index 7b06b1b8cbd..20e92ad0d9d 100644 --- a/src/operations/remove_user.ts +++ b/src/operations/remove_user.ts @@ -6,7 +6,7 @@ import { CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects } from './operation'; /** @public */ -export type RemoveUserOptions = CommandOperationOptions; +export type RemoveUserOptions = Omit; /** @internal */ export class RemoveUserOperation extends CommandOperation { diff --git a/src/operations/rename.ts b/src/operations/rename.ts index a0efb47a6d7..8969d27cde0 100644 --- a/src/operations/rename.ts +++ b/src/operations/rename.ts @@ -8,7 +8,7 @@ import { CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects } from './operation'; /** @public */ -export interface RenameOptions extends CommandOperationOptions { +export interface RenameOptions extends Omit { /** Drop the target name collection if it previously exists. */ dropTarget?: boolean; /** Unclear */ diff --git a/src/operations/set_profiling_level.ts b/src/operations/set_profiling_level.ts index 3b9ead5c3a2..bf97747cd94 100644 --- a/src/operations/set_profiling_level.ts +++ b/src/operations/set_profiling_level.ts @@ -19,7 +19,7 @@ export const ProfilingLevel = Object.freeze({ export type ProfilingLevel = (typeof ProfilingLevel)[keyof typeof ProfilingLevel]; /** @public */ -export type SetProfilingLevelOptions = CommandOperationOptions; +export type SetProfilingLevelOptions = Omit; /** @internal */ export class SetProfilingLevelOperation extends CommandOperation { diff --git a/src/operations/stats.ts b/src/operations/stats.ts index ede37c63398..e5f91501596 100644 --- a/src/operations/stats.ts +++ b/src/operations/stats.ts @@ -6,7 +6,7 @@ import { CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects } from './operation'; /** @public */ -export interface DbStatsOptions extends CommandOperationOptions { +export interface DbStatsOptions extends Omit { /** Divide the returned sizes by scale value. */ scale?: number; } diff --git a/src/operations/validate_collection.ts b/src/operations/validate_collection.ts index 06977178e4e..fb5fec8dc4e 100644 --- a/src/operations/validate_collection.ts +++ b/src/operations/validate_collection.ts @@ -7,7 +7,7 @@ import type { ClientSession } from '../sessions'; import { CommandOperation, type CommandOperationOptions } from './command'; /** @public */ -export interface ValidateCollectionOptions extends CommandOperationOptions { +export interface ValidateCollectionOptions extends Omit { /** Validates a collection in the background, without interrupting read or write traffic (only in MongoDB 4.4+) */ background?: boolean; }