Skip to content

Commit 9b76a43

Browse files
authored
test(NODE-5823): CSOT unified runner changes (#3966)
1 parent 568e05f commit 9b76a43

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

src/connection_string.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,9 @@ export const OPTIONS = {
10901090
target: 'tls',
10911091
type: 'boolean'
10921092
},
1093+
timeoutMS: {
1094+
type: 'uint'
1095+
},
10931096
tls: {
10941097
type: 'boolean'
10951098
},

src/mongo_client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ export type SupportedNodeConnectionOptions = SupportedTLSConnectionOptions &
118118
export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeConnectionOptions {
119119
/** Specifies the name of the replica set, if the mongod is a member of a replica set. */
120120
replicaSet?: string;
121+
/** @internal This option is in development and currently has no behaviour. */
122+
timeoutMS?: number;
121123
/** Enables or disables TLS/SSL for the connection. */
122124
tls?: boolean;
123125
/** A boolean to enable or disables TLS/SSL for the connection. (The ssl option is equivalent to the tls option.) */

test/tools/unified-spec-runner/operations.ts

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,30 @@ operations.set('dropCollection', async ({ entities, operation }) => {
295295
}
296296
});
297297

298+
operations.set('drop', async ({ entities, operation }) => {
299+
const bucket = entities.getEntity('bucket', operation.object);
300+
return bucket.drop();
301+
});
302+
303+
operations.set('dropIndexes', async ({ entities, operation }) => {
304+
const collection = entities.getEntity('collection', operation.object);
305+
return collection.dropIndexes();
306+
});
307+
298308
operations.set('endSession', async ({ entities, operation }) => {
299309
const session = entities.getEntity('session', operation.object);
300310
return session.endSession();
301311
});
302312

303313
operations.set('find', async ({ entities, operation }) => {
304-
const collection = entities.getEntity('collection', operation.object);
314+
let queryable;
315+
if (operation.object === 'bucket') {
316+
queryable = entities.getEntity('bucket', operation.object);
317+
} else {
318+
queryable = entities.getEntity('collection', operation.object);
319+
}
305320
const { filter, ...opts } = operation.arguments!;
306-
return collection.find(filter, opts).toArray();
321+
return queryable.find(filter, opts).toArray();
307322
});
308323

309324
operations.set('findOne', async ({ entities, operation }) => {
@@ -372,16 +387,35 @@ operations.set('listCollections', async ({ entities, operation }) => {
372387
return db.listCollections(filter, opts).toArray();
373388
});
374389

390+
operations.set('listCollectionNames', async ({ entities, operation }) => {
391+
const db = entities.getEntity('db', operation.object);
392+
const { filter, ...opts } = operation.arguments!;
393+
const collections = await db.listCollections(filter, opts).toArray();
394+
return collections.map(collection => collection.name);
395+
});
396+
375397
operations.set('listDatabases', async ({ entities, operation }) => {
376398
const client = entities.getEntity('client', operation.object);
377399
return client.db().admin().listDatabases(operation.arguments!);
378400
});
379401

402+
operations.set('listDatabaseNames', async ({ entities, operation }) => {
403+
const client = entities.getEntity('client', operation.object);
404+
const result = await client.db().admin().listDatabases(operation.arguments!);
405+
return result.databases.map(database => database.name);
406+
});
407+
380408
operations.set('listIndexes', async ({ entities, operation }) => {
381409
const collection = entities.getEntity('collection', operation.object);
382410
return collection.listIndexes(operation.arguments!).toArray();
383411
});
384412

413+
operations.set('listIndexNames', async ({ entities, operation }) => {
414+
const collection = entities.getEntity('collection', operation.object);
415+
const indexes = await collection.listIndexes(operation.arguments!).toArray();
416+
return indexes.map(index => index.name);
417+
});
418+
385419
operations.set('loop', async ({ entities, operation, client, testConfig }) => {
386420
const controller = new AbortController();
387421
// 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
680714
}, options);
681715
});
682716

717+
operations.set('count', async ({ entities, operation }) => {
718+
const collection = entities.getEntity('collection', operation.object);
719+
const { filter, ...opts } = operation.arguments!;
720+
return collection.count(filter, opts);
721+
});
722+
683723
operations.set('countDocuments', async ({ entities, operation }) => {
684724
const collection = entities.getEntity('collection', operation.object);
685725
const { filter, ...opts } = operation.arguments!;

0 commit comments

Comments
 (0)