Skip to content

Commit edd8a1c

Browse files
test(NODE-4479): adjust number of iterations of flakey test (#3378)
1 parent b643731 commit edd8a1c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

+12-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const failPoint = {
1919

2020
const POOL_SIZE = 100;
2121

22-
async function runTaskGroup(collection: Collection, count: 10 | 100) {
22+
async function runTaskGroup(collection: Collection, count: 10 | 100 | 1000) {
2323
for (let i = 0; i < count; ++i) {
2424
await collection.findOne({});
2525
}
@@ -147,13 +147,21 @@ describe('operationCount-based Selection Within Latency Window - Prose Test', fu
147147
it('equally distributes operations with both hosts are fine', TEST_METADATA, async function () {
148148
const collection = client.db('test-db').collection('collection0');
149149

150+
const numberTaskGroups = 10;
151+
const numberOfTasks = 1000;
152+
const totalNumberOfTasks = numberTaskGroups * numberOfTasks;
153+
154+
// This test has proved flakey, not just for Node. The number of iterations for the test has been increased,
155+
// to prevent the test from failing.
150156
// Step 8: Start 10 concurrent threads / tasks that each run 100 findOne operations with empty filters using that client.
151-
await Promise.all(Array.from({ length: 10 }, () => runTaskGroup(collection, 100)));
157+
await Promise.all(
158+
Array.from({ length: numberTaskGroups }, () => runTaskGroup(collection, numberOfTasks))
159+
);
152160

153161
// Step 9: Using command monitoring events, assert that each mongos was selected roughly 50% of the time (within +/- 10%).
154162
const [host1, host2] = seeds.map(seed => seed.split(':')[1]);
155-
const percentageToHost1 = (counts[host1] / 1000) * 100;
156-
const percentageToHost2 = (counts[host2] / 1000) * 100;
163+
const percentageToHost1 = (counts[host1] / totalNumberOfTasks) * 100;
164+
const percentageToHost2 = (counts[host2] / totalNumberOfTasks) * 100;
157165
expect(percentageToHost1).to.be.greaterThan(40).and.lessThan(60);
158166
expect(percentageToHost2).to.be.greaterThan(40).and.lessThan(60);
159167
});

0 commit comments

Comments
 (0)