Skip to content

Commit

Permalink
test: add timeout error
Browse files Browse the repository at this point in the history
  • Loading branch information
dariakp committed Sep 30, 2022
1 parent 8d6641a commit 588f704
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { on } from 'events';
import { CommandStartedEvent } from '../../../src';
import { Collection } from '../../../src/collection';
import { MongoClient } from '../../../src/mongo_client';
import { sleep } from '../../tools/utils';

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

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

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

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

Expand Down

0 comments on commit 588f704

Please sign in to comment.