From a8b1768afae5b1bd0ee67fd5933b9c0757cb4191 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Thu, 10 Jul 2025 13:46:06 -0400 Subject: [PATCH 1/3] feat(NODE-6883): allow rawData on time series collections --- src/bulk/common.ts | 6 + src/cmap/wire_protocol/constants.ts | 6 +- src/operations/aggregate.ts | 15 +- .../client_bulk_write/client_bulk_write.ts | 6 +- src/operations/client_bulk_write/common.ts | 6 + src/operations/count.ts | 11 +- src/operations/delete.ts | 11 +- src/operations/distinct.ts | 16 +- src/operations/estimated_document_count.ts | 10 + src/operations/find.ts | 15 +- src/operations/find_and_modify.ts | 27 ++- src/operations/indexes.ts | 27 ++- src/operations/insert.ts | 16 +- src/operations/list_collections.ts | 9 +- src/operations/update.ts | 22 +- src/utils.ts | 15 +- test/integration/crud/crud.spec.test.ts | 2 +- .../listCollections-rawdata.json | 91 ++++++++ .../listCollections-rawdata.yml | 47 +++++ 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 +++++++++ 71 files changed, 5505 insertions(+), 16 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/bulk/common.ts b/src/bulk/common.ts index 50283c94f1e..a81d4507a55 100644 --- a/src/bulk/common.ts +++ b/src/bulk/common.ts @@ -852,6 +852,12 @@ export interface BulkWriteOptions extends CommandOperationOptions { /** @internal */ timeoutContext?: TimeoutContext; + /** + * 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; } /** 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 a11365a9e89..ed1f1fff921 100644 --- a/src/operations/aggregate.ts +++ b/src/operations/aggregate.ts @@ -1,4 +1,5 @@ import type { Document } from '../bson'; +import { MIN_SUPPORTED_RAW_DATA_WIRE_VERSION } from '../cmap/wire_protocol/constants'; import { CursorResponse, ExplainedCursorResponse } from '../cmap/wire_protocol/responses'; import { type CursorTimeoutMode } from '../cursor/abstract_cursor'; import { MongoInvalidArgumentError } from '../error'; @@ -6,7 +7,7 @@ import { type ExplainOptions } from '../explain'; import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { type TimeoutContext } from '../timeout'; -import { maxWireVersion, type MongoDBNamespace } from '../utils'; +import { decorateRawData, maxWireVersion, type MongoDBNamespace } from '../utils'; import { WriteConcern } from '../write_concern'; import { type CollationOptions, CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects, type Hint } from './operation'; @@ -48,6 +49,12 @@ export interface AggregateOptions extends Omit { command.cursor.batchSize = options.batchSize; } + decorateRawData(command, !!options.rawData, serverWireVersion); + + if (options.rawData != null && serverWireVersion >= MIN_SUPPORTED_RAW_DATA_WIRE_VERSION) { + command.rawData = options.rawData; + } + return await super.executeCommand( server, session, diff --git a/src/operations/client_bulk_write/client_bulk_write.ts b/src/operations/client_bulk_write/client_bulk_write.ts index 26d1e7bb60f..3cbc6036817 100644 --- a/src/operations/client_bulk_write/client_bulk_write.ts +++ b/src/operations/client_bulk_write/client_bulk_write.ts @@ -3,7 +3,7 @@ import { ClientBulkWriteCursorResponse } from '../../cmap/wire_protocol/response import type { Server } from '../../sdam/server'; import type { ClientSession } from '../../sessions'; import { type TimeoutContext } from '../../timeout'; -import { MongoDBNamespace } from '../../utils'; +import { decorateRawData, maxWireVersion, MongoDBNamespace } from '../../utils'; import { CommandOperation } from '../command'; import { Aspect, defineAspects } from '../operation'; import { type ClientBulkWriteCommandBuilder } from './command_builder'; @@ -47,6 +47,7 @@ export class ClientBulkWriteOperation extends CommandOperation { + const serverWireVersion = maxWireVersion(server); let command; if (server.description.type === ServerType.LoadBalancer) { @@ -95,6 +96,9 @@ export class ClientBulkWriteOperation extends CommandOperation { timeoutContext: TimeoutContext ): Promise { const options = this.options; + const serverWireVersion = maxWireVersion(server); const cmd: Document = { count: this.collectionName, query: this.query @@ -66,6 +73,8 @@ export class CountOperation extends CommandOperation { cmd.maxTimeMS = options.maxTimeMS; } + decorateRawData(cmd, !!options.rawData, serverWireVersion); + const result = await super.executeCommand(server, session, cmd, timeoutContext); return result ? result.n : 0; } diff --git a/src/operations/delete.ts b/src/operations/delete.ts index 0e93ead36a2..6755d2c50fb 100644 --- a/src/operations/delete.ts +++ b/src/operations/delete.ts @@ -5,7 +5,7 @@ import { type TODO_NODE_3286 } from '../mongo_types'; import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { type TimeoutContext } from '../timeout'; -import { type MongoDBNamespace } from '../utils'; +import { decorateRawData, maxWireVersion, type MongoDBNamespace } from '../utils'; import { type WriteConcernOptions } from '../write_concern'; import { type CollationOptions, CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects, type Hint } from './operation'; @@ -20,6 +20,12 @@ export interface DeleteOptions extends CommandOperationOptions, WriteConcernOpti hint?: string | Document; /** Map of parameter names and values that can be accessed using $$var (requires MongoDB 5.0). */ let?: Document; + /** + * 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; } /** @public */ @@ -71,6 +77,7 @@ export class DeleteOperation extends CommandOperation { session: ClientSession | undefined, timeoutContext: TimeoutContext ): Promise { + const serverWireVersion = maxWireVersion(server); const options = this.options ?? {}; const ordered = typeof options.ordered === 'boolean' ? options.ordered : true; const command: Document = { @@ -97,6 +104,8 @@ export class DeleteOperation extends CommandOperation { } } + decorateRawData(command, !!this.options.rawData, serverWireVersion); + const res: TODO_NODE_3286 = await super.executeCommand( server, session, diff --git a/src/operations/distinct.ts b/src/operations/distinct.ts index cb6891fc475..4803e446c04 100644 --- a/src/operations/distinct.ts +++ b/src/operations/distinct.ts @@ -3,7 +3,12 @@ import type { Collection } from '../collection'; import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { type TimeoutContext } from '../timeout'; -import { decorateWithCollation, decorateWithReadConcern } from '../utils'; +import { + decorateRawData, + decorateWithCollation, + decorateWithReadConcern, + maxWireVersion +} from '../utils'; import { CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects } from './operation'; @@ -21,6 +26,12 @@ export type DistinctOptions = CommandOperationOptions & { * See https://www.mongodb.com/docs/manual/reference/command/distinct/#command-fields. */ hint?: Document | string; + /** + * 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; }; /** @@ -61,6 +72,7 @@ export class DistinctOperation extends CommandOperation { session: ClientSession | undefined, timeoutContext: TimeoutContext ): Promise { + const serverWireVersion = maxWireVersion(server); const coll = this.collection; const key = this.key; const query = this.query; @@ -94,6 +106,8 @@ export class DistinctOperation extends CommandOperation { // Have we specified collation decorateWithCollation(cmd, coll, options); + decorateRawData(cmd, !!this.options.rawData, serverWireVersion); + const result = await super.executeCommand(server, session, cmd, timeoutContext); // @ts-expect-error: Explain always returns a document diff --git a/src/operations/estimated_document_count.ts b/src/operations/estimated_document_count.ts index 5ab5aa4c305..0fc513ad3da 100644 --- a/src/operations/estimated_document_count.ts +++ b/src/operations/estimated_document_count.ts @@ -3,6 +3,7 @@ import type { Collection } from '../collection'; import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { type TimeoutContext } from '../timeout'; +import { decorateRawData, maxWireVersion } from '../utils'; import { CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects } from './operation'; @@ -14,6 +15,12 @@ export interface EstimatedDocumentCountOptions extends CommandOperationOptions { * This option is sent only if the caller explicitly provides a value. The default is to not send a value. */ maxTimeMS?: number; + /** + * 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 */ @@ -36,6 +43,7 @@ export class EstimatedDocumentCountOperation extends CommandOperation { session: ClientSession | undefined, timeoutContext: TimeoutContext ): Promise { + const serverWireVersion = maxWireVersion(server); const cmd: Document = { count: this.collectionName }; if (typeof this.options.maxTimeMS === 'number') { @@ -48,6 +56,8 @@ export class EstimatedDocumentCountOperation extends CommandOperation { cmd.comment = this.options.comment; } + decorateRawData(cmd, !!this.options.rawData, serverWireVersion); + const response = await super.executeCommand(server, session, cmd, timeoutContext); return response?.n || 0; diff --git a/src/operations/find.ts b/src/operations/find.ts index 1775ea6e07f..73935c50dbe 100644 --- a/src/operations/find.ts +++ b/src/operations/find.ts @@ -12,7 +12,12 @@ import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { formatSort, type Sort } from '../sort'; import { type TimeoutContext } from '../timeout'; -import { type MongoDBNamespace, normalizeHintField } from '../utils'; +import { + decorateRawData, + maxWireVersion, + type MongoDBNamespace, + normalizeHintField +} from '../utils'; import { type CollationOptions, CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects, type Hint } from './operation'; @@ -79,6 +84,12 @@ export interface FindOptions explain?: ExplainOptions['explain']; /** @internal*/ timeoutMode?: CursorTimeoutMode; + /** + * 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 */ @@ -118,6 +129,7 @@ export class FindOperation extends CommandOperation { timeoutContext: TimeoutContext ): Promise { this.server = server; + const serverWireVersion = maxWireVersion(server); const options = this.options; @@ -126,6 +138,7 @@ export class FindOperation extends CommandOperation { validateExplainTimeoutOptions(this.options, this.explain); findCommand = decorateWithExplain(findCommand, this.explain); } + decorateRawData(findCommand, !!this.options.rawData, serverWireVersion); return await server.command( this.ns, diff --git a/src/operations/find_and_modify.ts b/src/operations/find_and_modify.ts index 759cb02e72c..c7ad875d432 100644 --- a/src/operations/find_and_modify.ts +++ b/src/operations/find_and_modify.ts @@ -6,7 +6,12 @@ import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { formatSort, type Sort, type SortForCmd } from '../sort'; import { type TimeoutContext } from '../timeout'; -import { decorateWithCollation, hasAtomicOperators, maxWireVersion } from '../utils'; +import { + decorateRawData, + decorateWithCollation, + hasAtomicOperators, + maxWireVersion +} from '../utils'; import { type WriteConcern, type WriteConcernSettings } from '../write_concern'; import { CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects } from './operation'; @@ -34,6 +39,12 @@ export interface FindOneAndDeleteOptions extends CommandOperationOptions { * Return the ModifyResult instead of the modified document. Defaults to false */ includeResultMetadata?: 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; } /** @public */ @@ -56,6 +67,12 @@ export interface FindOneAndReplaceOptions extends CommandOperationOptions { * Return the ModifyResult instead of the modified document. Defaults to false */ includeResultMetadata?: 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; } /** @public */ @@ -80,6 +97,12 @@ export interface FindOneAndUpdateOptions extends CommandOperationOptions { * Return the ModifyResult instead of the modified document. Defaults to false */ includeResultMetadata?: 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 */ @@ -186,6 +209,7 @@ export class FindAndModifyOperation extends CommandOperation { session: ClientSession | undefined, timeoutContext: TimeoutContext ): Promise { + const serverWireVersion = maxWireVersion(server); const coll = this.collection; const query = this.query; const options = { ...this.options, ...this.bsonOptions }; @@ -198,6 +222,7 @@ export class FindAndModifyOperation extends CommandOperation { }; decorateWithCollation(cmd, coll, options); + decorateRawData(cmd, !!this.options.rawData, serverWireVersion); if (options.hint) { // TODO: once this method becomes a CommandOperation we will have the server diff --git a/src/operations/indexes.ts b/src/operations/indexes.ts index afd05f5be36..e3b9076d58b 100644 --- a/src/operations/indexes.ts +++ b/src/operations/indexes.ts @@ -7,7 +7,7 @@ import { type OneOrMore } from '../mongo_types'; import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { type TimeoutContext } from '../timeout'; -import { isObject, maxWireVersion, type MongoDBNamespace } from '../utils'; +import { decorateRawData, isObject, maxWireVersion, type MongoDBNamespace } from '../utils'; import { type CollationOptions, CommandOperation, @@ -163,6 +163,12 @@ export interface CreateIndexesOptions extends Omit { // collation is set on each index, it should not be defined at the root this.options.collation = undefined; + decorateRawData(cmd, !!this.options.rawData, serverWireVersion); await super.executeCommand(server, session, cmd, timeoutContext); @@ -329,7 +336,14 @@ export class CreateIndexesOperation extends CommandOperation { } /** @public */ -export type DropIndexesOptions = CommandOperationOptions; +export interface DropIndexesOptions extends 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 + **/ + rawData?: boolean; +} /** @internal */ export class DropIndexOperation extends CommandOperation { @@ -354,7 +368,9 @@ export class DropIndexOperation extends CommandOperation { session: ClientSession | undefined, timeoutContext: TimeoutContext ): Promise { + const serverWireVersion = maxWireVersion(server); const cmd = { dropIndexes: this.collection.collectionName, index: this.indexName }; + decorateRawData(cmd, !!this.options.rawData, serverWireVersion); return await super.executeCommand(server, session, cmd, timeoutContext); } } @@ -363,6 +379,12 @@ export class DropIndexOperation extends CommandOperation { export type ListIndexesOptions = AbstractCursorOptions & { /** @internal */ omitMaxTimeMS?: 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 */ @@ -405,6 +427,7 @@ export class ListIndexesOperation extends CommandOperation { if (serverWireVersion >= 9 && this.options.comment !== undefined) { command.comment = this.options.comment; } + decorateRawData(command, !!this.options.rawData, serverWireVersion); return await super.executeCommand(server, session, command, timeoutContext, CursorResponse); } diff --git a/src/operations/insert.ts b/src/operations/insert.ts index 1a40763e313..d6d05af6b07 100644 --- a/src/operations/insert.ts +++ b/src/operations/insert.ts @@ -6,7 +6,12 @@ import type { InferIdType } from '../mongo_types'; import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { type TimeoutContext } from '../timeout'; -import { maybeAddIdToDocuments, type MongoDBNamespace } from '../utils'; +import { + decorateRawData, + maxWireVersion, + maybeAddIdToDocuments, + type MongoDBNamespace +} from '../utils'; import { WriteConcern } from '../write_concern'; import { BulkWriteOperation } from './bulk_write'; import { CommandOperation, type CommandOperationOptions } from './command'; @@ -33,6 +38,7 @@ export class InsertOperation extends CommandOperation { session: ClientSession | undefined, timeoutContext: TimeoutContext ): Promise { + const serverWireVersion = maxWireVersion(server); const options = this.options ?? {}; const ordered = typeof options.ordered === 'boolean' ? options.ordered : true; const command: Document = { @@ -51,6 +57,8 @@ export class InsertOperation extends CommandOperation { command.comment = options.comment; } + decorateRawData(command, !!options.rawData, serverWireVersion); + return await super.executeCommand(server, session, command, timeoutContext); } } @@ -61,6 +69,12 @@ export interface InsertOneOptions extends CommandOperationOptions { bypassDocumentValidation?: boolean; /** Force server to assign _id values instead of driver. */ forceServerObjectId?: 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; } /** @public */ diff --git a/src/operations/list_collections.ts b/src/operations/list_collections.ts index 57f8aff45e6..ae22be87874 100644 --- a/src/operations/list_collections.ts +++ b/src/operations/list_collections.ts @@ -6,7 +6,7 @@ import { type Abortable } from '../mongo_types'; import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { type TimeoutContext } from '../timeout'; -import { maxWireVersion } from '../utils'; +import { decorateRawData, maxWireVersion } from '../utils'; import { CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects } from './operation'; @@ -25,6 +25,12 @@ export interface ListCollectionsOptions /** @internal */ timeoutContext?: CursorTimeoutContext; + /** + * 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 */ @@ -92,6 +98,7 @@ export class ListCollectionsOperation extends CommandOperation { command.comment = this.options.comment; } + decorateRawData(command, !!this.options.rawData, wireVersion); return command; } } diff --git a/src/operations/update.ts b/src/operations/update.ts index f731e77945d..52ffea0d4bb 100644 --- a/src/operations/update.ts +++ b/src/operations/update.ts @@ -6,7 +6,12 @@ import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { formatSort, type Sort, type SortForCmd } from '../sort'; import { type TimeoutContext } from '../timeout'; -import { hasAtomicOperators, type MongoDBNamespace } from '../utils'; +import { + decorateRawData, + hasAtomicOperators, + maxWireVersion, + type MongoDBNamespace +} from '../utils'; import { type CollationOptions, CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects, type Hint } from './operation'; @@ -24,6 +29,12 @@ export interface UpdateOptions extends CommandOperationOptions { upsert?: boolean; /** Map of parameter names and values that can be accessed using $$var (requires MongoDB 5.0). */ let?: Document; + /** + * 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; } /** @@ -100,6 +111,7 @@ export class UpdateOperation extends CommandOperation { session: ClientSession | undefined, timeoutContext: TimeoutContext ): Promise { + const serverWireVersion = maxWireVersion(server); const options = this.options ?? {}; const ordered = typeof options.ordered === 'boolean' ? options.ordered : true; const command: Document = { @@ -122,6 +134,8 @@ export class UpdateOperation extends CommandOperation { command.comment = options.comment; } + decorateRawData(command, !!this.options.rawData, serverWireVersion); + const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0; if (unacknowledgedWrite) { if (this.statements.find((o: Document) => o.hint)) { @@ -219,6 +233,12 @@ export interface ReplaceOptions extends CommandOperationOptions { let?: Document; /** Specifies the sort order for the documents matched by the filter. */ sort?: Sort; + /** + * 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 */ diff --git a/src/utils.ts b/src/utils.ts index 22cda4092ba..bc900822edb 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'; @@ -80,6 +83,16 @@ export function isUint8Array(value: unknown): value is Uint8Array { ); } +export function decorateRawData( + command: Document, + rawData: boolean, + serverWireVersion: number +): void { + if (rawData && serverWireVersion >= MIN_SUPPORTED_RAW_DATA_WIRE_VERSION) { + command.rawData = rawData; + } +} + /** * Determines if a connection's address matches a user provided list * of domain wildcards. diff --git a/test/integration/crud/crud.spec.test.ts b/test/integration/crud/crud.spec.test.ts index 5439c775236..ce13689a0e2 100644 --- a/test/integration/crud/crud.spec.test.ts +++ b/test/integration/crud/crud.spec.test.ts @@ -39,7 +39,7 @@ const loadBalancedCollationTests = [ 'Distinct with a collation' ]; -describe('CRUD unified', function () { +describe.only('CRUD unified', function () { runUnifiedSuite( loadSpecTests(path.join('crud', 'unified')), ({ description }, { isLoadBalanced }) => { diff --git a/test/spec/collection-management/listCollections-rawdata.json b/test/spec/collection-management/listCollections-rawdata.json new file mode 100644 index 00000000000..f24c8e1a3cc --- /dev/null +++ b/test/spec/collection-management/listCollections-rawdata.json @@ -0,0 +1,91 @@ +{ + "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" + } + ], + "operations": [ + { + "name": "listCollections", + "object": "database0", + "arguments": { + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "listCollections": 1, + "filter": {}, + "rawData": true + } + } + } + ] + } + ] + }, + { + "description": "listCollections with rawData option on less than 8.2.0 - ignore argument", + "runOnRequirements": [ + { + "maxServerVersion": "8.1.99" + } + ], + "operations": [ + { + "name": "listCollections", + "object": "database0", + "arguments": { + "rawData": true + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "listCollections": 1, + "filter": {}, + "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..6c931da0c35 --- /dev/null +++ b/test/spec/collection-management/listCollections-rawdata.yml @@ -0,0 +1,47 @@ +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" + operations: + - name: listCollections + object: *database0 + arguments: + rawData: &rawdata true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + listCollections: 1 + filter: {} + rawData: *rawdata + - description: "listCollections with rawData option on less than 8.2.0 - ignore argument" + runOnRequirements: + - maxServerVersion: "8.1.99" + operations: + - name: listCollections + object: *database0 + arguments: + rawData: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + listCollections: 1 + filter: {} + 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 From e3e99cbd01d82cbc73e9dd4bc360fecefd31179c Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Thu, 10 Jul 2025 15:21:06 -0400 Subject: [PATCH 2/3] test: fix constants test --- test/unit/cmap/wire_protocol/constants.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 24f18c80f6a91c9775eeaac25d29cd564bb9d361 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Thu, 10 Jul 2025 15:37:01 -0400 Subject: [PATCH 3/3] test: remove only --- test/integration/crud/crud.spec.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/crud/crud.spec.test.ts b/test/integration/crud/crud.spec.test.ts index ce13689a0e2..5439c775236 100644 --- a/test/integration/crud/crud.spec.test.ts +++ b/test/integration/crud/crud.spec.test.ts @@ -39,7 +39,7 @@ const loadBalancedCollationTests = [ 'Distinct with a collation' ]; -describe.only('CRUD unified', function () { +describe('CRUD unified', function () { runUnifiedSuite( loadSpecTests(path.join('crud', 'unified')), ({ description }, { isLoadBalanced }) => {