From dc55ef8c98a78ef2bdad8730e5d105aa414020a2 Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Tue, 16 Sep 2025 14:16:53 -0700 Subject: [PATCH] CSHARP-5724: [Unified test runner] Introduce optin setting to await for MinPoolSize population --- .../tests/command-execution.json | 14 +- .../tests/command-execution.yml | 8 +- .../tests/convenient-transactions.json | 6 +- .../tests/convenient-transactions.yml | 4 +- .../tests/error-transformations.json | 6 +- .../tests/error-transformations.yml | 4 +- .../tests/global-timeoutMS.json | 130 +++++++++++++----- .../tests/global-timeoutMS.yml | 66 ++++++++- .../tests/retryability-timeoutMS.json | 6 +- .../tests/retryability-timeoutMS.yml | 4 +- .../tests/sessions-inherit-timeoutMS.json | 6 +- .../tests/sessions-inherit-timeoutMS.yml | 4 +- .../Authentication/AuthenticationHelper.cs | 2 +- src/MongoDB.Driver/Core/Clusters/Cluster.cs | 2 + src/MongoDB.Driver/Core/Clusters/ICluster.cs | 3 + .../Core/Clusters/LoadBalancedCluster.cs | 13 ++ .../Core/Clusters/MultiServerCluster.cs | 2 + .../Core/Clusters/SingleServerCluster.cs | 14 ++ src/MongoDB.Driver/Core/Servers/IServer.cs | 2 + .../Core/Clusters/ClusterTests.cs | 2 + .../UnifiedTestOperations/UnifiedEntityMap.cs | 24 ++++ .../UnifiedTestRunner.cs | 2 +- 22 files changed, 271 insertions(+), 53 deletions(-) diff --git a/specifications/client-side-operations-timeout/tests/command-execution.json b/specifications/client-side-operations-timeout/tests/command-execution.json index aa9c3eb23f3..212cd41089d 100644 --- a/specifications/client-side-operations-timeout/tests/command-execution.json +++ b/specifications/client-side-operations-timeout/tests/command-execution.json @@ -1,6 +1,6 @@ { "description": "timeoutMS behaves correctly during command execution", - "schemaVersion": "1.9", + "schemaVersion": "1.26", "runOnRequirements": [ { "minServerVersion": "4.4.7", @@ -69,8 +69,10 @@ "appName": "reduceMaxTimeMSTest", "w": 1, "timeoutMS": 500, - "heartbeatFrequencyMS": 500 + "heartbeatFrequencyMS": 500, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "observeEvents": [ "commandStartedEvent" ] @@ -185,8 +187,10 @@ "appName": "rttTooHighTest", "w": 1, "timeoutMS": 10, - "heartbeatFrequencyMS": 500 + "heartbeatFrequencyMS": 500, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "observeEvents": [ "commandStartedEvent" ] @@ -316,8 +320,10 @@ "appName": "reduceMaxTimeMSTest", "w": 1, "timeoutMS": 90, - "heartbeatFrequencyMS": 100000 + "heartbeatFrequencyMS": 100000, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "observeEvents": [ "commandStartedEvent" ] diff --git a/specifications/client-side-operations-timeout/tests/command-execution.yml b/specifications/client-side-operations-timeout/tests/command-execution.yml index 6ba0585b3ca..95a9abeefc7 100644 --- a/specifications/client-side-operations-timeout/tests/command-execution.yml +++ b/specifications/client-side-operations-timeout/tests/command-execution.yml @@ -1,6 +1,6 @@ description: "timeoutMS behaves correctly during command execution" -schemaVersion: "1.9" +schemaVersion: "1.26" runOnRequirements: # Require SERVER-49336 for failCommand + appName on the initial handshake. @@ -56,6 +56,8 @@ tests: w: 1 # Override server's w:majority default to speed up the test. timeoutMS: 500 heartbeatFrequencyMS: 500 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 observeEvents: - commandStartedEvent - database: @@ -127,6 +129,8 @@ tests: w: 1 # Override server's w:majority default to speed up the test. timeoutMS: 10 heartbeatFrequencyMS: 500 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 observeEvents: - commandStartedEvent - database: @@ -210,6 +214,8 @@ tests: w: 1 # Override server's w:majority default to speed up the test. timeoutMS: 90 heartbeatFrequencyMS: 100000 # Override heartbeatFrequencyMS to ensure only 1 RTT is recorded. + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 observeEvents: - commandStartedEvent - database: diff --git a/specifications/client-side-operations-timeout/tests/convenient-transactions.json b/specifications/client-side-operations-timeout/tests/convenient-transactions.json index 3868b3026c2..f9d03429db9 100644 --- a/specifications/client-side-operations-timeout/tests/convenient-transactions.json +++ b/specifications/client-side-operations-timeout/tests/convenient-transactions.json @@ -1,6 +1,6 @@ { "description": "timeoutMS behaves correctly for the withTransaction API", - "schemaVersion": "1.9", + "schemaVersion": "1.26", "runOnRequirements": [ { "minServerVersion": "4.4", @@ -21,8 +21,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 500 + "timeoutMS": 500, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" diff --git a/specifications/client-side-operations-timeout/tests/convenient-transactions.yml b/specifications/client-side-operations-timeout/tests/convenient-transactions.yml index 02d48b83242..55b72481dfb 100644 --- a/specifications/client-side-operations-timeout/tests/convenient-transactions.yml +++ b/specifications/client-side-operations-timeout/tests/convenient-transactions.yml @@ -1,6 +1,6 @@ description: "timeoutMS behaves correctly for the withTransaction API" -schemaVersion: "1.9" +schemaVersion: "1.26" runOnRequirements: - minServerVersion: "4.4" @@ -14,6 +14,8 @@ createEntities: id: &client client uriOptions: timeoutMS: 500 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent diff --git a/specifications/client-side-operations-timeout/tests/error-transformations.json b/specifications/client-side-operations-timeout/tests/error-transformations.json index 4889e39583a..89be49f0a4f 100644 --- a/specifications/client-side-operations-timeout/tests/error-transformations.json +++ b/specifications/client-side-operations-timeout/tests/error-transformations.json @@ -1,6 +1,6 @@ { "description": "MaxTimeMSExpired server errors are transformed into a custom timeout error", - "schemaVersion": "1.9", + "schemaVersion": "1.26", "runOnRequirements": [ { "minServerVersion": "4.0", @@ -26,8 +26,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" diff --git a/specifications/client-side-operations-timeout/tests/error-transformations.yml b/specifications/client-side-operations-timeout/tests/error-transformations.yml index 7bff4776a83..0ea9373b7dd 100644 --- a/specifications/client-side-operations-timeout/tests/error-transformations.yml +++ b/specifications/client-side-operations-timeout/tests/error-transformations.yml @@ -1,6 +1,6 @@ description: "MaxTimeMSExpired server errors are transformed into a custom timeout error" -schemaVersion: "1.9" +schemaVersion: "1.26" # failCommand is available on 4.0 for replica sets and 4.2 for sharded clusters. runOnRequirements: @@ -17,6 +17,8 @@ createEntities: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent diff --git a/specifications/client-side-operations-timeout/tests/global-timeoutMS.json b/specifications/client-side-operations-timeout/tests/global-timeoutMS.json index f1edbe68e39..9d8046d1bfa 100644 --- a/specifications/client-side-operations-timeout/tests/global-timeoutMS.json +++ b/specifications/client-side-operations-timeout/tests/global-timeoutMS.json @@ -1,6 +1,6 @@ { "description": "timeoutMS can be configured on a MongoClient", - "schemaVersion": "1.9", + "schemaVersion": "1.26", "runOnRequirements": [ { "minServerVersion": "4.4", @@ -38,8 +38,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -217,8 +219,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -390,8 +394,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -569,8 +575,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -762,8 +770,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -941,8 +951,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -1120,8 +1132,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -1305,8 +1319,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -1484,8 +1500,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -1663,8 +1681,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -1842,8 +1862,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -2021,8 +2043,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -2194,8 +2218,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -2375,8 +2401,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -2554,8 +2582,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -2733,8 +2763,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -2906,8 +2938,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -3079,8 +3113,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -3258,8 +3294,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -3441,8 +3479,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -3628,8 +3668,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -3807,8 +3849,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -3986,8 +4030,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -4171,8 +4217,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -4360,8 +4408,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -4549,8 +4599,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -4728,8 +4780,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -4913,8 +4967,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -5102,8 +5158,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -5297,8 +5355,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -5482,8 +5542,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" @@ -5677,8 +5739,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 250 + "timeoutMS": 250, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" diff --git a/specifications/client-side-operations-timeout/tests/global-timeoutMS.yml b/specifications/client-side-operations-timeout/tests/global-timeoutMS.yml index 847c26f096b..8cb1013166a 100644 --- a/specifications/client-side-operations-timeout/tests/global-timeoutMS.yml +++ b/specifications/client-side-operations-timeout/tests/global-timeoutMS.yml @@ -2,7 +2,7 @@ description: "timeoutMS can be configured on a MongoClient" -schemaVersion: "1.9" +schemaVersion: "1.26" runOnRequirements: - minServerVersion: "4.4" @@ -39,6 +39,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -139,6 +141,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -235,6 +239,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -335,6 +341,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -435,6 +443,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -535,6 +545,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -635,6 +647,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -737,6 +751,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -837,6 +853,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -937,6 +955,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -1037,6 +1057,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -1137,6 +1159,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -1233,6 +1257,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -1335,6 +1361,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -1435,6 +1463,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -1535,6 +1565,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -1631,6 +1663,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -1727,6 +1761,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -1827,6 +1863,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -1927,6 +1965,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -2029,6 +2069,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -2129,6 +2171,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -2229,6 +2273,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -2331,6 +2377,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -2433,6 +2481,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -2535,6 +2585,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -2635,6 +2687,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -2737,6 +2791,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -2839,6 +2895,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -2943,6 +3001,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -3045,6 +3105,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent @@ -3154,6 +3216,8 @@ tests: id: &client client uriOptions: timeoutMS: 250 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent diff --git a/specifications/client-side-operations-timeout/tests/retryability-timeoutMS.json b/specifications/client-side-operations-timeout/tests/retryability-timeoutMS.json index 9daad260ef3..5a0c9f36051 100644 --- a/specifications/client-side-operations-timeout/tests/retryability-timeoutMS.json +++ b/specifications/client-side-operations-timeout/tests/retryability-timeoutMS.json @@ -1,6 +1,6 @@ { "description": "timeoutMS behaves correctly for retryable operations", - "schemaVersion": "1.9", + "schemaVersion": "1.26", "runOnRequirements": [ { "minServerVersion": "4.0", @@ -26,8 +26,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 100 + "timeoutMS": 100, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" diff --git a/specifications/client-side-operations-timeout/tests/retryability-timeoutMS.yml b/specifications/client-side-operations-timeout/tests/retryability-timeoutMS.yml index 6f47d6c2e42..5e0ad164a2c 100644 --- a/specifications/client-side-operations-timeout/tests/retryability-timeoutMS.yml +++ b/specifications/client-side-operations-timeout/tests/retryability-timeoutMS.yml @@ -2,7 +2,7 @@ description: "timeoutMS behaves correctly for retryable operations" -schemaVersion: "1.9" +schemaVersion: "1.26" # failCommand is available on 4.0+ replica sets and 4.2+ sharded clusters. runOnRequirements: @@ -19,6 +19,8 @@ createEntities: id: &client client uriOptions: timeoutMS: 100 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent diff --git a/specifications/client-side-operations-timeout/tests/sessions-inherit-timeoutMS.json b/specifications/client-side-operations-timeout/tests/sessions-inherit-timeoutMS.json index 13ea91c7948..dbf163e484e 100644 --- a/specifications/client-side-operations-timeout/tests/sessions-inherit-timeoutMS.json +++ b/specifications/client-side-operations-timeout/tests/sessions-inherit-timeoutMS.json @@ -1,6 +1,6 @@ { "description": "sessions inherit timeoutMS from their parent MongoClient", - "schemaVersion": "1.9", + "schemaVersion": "1.26", "runOnRequirements": [ { "minServerVersion": "4.4", @@ -21,8 +21,10 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 500 + "timeoutMS": 500, + "minPoolSize": 1 }, + "awaitMinPoolSizeMS": 10000, "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent", diff --git a/specifications/client-side-operations-timeout/tests/sessions-inherit-timeoutMS.yml b/specifications/client-side-operations-timeout/tests/sessions-inherit-timeoutMS.yml index c79384e5f0b..77f216d3adf 100644 --- a/specifications/client-side-operations-timeout/tests/sessions-inherit-timeoutMS.yml +++ b/specifications/client-side-operations-timeout/tests/sessions-inherit-timeoutMS.yml @@ -1,6 +1,6 @@ description: "sessions inherit timeoutMS from their parent MongoClient" -schemaVersion: "1.9" +schemaVersion: "1.26" runOnRequirements: - minServerVersion: "4.4" @@ -14,6 +14,8 @@ createEntities: id: &client client uriOptions: timeoutMS: 500 + minPoolSize: 1 + awaitMinPoolSizeMS: 10000 useMultipleMongoses: false observeEvents: - commandStartedEvent diff --git a/src/MongoDB.Driver/Authentication/AuthenticationHelper.cs b/src/MongoDB.Driver/Authentication/AuthenticationHelper.cs index 851abd47377..679897eb45e 100644 --- a/src/MongoDB.Driver/Authentication/AuthenticationHelper.cs +++ b/src/MongoDB.Driver/Authentication/AuthenticationHelper.cs @@ -59,7 +59,7 @@ public static async Task AuthenticateAsync(OperationContext operationContext, IC // authentication is currently broken on arbiters if (!description.HelloResult.IsArbiter) { - await authenticator.AuthenticateAsync(operationContext, connection, description).ConfigureAwait(false); + await authenticator.AuthenticateAsync(operationContext, connection, description).ConfigureAwait(false); } } diff --git a/src/MongoDB.Driver/Core/Clusters/Cluster.cs b/src/MongoDB.Driver/Core/Clusters/Cluster.cs index 83591f43ea3..db14eed8b19 100644 --- a/src/MongoDB.Driver/Core/Clusters/Cluster.cs +++ b/src/MongoDB.Driver/Core/Clusters/Cluster.cs @@ -89,6 +89,8 @@ public ClusterDescription Description } } + public abstract IEnumerable Servers { get; } + public ClusterSettings Settings { get { return _settings; } diff --git a/src/MongoDB.Driver/Core/Clusters/ICluster.cs b/src/MongoDB.Driver/Core/Clusters/ICluster.cs index ea31d13bc12..97c9a686226 100644 --- a/src/MongoDB.Driver/Core/Clusters/ICluster.cs +++ b/src/MongoDB.Driver/Core/Clusters/ICluster.cs @@ -14,6 +14,7 @@ */ using System; +using System.Collections.Generic; using System.Threading.Tasks; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters.ServerSelectors; @@ -55,6 +56,8 @@ public interface ICluster : IDisposable internal interface IClusterInternal : ICluster { + IEnumerable Servers { get; } + event EventHandler DescriptionChanged; ICoreServerSession AcquireServerSession(); diff --git a/src/MongoDB.Driver/Core/Clusters/LoadBalancedCluster.cs b/src/MongoDB.Driver/Core/Clusters/LoadBalancedCluster.cs index 7fa3b29b038..bbe903661ad 100644 --- a/src/MongoDB.Driver/Core/Clusters/LoadBalancedCluster.cs +++ b/src/MongoDB.Driver/Core/Clusters/LoadBalancedCluster.cs @@ -142,6 +142,19 @@ private void Dispose(bool disposing) } } + public IEnumerable Servers + { + get + { + if (_server == null) + { + return []; + } + + return [_server]; + } + } + public void Initialize() { ThrowIfDisposed(); diff --git a/src/MongoDB.Driver/Core/Clusters/MultiServerCluster.cs b/src/MongoDB.Driver/Core/Clusters/MultiServerCluster.cs index 2b463f1c894..57087d7789f 100644 --- a/src/MongoDB.Driver/Core/Clusters/MultiServerCluster.cs +++ b/src/MongoDB.Driver/Core/Clusters/MultiServerCluster.cs @@ -90,6 +90,8 @@ protected override void Dispose(bool disposing) } } + public override IEnumerable Servers => _servers; + public override void Initialize() { base.Initialize(); diff --git a/src/MongoDB.Driver/Core/Clusters/SingleServerCluster.cs b/src/MongoDB.Driver/Core/Clusters/SingleServerCluster.cs index 0f6651a2b92..ff391eb48eb 100644 --- a/src/MongoDB.Driver/Core/Clusters/SingleServerCluster.cs +++ b/src/MongoDB.Driver/Core/Clusters/SingleServerCluster.cs @@ -13,6 +13,7 @@ * limitations under the License. */ +using System.Collections.Generic; using System.Diagnostics; using System.Net; using Microsoft.Extensions.Logging; @@ -72,6 +73,19 @@ protected override void Dispose(bool disposing) } } + public override IEnumerable Servers + { + get + { + if (_server == null) + { + return []; + } + + return [_server]; + } + } + public override void Initialize() { base.Initialize(); diff --git a/src/MongoDB.Driver/Core/Servers/IServer.cs b/src/MongoDB.Driver/Core/Servers/IServer.cs index 643a5883126..9010405d1b3 100644 --- a/src/MongoDB.Driver/Core/Servers/IServer.cs +++ b/src/MongoDB.Driver/Core/Servers/IServer.cs @@ -18,6 +18,7 @@ using System.Threading.Tasks; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; +using MongoDB.Driver.Core.ConnectionPools; using MongoDB.Driver.Core.Connections; namespace MongoDB.Driver.Core.Servers @@ -40,6 +41,7 @@ internal interface IServer internal interface IClusterableServer : IServer, IDisposable { + IConnectionPool ConnectionPool { get; } bool IsInitialized { get; } int OutstandingOperationsCount { get; } diff --git a/tests/MongoDB.Driver.Tests/Core/Clusters/ClusterTests.cs b/tests/MongoDB.Driver.Tests/Core/Clusters/ClusterTests.cs index 2b9f141dec0..5879776f3ac 100644 --- a/tests/MongoDB.Driver.Tests/Core/Clusters/ClusterTests.cs +++ b/tests/MongoDB.Driver.Tests/Core/Clusters/ClusterTests.cs @@ -586,6 +586,8 @@ public override void Initialize() UpdateClusterDescription(Description.WithType(_clusterType ?? Settings.GetInitialClusterType())); } + public override IEnumerable Servers => _servers.Values; + public void RemoveServer(EndPoint endPoint) { _servers.Remove(endPoint); diff --git a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedEntityMap.cs b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedEntityMap.cs index e5ea553ff15..5649ca8a3c2 100644 --- a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedEntityMap.cs +++ b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedEntityMap.cs @@ -16,6 +16,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -24,6 +25,7 @@ using MongoDB.Driver.Core; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Configuration; +using MongoDB.Driver.Core.ConnectionPools; using MongoDB.Driver.Core.Events; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; @@ -494,6 +496,7 @@ private IGridFSBucket CreateBucket(BsonDocument entity, Dictionary 0) + { + if (!SpinWait.SpinUntil(() => + { + var servers = ((IClusterInternal)client.Cluster).Servers.Where(s => s.Description.IsDataBearing).ToArray(); + return servers.Any() && servers.All(s => ((ExclusiveConnectionPool)s.ConnectionPool).DormantCount >= minPoolSize); + }, awaitMinPoolSizeTimeout.Value)) + { + client.Dispose(); + throw new TimeoutException("MinPoolSize population took too long"); + } + + foreach (var eventCapturer in clientEventCapturers.Values) + { + eventCapturer.Clear(); + } + } + return (client, clientEventCapturers, loggingComponents); } diff --git a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedTestRunner.cs b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedTestRunner.cs index 7256a5748d7..547dbfb4a2b 100644 --- a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedTestRunner.cs @@ -108,7 +108,7 @@ public void Run( var schemaSemanticVersion = SemanticVersion.Parse(schemaVersion); if (schemaSemanticVersion < new SemanticVersion(1, 0, 0) || - schemaSemanticVersion > new SemanticVersion(1, 25, 0)) + schemaSemanticVersion > new SemanticVersion(1, 26, 0)) { throw new FormatException($"Schema version '{schemaVersion}' is not supported."); }