From aafd2a9dc9ff2f4fc26bbb046f10241ec6b9acf2 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Wed, 17 Jan 2024 14:45:44 +0100 Subject: [PATCH 1/2] test(NODE-5823): CSOT unified runner changes --- src/connection_string.ts | 3 ++ src/mongo_client.ts | 2 + test/tools/unified-spec-runner/operations.ts | 44 +++++++++++++++++++- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/connection_string.ts b/src/connection_string.ts index fb7890df5a5..28d1c1fbc3d 100644 --- a/src/connection_string.ts +++ b/src/connection_string.ts @@ -1090,6 +1090,9 @@ export const OPTIONS = { target: 'tls', type: 'boolean' }, + timeoutMS: { + type: 'uint' + }, tls: { type: 'boolean' }, diff --git a/src/mongo_client.ts b/src/mongo_client.ts index a1e92f93f80..7c596e846a4 100644 --- a/src/mongo_client.ts +++ b/src/mongo_client.ts @@ -118,6 +118,8 @@ export type SupportedNodeConnectionOptions = SupportedTLSConnectionOptions & export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeConnectionOptions { /** Specifies the name of the replica set, if the mongod is a member of a replica set. */ replicaSet?: string; + /** @experimental */ + timeoutMS?: number; /** Enables or disables TLS/SSL for the connection. */ tls?: boolean; /** A boolean to enable or disables TLS/SSL for the connection. (The ssl option is equivalent to the tls option.) */ diff --git a/test/tools/unified-spec-runner/operations.ts b/test/tools/unified-spec-runner/operations.ts index ab184c82ca2..2b955416fc6 100644 --- a/test/tools/unified-spec-runner/operations.ts +++ b/test/tools/unified-spec-runner/operations.ts @@ -295,15 +295,30 @@ operations.set('dropCollection', async ({ entities, operation }) => { } }); +operations.set('drop', async ({ entities, operation }) => { + const bucket = entities.getEntity('bucket', operation.object); + return bucket.drop(); +}); + +operations.set('dropIndexes', async ({ entities, operation }) => { + const collection = entities.getEntity('collection', operation.object); + return collection.dropIndexes(); +}); + operations.set('endSession', async ({ entities, operation }) => { const session = entities.getEntity('session', operation.object); return session.endSession(); }); operations.set('find', async ({ entities, operation }) => { - const collection = entities.getEntity('collection', operation.object); + let queryable; + if (operation.object === 'bucket') { + queryable = entities.getEntity('bucket', operation.object); + } else { + queryable = entities.getEntity('collection', operation.object); + } const { filter, ...opts } = operation.arguments!; - return collection.find(filter, opts).toArray(); + return queryable.find(filter, opts).toArray(); }); operations.set('findOne', async ({ entities, operation }) => { @@ -372,16 +387,35 @@ operations.set('listCollections', async ({ entities, operation }) => { return db.listCollections(filter, opts).toArray(); }); +operations.set('listCollectionNames', async ({ entities, operation }) => { + const db = entities.getEntity('db', operation.object); + const { filter, ...opts } = operation.arguments!; + const collections = await db.listCollections(filter, opts).toArray(); + return collections.map(collection => collection.name); +}); + operations.set('listDatabases', async ({ entities, operation }) => { const client = entities.getEntity('client', operation.object); return client.db().admin().listDatabases(operation.arguments!); }); +operations.set('listDatabaseNames', async ({ entities, operation }) => { + const client = entities.getEntity('client', operation.object); + const result = await client.db().admin().listDatabases(operation.arguments!); + return result.databases.map(database => database.name); +}); + operations.set('listIndexes', async ({ entities, operation }) => { const collection = entities.getEntity('collection', operation.object); return collection.listIndexes(operation.arguments!).toArray(); }); +operations.set('listIndexNames', async ({ entities, operation }) => { + const collection = entities.getEntity('collection', operation.object); + const indexes = await collection.listIndexes(operation.arguments!).toArray(); + return indexes.map(index => index.name); +}); + operations.set('loop', async ({ entities, operation, client, testConfig }) => { const controller = new AbortController(); // We always want the process to exit on SIGINT last, so all other @@ -680,6 +714,12 @@ operations.set('withTransaction', async ({ entities, operation, client, testConf }, options); }); +operations.set('count', async ({ entities, operation }) => { + const collection = entities.getEntity('collection', operation.object); + const { filter, ...opts } = operation.arguments!; + return collection.count(filter, opts); +}); + operations.set('countDocuments', async ({ entities, operation }) => { const collection = entities.getEntity('collection', operation.object); const { filter, ...opts } = operation.arguments!; From d8ef36c501db9201d2883be22d7f8535fb0cbee8 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Thu, 18 Jan 2024 20:40:22 +0100 Subject: [PATCH 2/2] fix: make option internal --- src/mongo_client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mongo_client.ts b/src/mongo_client.ts index 7c596e846a4..a8be513d176 100644 --- a/src/mongo_client.ts +++ b/src/mongo_client.ts @@ -118,7 +118,7 @@ export type SupportedNodeConnectionOptions = SupportedTLSConnectionOptions & export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeConnectionOptions { /** Specifies the name of the replica set, if the mongod is a member of a replica set. */ replicaSet?: string; - /** @experimental */ + /** @internal This option is in development and currently has no behaviour. */ timeoutMS?: number; /** Enables or disables TLS/SSL for the connection. */ tls?: boolean;