From 779b9103ce3f59c9a4315512a8dc2dcc0157d085 Mon Sep 17 00:00:00 2001 From: bailey Date: Mon, 24 Feb 2025 10:57:55 -0700 Subject: [PATCH 1/3] new tests --- .../unified/change-streams-nsType.json | 145 ++++++++++++++++++ .../unified/change-streams-nsType.yml | 86 +++++++++++ 2 files changed, 231 insertions(+) create mode 100644 test/spec/change-streams/unified/change-streams-nsType.json create mode 100644 test/spec/change-streams/unified/change-streams-nsType.yml diff --git a/test/spec/change-streams/unified/change-streams-nsType.json b/test/spec/change-streams/unified/change-streams-nsType.json new file mode 100644 index 00000000000..1861c9a5e0a --- /dev/null +++ b/test/spec/change-streams/unified/change-streams-nsType.json @@ -0,0 +1,145 @@ +{ + "description": "change-streams-nsType", + "schemaVersion": "1.7", + "runOnRequirements": [ + { + "minServerVersion": "8.1.0", + "topologies": [ + "replicaset", + "sharded" + ], + "serverless": "forbid" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "database0" + } + } + ], + "tests": [ + { + "description": "nsType is present when creating collections", + "operations": [ + { + "name": "dropCollection", + "object": "database0", + "arguments": { + "collection": "foo" + } + }, + { + "name": "createChangeStream", + "object": "database0", + "arguments": { + "pipeline": [], + "showExpandedEvents": true + }, + "saveResultAsEntity": "changeStream0" + }, + { + "name": "createCollection", + "object": "database0", + "arguments": { + "collection": "foo" + } + }, + { + "name": "iterateUntilDocumentOrError", + "object": "changeStream0", + "expectResult": { + "operationType": "create", + "nsType": "collection" + } + } + ] + }, + { + "description": "nsType is present when creating timeseries", + "operations": [ + { + "name": "dropCollection", + "object": "database0", + "arguments": { + "collection": "foo" + } + }, + { + "name": "createChangeStream", + "object": "database0", + "arguments": { + "pipeline": [], + "showExpandedEvents": true + }, + "saveResultAsEntity": "changeStream0" + }, + { + "name": "createCollection", + "object": "database0", + "arguments": { + "collection": "foo", + "timeseries": { + "timeField": "time", + "metaField": "meta", + "granularity": "minutes" + } + } + }, + { + "name": "iterateUntilDocumentOrError", + "object": "changeStream0", + "expectResult": { + "operationType": "create", + "nsType": "timeseries" + } + } + ] + }, + { + "description": "nsType is present when creating views", + "operations": [ + { + "name": "dropCollection", + "object": "database0", + "arguments": { + "collection": "foo" + } + }, + { + "name": "createChangeStream", + "object": "database0", + "arguments": { + "pipeline": [], + "showExpandedEvents": true + }, + "saveResultAsEntity": "changeStream0" + }, + { + "name": "createCollection", + "object": "database0", + "arguments": { + "collection": "foo", + "viewOn": "testName" + } + }, + { + "name": "iterateUntilDocumentOrError", + "object": "changeStream0", + "expectResult": { + "operationType": "create", + "nsType": "view" + } + } + ] + } + ] +} diff --git a/test/spec/change-streams/unified/change-streams-nsType.yml b/test/spec/change-streams/unified/change-streams-nsType.yml new file mode 100644 index 00000000000..9885c4aaf68 --- /dev/null +++ b/test/spec/change-streams/unified/change-streams-nsType.yml @@ -0,0 +1,86 @@ +description: "change-streams-nsType" +schemaVersion: "1.7" +runOnRequirements: + - minServerVersion: "8.1.0" + topologies: [ replicaset, sharded ] + serverless: forbid +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + - database: + id: &database0 database0 + client: *client0 + databaseName: *database0 + +tests: + - description: "nsType is present when creating collections" + operations: + - name: dropCollection + object: *database0 + arguments: + collection: &collection0 foo + - name: createChangeStream + object: *database0 + arguments: + pipeline: [] + showExpandedEvents: true + saveResultAsEntity: &changeStream0 changeStream0 + - name: createCollection + object: *database0 + arguments: + collection: *collection0 + - name: iterateUntilDocumentOrError + object: *changeStream0 + expectResult: + operationType: create + nsType: collection + + - description: "nsType is present when creating timeseries" + operations: + - name: dropCollection + object: *database0 + arguments: + collection: &collection0 foo + - name: createChangeStream + object: *database0 + arguments: + pipeline: [] + showExpandedEvents: true + saveResultAsEntity: &changeStream0 changeStream0 + - name: createCollection + object: *database0 + arguments: + collection: *collection0 + timeseries: + timeField: "time" + metaField: "meta" + granularity: "minutes" + - name: iterateUntilDocumentOrError + object: *changeStream0 + expectResult: + operationType: create + nsType: timeseries + + - description: "nsType is present when creating views" + operations: + - name: dropCollection + object: *database0 + arguments: + collection: &collection0 foo + - name: createChangeStream + object: *database0 + arguments: + pipeline: [] + showExpandedEvents: true + saveResultAsEntity: &changeStream0 changeStream0 + - name: createCollection + object: *database0 + arguments: + collection: *collection0 + viewOn: testName + - name: iterateUntilDocumentOrError + object: *changeStream0 + expectResult: + operationType: create + nsType: view \ No newline at end of file From 6dba44983a520402fbc68f6683361fc4855a312a Mon Sep 17 00:00:00 2001 From: bailey Date: Mon, 24 Feb 2025 11:10:33 -0700 Subject: [PATCH 2/3] changes --- src/change_stream.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/change_stream.ts b/src/change_stream.ts index 1526ca3c756..10c3dcebab7 100644 --- a/src/change_stream.ts +++ b/src/change_stream.ts @@ -419,6 +419,13 @@ export interface ChangeStreamCreateDocument ChangeStreamDocumentCollectionUUID { /** Describes the type of operation represented in this change notification */ operationType: 'create'; + + /** + * The type of the newly created object. + * + * @since 8.1.0 + */ + nsType?: 'collection' | 'timeseries' | 'view'; } /** From 1b16680af07b593159544e202e5b51cbc2d5c18b Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Mon, 24 Feb 2025 14:18:59 -0700 Subject: [PATCH 3/3] Update src/change_stream.ts Co-authored-by: Neal Beeken --- src/change_stream.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/change_stream.ts b/src/change_stream.ts index 10c3dcebab7..7f7551f2d82 100644 --- a/src/change_stream.ts +++ b/src/change_stream.ts @@ -423,7 +423,7 @@ export interface ChangeStreamCreateDocument /** * The type of the newly created object. * - * @since 8.1.0 + * @sinceServerVersion 8.1.0 */ nsType?: 'collection' | 'timeseries' | 'view'; }