Skip to content

Commit ad75387

Browse files
asdf
1 parent 772c458 commit ad75387

File tree

2 files changed

+88
-87
lines changed

2 files changed

+88
-87
lines changed

test/integration/crud/explain.test.ts

Lines changed: 71 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import {
88
type Document,
99
type MongoClient,
1010
MongoOperationTimeoutError,
11-
MongoServerError
11+
MongoServerError,
12+
squashError
1213
} from '../../mongodb';
1314
import { clearFailPoint, configureFailPoint, measureDuration } from '../../tools/utils';
1415
import { filterForCommands } from '../shared';
15-
import { clear } from 'console';
1616

1717
const explain = [true, false, 'queryPlanner', 'allPlansExecution', 'executionStats', 'invalid'];
1818

@@ -326,7 +326,7 @@ describe('CRUD API explain option', function () {
326326
data: {
327327
failCommands: ['explain'],
328328
blockConnection: true,
329-
blockTimeMS: 1000
329+
blockTimeMS: 2000
330330
}
331331
},
332332
this.configuration.url({ useMultipleMongoses: false })
@@ -565,13 +565,15 @@ describe('CRUD API explain option', function () {
565565
}
566566
);
567567
});
568-
})
568+
});
569569

570570
describe('fluent api timeoutMS precedence and inheritance', function () {
571571
beforeEach(async function () {
572572
client = this.configuration.newClient({}, { monitorCommands: true });
573573
client.on('commandStarted', filterForCommands('explain', commands));
574574
await client.connect();
575+
await client.db('foo').dropDatabase().catch(squashError);
576+
await client.db('foo').createCollection('bar');
575577
});
576578

577579
afterEach(async function () {
@@ -601,7 +603,8 @@ describe('CRUD API explain option', function () {
601603
expect(maxTimeMS).not.to.exist;
602604
commands.length = 0;
603605
}
604-
})
606+
});
607+
605608
beforeEach('aggregate does not set maxTimeMS if timeoutMS is not set', async function () {
606609
{
607610
const cursor = client.db('foo').collection('bar').aggregate([]);
@@ -615,108 +618,90 @@ describe('CRUD API explain option', function () {
615618
expect(maxTimeMS).not.to.exist;
616619
commands.length = 0;
617620
}
618-
})
621+
});
619622
});
620623

621624
describe('find({}, { timeoutMS }).explain()', function () {
622-
it(
623-
'respects the timeoutMS from the find options',
624-
async function () {
625-
const cursor = client.db('foo').collection('bar').find({}, { timeoutMS: 800 });
626-
await cursor.explain({ verbosity: 'queryPlanner' });
625+
it('respects the timeoutMS from the find options', async function () {
626+
const cursor = client.db('foo').collection('bar').find({}, { timeoutMS: 800 });
627+
await cursor.explain({ verbosity: 'queryPlanner' });
627628

628-
const [
629-
{
630-
command: { maxTimeMS }
631-
}
632-
] = commands;
633-
expect(maxTimeMS).to.exist;
634-
}
635-
);
629+
const [
630+
{
631+
command: { maxTimeMS }
632+
}
633+
] = commands;
634+
expect(maxTimeMS).to.exist;
635+
});
636636
});
637637

638638
describe('find().explain({}, { timeoutMS })', function () {
639-
it(
640-
'respects the timeoutMS from the explain helper',
641-
async function () {
642-
const cursor = client.db('foo').collection('bar').find();
643-
await cursor.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 800 })
639+
it('respects the timeoutMS from the explain helper', async function () {
640+
const cursor = client.db('foo').collection('bar').find();
641+
await cursor.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 800 });
644642

645-
const [
646-
{
647-
command: { maxTimeMS }
648-
}
649-
] = commands;
650-
expect(maxTimeMS).to.exist;
651-
}
652-
);
643+
const [
644+
{
645+
command: { maxTimeMS }
646+
}
647+
] = commands;
648+
expect(maxTimeMS).to.exist;
649+
});
653650
});
654651

