From a855e2b42e367496028fe1b1bd9d5e9eb5df63e3 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Fri, 19 Aug 2022 14:44:21 -0400 Subject: [PATCH 1/4] test: adjust number of iterations of flakey test --- .../server_selection.prose.operation_count.test.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/integration/server-selection/server_selection.prose.operation_count.test.ts b/test/integration/server-selection/server_selection.prose.operation_count.test.ts index 39bb7d25669..df15950c292 100644 --- a/test/integration/server-selection/server_selection.prose.operation_count.test.ts +++ b/test/integration/server-selection/server_selection.prose.operation_count.test.ts @@ -19,7 +19,7 @@ const failPoint = { const POOL_SIZE = 100; -async function runTaskGroup(collection: Collection, count: 10 | 100) { +async function runTaskGroup(collection: Collection, count: 10 | 100 | 500) { for (let i = 0; i < count; ++i) { await collection.findOne({}); } @@ -147,13 +147,19 @@ describe('operationCount-based Selection Within Latency Window - Prose Test', fu it('equally distributes operations with both hosts are fine', TEST_METADATA, async function () { const collection = client.db('test-db').collection('collection0'); + const numberTaskGroups = 10; + const numberOfTasks = 500; + const totalNumberOfTasks = numberTaskGroups * numberOfTasks; + // Step 8: Start 10 concurrent threads / tasks that each run 100 findOne operations with empty filters using that client. - await Promise.all(Array.from({ length: 10 }, () => runTaskGroup(collection, 100))); + await Promise.all( + Array.from({ length: numberTaskGroups }, () => runTaskGroup(collection, numberOfTasks)) + ); // Step 9: Using command monitoring events, assert that each mongos was selected roughly 50% of the time (within +/- 10%). const [host1, host2] = seeds.map(seed => seed.split(':')[1]); - const percentageToHost1 = (counts[host1] / 1000) * 100; - const percentageToHost2 = (counts[host2] / 1000) * 100; + const percentageToHost1 = (counts[host1] / totalNumberOfTasks) * 100; + const percentageToHost2 = (counts[host2] / totalNumberOfTasks) * 100; expect(percentageToHost1).to.be.greaterThan(40).and.lessThan(60); expect(percentageToHost2).to.be.greaterThan(40).and.lessThan(60); }); From 932a8189aa73117deb0a8803898a433b435ee6d5 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Fri, 19 Aug 2022 16:30:23 -0400 Subject: [PATCH 2/4] bump count to 1000 --- .../server_selection.prose.operation_count.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/server-selection/server_selection.prose.operation_count.test.ts b/test/integration/server-selection/server_selection.prose.operation_count.test.ts index df15950c292..27650ab1369 100644 --- a/test/integration/server-selection/server_selection.prose.operation_count.test.ts +++ b/test/integration/server-selection/server_selection.prose.operation_count.test.ts @@ -19,7 +19,7 @@ const failPoint = { const POOL_SIZE = 100; -async function runTaskGroup(collection: Collection, count: 10 | 100 | 500) { +async function runTaskGroup(collection: Collection, count: 10 | 100 | 1000) { for (let i = 0; i < count; ++i) { await collection.findOne({}); } @@ -148,7 +148,7 @@ describe('operationCount-based Selection Within Latency Window - Prose Test', fu const collection = client.db('test-db').collection('collection0'); const numberTaskGroups = 10; - const numberOfTasks = 500; + const numberOfTasks = 1000; const totalNumberOfTasks = numberTaskGroups * numberOfTasks; // Step 8: Start 10 concurrent threads / tasks that each run 100 findOne operations with empty filters using that client. From f6c2364e527d62a7d7c7699c4006e2e1f4f4c569 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 24 Aug 2022 10:14:30 -0400 Subject: [PATCH 3/4] Update server_selection.prose.operation_count.test.ts --- .../server_selection.prose.operation_count.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/integration/server-selection/server_selection.prose.operation_count.test.ts b/test/integration/server-selection/server_selection.prose.operation_count.test.ts index 27650ab1369..be7ebfb6b0d 100644 --- a/test/integration/server-selection/server_selection.prose.operation_count.test.ts +++ b/test/integration/server-selection/server_selection.prose.operation_count.test.ts @@ -150,7 +150,9 @@ describe('operationCount-based Selection Within Latency Window - Prose Test', fu const numberTaskGroups = 10; const numberOfTasks = 1000; const totalNumberOfTasks = numberTaskGroups * numberOfTasks; - + + // This test has proved flakey, not just for Node. The number of iterations for the test has been increased, + // to prevent the test from failing. // Step 8: Start 10 concurrent threads / tasks that each run 100 findOne operations with empty filters using that client. await Promise.all( Array.from({ length: numberTaskGroups }, () => runTaskGroup(collection, numberOfTasks)) From 0dc85518e033839274603db4b410e05bc707b8f1 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 24 Aug 2022 10:38:08 -0400 Subject: [PATCH 4/4] chore: fix lint --- .../server_selection.prose.operation_count.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/server-selection/server_selection.prose.operation_count.test.ts b/test/integration/server-selection/server_selection.prose.operation_count.test.ts index be7ebfb6b0d..48e8c23cb85 100644 --- a/test/integration/server-selection/server_selection.prose.operation_count.test.ts +++ b/test/integration/server-selection/server_selection.prose.operation_count.test.ts @@ -150,7 +150,7 @@ describe('operationCount-based Selection Within Latency Window - Prose Test', fu const numberTaskGroups = 10; const numberOfTasks = 1000; const totalNumberOfTasks = numberTaskGroups * numberOfTasks; - + // This test has proved flakey, not just for Node. The number of iterations for the test has been increased, // to prevent the test from failing. // Step 8: Start 10 concurrent threads / tasks that each run 100 findOne operations with empty filters using that client.