Skip to content

Commit 588f704

Browse files
committed
test: add timeout error
1 parent 8d6641a commit 588f704

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/integration/server-selection/server_selection.prose.operation_count.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { on } from 'events';
44
import { CommandStartedEvent } from '../../../src';
55
import { Collection } from '../../../src/collection';
66
import { MongoClient } from '../../../src/mongo_client';
7+
import { sleep } from '../../tools/utils';
78

89
const failPoint = {
910
configureFailPoint: 'failCommand',
@@ -24,7 +25,7 @@ async function runTaskGroup(collection: Collection, count: 10 | 100 | 1000) {
2425
}
2526
}
2627

27-
async function ensurePoolIsFull(client: MongoClient) {
28+
async function ensurePoolIsFull(client: MongoClient): Promise<boolean> {
2829
let connectionCount = 0;
2930
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3031
for await (const _event of on(client, 'connectionCreated')) {
@@ -74,7 +75,10 @@ describe('operationCount-based Selection Within Latency Window - Prose Test', fu
7475
await client.connect();
7576

7677
// Step 4: Using CMAP events, ensure the client's connection pools for both mongoses have been saturated
77-
await poolIsFullPromise;
78+
const poolIsFull = Promise.race([poolIsFullPromise, sleep(30 * 1000)]);
79+
if (!poolIsFull) {
80+
throw new Error('Timed out waiting for connection pool to fill to minPoolSize');
81+
}
7882

7983
seeds = client.topology.s.seedlist.map(address => address.toString());
8084

0 commit comments

Comments
 (0)