655652
describe('find({}, { timeoutMS} ).explain({}, { timeoutMS })', function () {
656-
it(
657-
'the timeoutMS from the explain helper has precedence',
658-
async function () {
659-
const cursor = client.db('foo').collection('bar').find({}, { timeoutMS: 100 });
660-
await cursor.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 800 });
661-
const [
662-
{
663-
command: { maxTimeMS }
664-
}
665-
] = commands;
666-
expect(maxTimeMS).to.exist;
667-
expect(maxTimeMS).to.be.greaterThan(100);
668-
}
669-
);
653+
it('the timeoutMS from the explain helper has precedence', async function () {
654+
const cursor = client.db('foo').collection('bar').find({}, { timeoutMS: 100 });
655+
await cursor.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 800 });
656+
const [
657+
{
658+
command: { maxTimeMS }
659+
}
660+
] = commands;
661+
expect(maxTimeMS).to.exist;
662+
expect(maxTimeMS).to.be.greaterThan(100);
663+
});
670664
});
671665

672666
describe('aggregate([], { timeoutMS }).explain()', function () {
673-
it(
674-
'respects the timeoutMS from the find options',
675-
async function () {
676-
const cursor = client.db('foo').collection('bar').aggregate([], { timeoutMS: 800 });
677-
await cursor.explain({ verbosity: 'queryPlanner' })
667+
it('respects the timeoutMS from the find options', async function () {
668+
const cursor = client.db('foo').collection('bar').aggregate([], { timeoutMS: 800 });
669+
await cursor.explain({ verbosity: 'queryPlanner' });
678670

679-
const [
680-
{
681-
command: { maxTimeMS }
682-
}
683-
] = commands;
684-
expect(maxTimeMS).to.exist;
685-
}
686-
);
671+
const [
672+
{
673+
command: { maxTimeMS }
674+
}
675+
] = commands;
676+
expect(maxTimeMS).to.exist;
677+
});
687678
});
688679

689680
describe('aggregate([], { timeoutMS })', function () {
690-
it(
691-
'respects the timeoutMS from the explain helper',
692-
async function () {
693-
const cursor = client.db('foo').collection('bar').aggregate();
694-
await cursor.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 800 })
695-
const [
696-
{
697-
command: { maxTimeMS }
698-
}
699-
] = commands;
700-
expect(maxTimeMS).to.exist;
701-
}
702-
);
681+
it('respects the timeoutMS from the explain helper', async function () {
682+
const cursor = client.db('foo').collection('bar').aggregate();
683+
await cursor.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 800 });
684+
const [
685+
{
686+
command: { maxTimeMS }
687+
}
688+
] = commands;
689+
expect(maxTimeMS).to.exist;
690+
});
703691
});
704692

705693
describe('aggregate([], { timeoutMS} ).explain({}, { timeoutMS })', function () {
706-
it(
707-
'the timeoutMS from the explain helper has precedence',
708-
async function () {
709-
const cursor = client.db('foo').collection('bar').aggregate([], { timeoutMS: 100 });
710-
await cursor.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 800 })
711-
const [
712-
{
713-
command: { maxTimeMS }
714-
}
715-
] = commands;
716-
expect(maxTimeMS).to.exist;
717-
expect(maxTimeMS).to.be.greaterThan(100);
718-
}
719-
);
694+
it('the timeoutMS from the explain helper has precedence', async function () {
695+
const cursor = client.db('foo').collection('bar').aggregate([], { timeoutMS: 100 });
696+
await cursor.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 800 });
697+
const [
698+
{
699+
command: { maxTimeMS }
700+
}
701+
] = commands;
702+
expect(maxTimeMS).to.exist;
703+
expect(maxTimeMS).to.be.greaterThan(100);
704+
});
720705
});
721706
});
722707
});

test/tools/runner/config.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,23 @@ export class TestConfiguration {
294294
*
295295
* @param options - overrides and settings for URI generation
296296
*/
297-
url(options?: UrlOptions) {
297+
url(
298+
options?: UrlOptions & {
299+
useMultipleMongoses?: boolean;
300+
db?: string;
301+
replicaSet?: string;
302+
proxyURIParams?: ProxyParams;
303+
username?: string;
304+
password?: string;
305+
auth?: {
306+
username?: string;
307+
password?: string;
308+
};
309+
authSource?: string;
310+
authMechanism?: string;
311+
authMechanismProperties?: Record<string, any>;
312+
}
313+
) {
298314
options = {
299315
db: this.options.db,
300316
replicaSet: this.options.replicaSet,

0 commit comments

Comments
 (0)