Skip to content

Commit 770937b

Browse files
test?
1 parent 529da59 commit 770937b

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

test/integration/crud/explain.test.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import {
1010
MongoOperationTimeoutError,
1111
MongoServerError
1212
} from '../../mongodb';
13-
import { clearFailPoint, configureFailPoint, measureDuration } from '../../tools/utils';
13+
import {
14+
clearFailPoint,
15+
configureFailPoint,
16+
measureDuration,
17+
waitUntilPoolsFilled
18+
} from '../../tools/utils';
1419
import { filterForCommands } from '../shared';
1520

1621
const explain = [true, false, 'queryPlanner', 'allPlansExecution', 'executionStats', 'invalid'];
@@ -312,16 +317,22 @@ describe('CRUD API explain option', function () {
312317
}
313318

314319
beforeEach(async function () {
315-
client = this.configuration.newClient({}, { monitorCommands: true });
320+
client = this.configuration.newClient(
321+
{},
322+
{ monitorCommands: true, minPoolSize: 5, appName: 'explain-test' }
323+
);
316324
client.on('commandStarted', filterForCommands('explain', commands));
317325

326+
waitUntilPoolsFilled(client, AbortSignal.timeout(30_000), 4);
327+
318328
await configureFailPoint(this.configuration, {
319329
configureFailPoint: 'failCommand',
320330
mode: { times: 1 },
321331
data: {
322332
failCommands: ['explain'],
323333
blockConnection: true,
324-
blockTimeMS: 1000
334+
blockTimeMS: 1000,
335+
appName: 'explain-tests'
325336
}
326337
});
327338
});
@@ -525,7 +536,7 @@ describe('CRUD API explain option', function () {
525536
cursor.explain({ verbosity: 'queryPlanner' }).catch(e => e)
526537
);
527538
expect(result).to.be.instanceOf(MongoOperationTimeoutError);
528-
expect(duration).to.be.within(1000, 1000 + 100);
539+
expect(duration).to.be.within(1000 - 100, 1000 + 100);
529540
});
530541
});
531542

@@ -537,7 +548,7 @@ describe('CRUD API explain option', function () {
537548
cursor.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 1000 }).catch(e => e)
538549
);
539550
expect(result).to.be.instanceOf(MongoOperationTimeoutError);
540-
expect(duration).to.be.within(1000, 1000 + 100);
551+
expect(duration).to.be.within(1000 - 100, 1000 + 100);
541552
});
542553
});
543554

@@ -548,7 +559,7 @@ describe('CRUD API explain option', function () {
548559
cursor.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 1000 }).catch(e => e)
549560
);
550561
expect(result).to.be.instanceOf(MongoOperationTimeoutError);
551-
expect(duration).to.be.within(1000, 1000 + 100);
562+
expect(duration).to.be.within(1000 - 100, 1000 + 100);
552563
});
553564
});
554565

@@ -560,7 +571,7 @@ describe('CRUD API explain option', function () {
560571
);
561572

562573
expect(result).to.be.instanceOf(MongoOperationTimeoutError);
563-
expect(duration).to.be.within(1000, 1000 + 100);
574+
expect(duration).to.be.within(1000 - 100, 1000 + 100);
564575
});
565576
});
566577

@@ -572,7 +583,7 @@ describe('CRUD API explain option', function () {
572583
);
573584

574585
expect(result).to.be.instanceOf(MongoOperationTimeoutError);
575-
expect(duration).to.be.within(1000, 1000 + 100);
586+
expect(duration).to.be.within(1000 - 100, 1000 + 100);
576587
});
577588
});
578589

@@ -582,7 +593,7 @@ describe('CRUD API explain option', function () {
582593
const { duration, result } = await measureDuration(() =>
583594
cursor.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 1000 }).catch(e => e)
584595
);
585-
expect(duration).to.be.within(1000, 1000 + 100);
596+
expect(duration).to.be.within(1000 - 100, 1000 + 100);
586597
expect(result).to.be.instanceOf(MongoOperationTimeoutError);
587598
});
588599
});

test/tools/runner/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
type AuthMechanism,
88
HostAddress,
99
MongoClient,
10+
type MongoClientOptions,
1011
type ServerApi,
1112
TopologyType,
1213
type WriteConcernSettings
@@ -176,7 +177,7 @@ export class TestConfiguration {
176177
return uri.indexOf('MONGODB-OIDC') > -1 && uri.indexOf(`ENVIRONMENT:${env}`) > -1;
177178
}
178179

179-
newClient(urlOrQueryOptions?: string | Record<string, any>, serverOptions?: Record<string, any>) {
180+
newClient(urlOrQueryOptions?: string | Record<string, any>, serverOptions?: MongoClientOptions) {
180181
serverOptions = Object.assign({}, getEnvironmentalOptions(), serverOptions);
181182

182183
// Support MongoClient constructor form (url, options) for `newClient`.

0 commit comments

Comments
 (0)