From 5af76dd29f1e63e4b319a6a81914198c9173d8d2 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Thu, 30 Nov 2023 17:17:52 -0500 Subject: [PATCH 01/22] added tests --- ...rver_discovery_and_monitoring.spec.test.ts | 2 +- .../unified/auth-error.json | 2 +- .../unified/auth-error.yml | 2 +- .../unified/auth-misc-command-error.json | 2 +- .../unified/auth-misc-command-error.yml | 2 +- .../unified/auth-network-error.json | 2 +- .../unified/auth-network-error.yml | 2 +- .../unified/auth-network-timeout-error.json | 2 +- .../unified/auth-network-timeout-error.yml | 2 +- .../unified/auth-shutdown-error.json | 2 +- .../unified/auth-shutdown-error.yml | 2 +- .../unified/cancel-server-check.json | 2 +- .../unified/cancel-server-check.yml | 2 +- .../unified/connectTimeoutMS.json | 2 +- .../unified/connectTimeoutMS.yml | 2 +- .../unified/find-network-error.json | 2 +- .../unified/find-network-error.yml | 2 +- .../unified/find-network-timeout-error.json | 2 +- .../unified/find-network-timeout-error.yml | 2 +- .../unified/find-shutdown-error.json | 2 +- .../unified/find-shutdown-error.yml | 2 +- .../unified/hello-command-error.json | 2 +- .../unified/hello-command-error.yml | 2 +- .../unified/hello-network-error.json | 2 +- .../unified/hello-network-error.yml | 2 +- .../unified/hello-timeout.json | 2 +- .../unified/hello-timeout.yml | 2 +- .../unified/insert-network-error.json | 2 +- .../unified/insert-network-error.yml | 2 +- .../unified/insert-shutdown-error.json | 2 +- .../unified/insert-shutdown-error.yml | 2 +- .../unified/interruptInUse-pool-clear.json | 78 ++- .../unified/interruptInUse-pool-clear.yml | 42 +- .../unified/logging-loadbalanced.json | 150 +++++ .../unified/logging-loadbalanced.yml | 74 +++ .../unified/logging-replicaset.json | 606 ++++++++++++++++++ .../unified/logging-replicaset.yml | 289 +++++++++ .../unified/logging-sharded.json | 492 ++++++++++++++ .../unified/logging-sharded.yml | 248 +++++++ .../unified/logging-standalone.json | 517 +++++++++++++++ .../unified/logging-standalone.yml | 258 ++++++++ .../unified/minPoolSize-error.json | 2 +- .../unified/minPoolSize-error.yml | 2 +- .../unified/pool-cleared-error.json | 2 +- .../unified/pool-cleared-error.yml | 2 +- .../rediscover-quickly-after-step-down.json | 2 +- .../rediscover-quickly-after-step-down.yml | 2 +- 47 files changed, 2731 insertions(+), 97 deletions(-) create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-sharded.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-standalone.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-standalone.yml diff --git a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts index 74fc67efc6..312d6cbba7 100644 --- a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts +++ b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts @@ -3,6 +3,6 @@ import * as path from 'path'; import { loadSpecTests } from '../../spec'; import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; -describe('SDAM Unified Tests', function () { +describe.only('SDAM Unified Tests', function () { runUnifiedSuite(loadSpecTests(path.join('server-discovery-and-monitoring', 'unified'))); }); diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-error.json index 5c78ecfe50..62d26494c7 100644 --- a/test/spec/server-discovery-and-monitoring/unified/auth-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/auth-error.json @@ -1,6 +1,6 @@ { "description": "auth-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-error.yml index b2dfc4eccc..febf4a46dc 100644 --- a/test/spec/server-discovery-and-monitoring/unified/auth-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/auth-error.yml @@ -1,6 +1,6 @@ description: auth-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.json index 6e1b645461..fd62fe604e 100644 --- a/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.json @@ -1,6 +1,6 @@ { "description": "auth-misc-command-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.yml index 94d41d6616..9969ca92d4 100644 --- a/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.yml @@ -1,7 +1,7 @@ --- description: auth-misc-command-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-network-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-network-error.json index 7606d2db7a..84763af32e 100644 --- a/test/spec/server-discovery-and-monitoring/unified/auth-network-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/auth-network-error.json @@ -1,6 +1,6 @@ { "description": "auth-network-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-network-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-network-error.yml index 9073a927ce..cdf77c56df 100644 --- a/test/spec/server-discovery-and-monitoring/unified/auth-network-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/auth-network-error.yml @@ -1,7 +1,7 @@ --- description: auth-network-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.json index 22066e8bae..3cf9576eba 100644 --- a/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.json @@ -1,6 +1,6 @@ { "description": "auth-network-timeout-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.yml index 8b29a1e670..49b91d8373 100644 --- a/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.yml @@ -1,7 +1,7 @@ --- description: auth-network-timeout-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.json index 5dd7b5bb6f..b9e503af66 100644 --- a/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.json @@ -1,6 +1,6 @@ { "description": "auth-shutdown-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.yml index 87a937d381..f0bb4d17df 100644 --- a/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.yml @@ -1,7 +1,7 @@ --- description: auth-shutdown-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.json b/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.json index 896cc8d087..a60ccfcb41 100644 --- a/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.json +++ b/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.json @@ -1,6 +1,6 @@ { "description": "cancel-server-check", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.0", diff --git a/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.yml b/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.yml index 67d96706e1..af46792546 100644 --- a/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.yml +++ b/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.yml @@ -1,7 +1,7 @@ --- description: cancel-server-check -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # General failCommand requirements (this file does not use appName diff --git a/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.json b/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.json index 67a4d9da1d..d3e860a9cb 100644 --- a/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.json +++ b/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.json @@ -1,6 +1,6 @@ { "description": "connectTimeoutMS", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.yml b/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.yml index ef6d1150a7..7c610623eb 100644 --- a/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.yml +++ b/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.yml @@ -1,7 +1,7 @@ --- description: connectTimeoutMS -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/find-network-error.json b/test/spec/server-discovery-and-monitoring/unified/find-network-error.json index 651466bfa6..c1b6db40ca 100644 --- a/test/spec/server-discovery-and-monitoring/unified/find-network-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/find-network-error.json @@ -1,6 +1,6 @@ { "description": "find-network-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/test/spec/server-discovery-and-monitoring/unified/find-network-error.yml b/test/spec/server-discovery-and-monitoring/unified/find-network-error.yml index deae09a19f..f97d799a2a 100644 --- a/test/spec/server-discovery-and-monitoring/unified/find-network-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/find-network-error.yml @@ -1,7 +1,7 @@ --- description: find-network-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.json b/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.json index 2bde6daa5d..e5ac9f21aa 100644 --- a/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.json @@ -1,6 +1,6 @@ { "description": "find-network-timeout-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.yml b/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.yml index 30c4809ccf..e00b7a2be0 100644 --- a/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.yml @@ -1,7 +1,7 @@ --- description: find-network-timeout-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.json b/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.json index 624ad352fc..6e5a2cac05 100644 --- a/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.json @@ -1,6 +1,6 @@ { "description": "find-shutdown-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.yml b/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.yml index f2da705d9e..395215244b 100644 --- a/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.yml @@ -1,7 +1,7 @@ --- description: find-shutdown-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-command-error.json b/test/spec/server-discovery-and-monitoring/unified/hello-command-error.json index 7d6046b76f..9afea87e77 100644 --- a/test/spec/server-discovery-and-monitoring/unified/hello-command-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/hello-command-error.json @@ -1,6 +1,6 @@ { "description": "hello-command-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.9", diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-command-error.yml b/test/spec/server-discovery-and-monitoring/unified/hello-command-error.yml index 2dc8be2f3b..3b1428deb0 100644 --- a/test/spec/server-discovery-and-monitoring/unified/hello-command-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/hello-command-error.yml @@ -1,7 +1,7 @@ --- description: hello-command-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-network-error.json b/test/spec/server-discovery-and-monitoring/unified/hello-network-error.json index f44b26a9f9..55373c90cc 100644 --- a/test/spec/server-discovery-and-monitoring/unified/hello-network-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/hello-network-error.json @@ -1,6 +1,6 @@ { "description": "hello-network-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.9", diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-network-error.yml b/test/spec/server-discovery-and-monitoring/unified/hello-network-error.yml index 20932b39c6..92c8cf243d 100644 --- a/test/spec/server-discovery-and-monitoring/unified/hello-network-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/hello-network-error.yml @@ -1,7 +1,7 @@ --- description: hello-network-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-timeout.json b/test/spec/server-discovery-and-monitoring/unified/hello-timeout.json index dfa6b48d66..fe7cf4e78d 100644 --- a/test/spec/server-discovery-and-monitoring/unified/hello-timeout.json +++ b/test/spec/server-discovery-and-monitoring/unified/hello-timeout.json @@ -1,6 +1,6 @@ { "description": "hello-timeout", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-timeout.yml b/test/spec/server-discovery-and-monitoring/unified/hello-timeout.yml index efab836e65..2a3374d1e7 100644 --- a/test/spec/server-discovery-and-monitoring/unified/hello-timeout.yml +++ b/test/spec/server-discovery-and-monitoring/unified/hello-timeout.yml @@ -1,7 +1,7 @@ --- description: hello-timeout -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/insert-network-error.json b/test/spec/server-discovery-and-monitoring/unified/insert-network-error.json index e4ba6684ae..bfe41a4cb6 100644 --- a/test/spec/server-discovery-and-monitoring/unified/insert-network-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/insert-network-error.json @@ -1,6 +1,6 @@ { "description": "insert-network-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/test/spec/server-discovery-and-monitoring/unified/insert-network-error.yml b/test/spec/server-discovery-and-monitoring/unified/insert-network-error.yml index fc9c2f4921..fcedf54357 100644 --- a/test/spec/server-discovery-and-monitoring/unified/insert-network-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/insert-network-error.yml @@ -1,7 +1,7 @@ --- description: insert-network-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.json b/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.json index 3c724fa5e4..af7c6c987a 100644 --- a/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.json @@ -1,6 +1,6 @@ { "description": "insert-shutdown-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.yml b/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.yml index 1ec920a6bc..ae32229ffa 100644 --- a/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.yml @@ -1,7 +1,7 @@ --- description: insert-shutdown-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json b/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json index 1e4402f599..a20d79030a 100644 --- a/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json +++ b/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json @@ -4,11 +4,11 @@ "runOnRequirements": [ { "minServerVersion": "4.9", + "serverless": "forbid", "topologies": [ "replicaset", "sharded" - ], - "serverless": "forbid" + ] } ], "createEntities": [ @@ -39,13 +39,6 @@ "client": { "id": "client", "useMultipleMongoses": false, - "uriOptions": { - "connectTimeoutMS": 500, - "heartbeatFrequencyMS": 500, - "appname": "interruptInUse", - "retryReads": false, - "minPoolSize": 0 - }, "observeEvents": [ "poolClearedEvent", "connectionClosedEvent", @@ -54,7 +47,14 @@ "commandFailedEvent", "connectionCheckedOutEvent", "connectionCheckedInEvent" - ] + ], + "uriOptions": { + "connectTimeoutMS": 500, + "heartbeatFrequencyMS": 500, + "appname": "interruptInUse", + "retryReads": false, + "minPoolSize": 0 + } } }, { @@ -111,6 +111,7 @@ "name": "failPoint", "object": "testRunner", "arguments": { + "client": "setupClient", "failPoint": { "configureFailPoint": "failCommand", "mode": { @@ -125,8 +126,7 @@ "blockTimeMS": 1500, "appName": "interruptInUse" } - }, - "client": "setupClient" + } } }, { @@ -215,22 +215,22 @@ "client": { "id": "client", "useMultipleMongoses": false, - "uriOptions": { - "connectTimeoutMS": 500, - "heartbeatFrequencyMS": 500, - "appname": "interruptInUseRetryable", - "retryReads": true, - "minPoolSize": 0 - }, "observeEvents": [ "poolClearedEvent", "connectionClosedEvent", - "commandFailedEvent", "commandStartedEvent", + "commandFailedEvent", "commandSucceededEvent", "connectionCheckedOutEvent", "connectionCheckedInEvent" - ] + ], + "uriOptions": { + "connectTimeoutMS": 500, + "heartbeatFrequencyMS": 500, + "appname": "interruptInUseRetryable", + "retryReads": true, + "minPoolSize": 0 + } } }, { @@ -284,6 +284,7 @@ "name": "failPoint", "object": "testRunner", "arguments": { + "client": "setupClient", "failPoint": { "configureFailPoint": "failCommand", "mode": { @@ -298,8 +299,7 @@ "blockTimeMS": 1500, "appName": "interruptInUseRetryable" } - }, - "client": "setupClient" + } } }, { @@ -404,22 +404,22 @@ "client": { "id": "client", "useMultipleMongoses": false, - "uriOptions": { - "connectTimeoutMS": 500, - "heartbeatFrequencyMS": 500, - "appname": "interruptInUseRetryableWrite", - "retryWrites": true, - "minPoolSize": 0 - }, "observeEvents": [ "poolClearedEvent", "connectionClosedEvent", - "commandFailedEvent", "commandStartedEvent", + "commandFailedEvent", "commandSucceededEvent", "connectionCheckedOutEvent", "connectionCheckedInEvent" - ] + ], + "uriOptions": { + "connectTimeoutMS": 500, + "heartbeatFrequencyMS": 500, + "appname": "interruptInUseRetryableWrite", + "retryWrites": true, + "minPoolSize": 0 + } } }, { @@ -465,13 +465,11 @@ "filter": { "$where": "sleep(2000) || true" }, - "update": [ - { - "$set": { - "a": "bar" - } + "update": { + "$set": { + "a": "bar" } - ] + } } } } @@ -480,6 +478,7 @@ "name": "failPoint", "object": "testRunner", "arguments": { + "client": "setupClient", "failPoint": { "configureFailPoint": "failCommand", "mode": { @@ -494,8 +493,7 @@ "blockTimeMS": 1500, "appName": "interruptInUseRetryableWrite" } - }, - "client": "setupClient" + } } }, { diff --git a/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml b/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml index 5db669d58d..1f241e8536 100644 --- a/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml +++ b/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml @@ -72,7 +72,7 @@ tests: isError: true # Configure the monitor check to fail with a timeout. # Use "times: 4" to increase the probability that the Monitor check triggers - # the failpoint, since the RTT hello may trigger this failpoint one or many + # the failpoint, since the RTT hello may trigger this failpoint one or many # times as well. - name: failPoint object: testRunner @@ -86,11 +86,11 @@ tests: failCommands: - hello - isMaster - blockConnection: true, - blockTimeMS: 1500, - appName: interruptInUse + blockConnection: true + blockTimeMS: 1500 + appName: interruptInUse - name: waitForThread - object: testRunner, + object: testRunner arguments: thread: *thread1 @@ -100,6 +100,8 @@ tests: events: - commandStartedEvent: commandName: insert + - commandSucceededEvent: + commandName: insert - commandStartedEvent: commandName: find - commandFailedEvent: @@ -171,7 +173,7 @@ tests: $where : sleep(2000) || true # Configure the monitor check to fail with a timeout. # Use "times: 4" to increase the probability that the Monitor check triggers - # the failpoint, since the RTT hello may trigger this failpoint one or many + # the failpoint, since the RTT hello may trigger this failpoint one or many # times as well. - name: failPoint object: testRunner @@ -185,11 +187,11 @@ tests: failCommands: - hello - isMaster - blockConnection: true, - blockTimeMS: 1500, + blockConnection: true + blockTimeMS: 1500 appName: interruptInUseRetryable - name: waitForThread - object: testRunner, + object: testRunner arguments: thread: *thread1 @@ -221,7 +223,7 @@ tests: - connectionClosedEvent: {} - connectionCheckedOutEvent: {} - connectionCheckedInEvent: {} - + outcome: - collectionName: *collectionName databaseName: *databaseName @@ -260,7 +262,7 @@ tests: collectionName: *collectionName - thread: id: &thread1 thread1 - # ensure the primary is discovered + # ensure the primary is discovered - name: insertOne object: *collection arguments: @@ -274,13 +276,13 @@ tests: name: updateOne object: *collection arguments: - filter: - $where": sleep(2000) || true - update: - "$set": { "a": "bar" } + filter: + $where: sleep(2000) || true + update: + "$set": { "a": "bar" } # Configure the monitor check to fail with a timeout. # Use "times: 4" to increase the probability that the Monitor check triggers - # the failpoint, since the RTT hello may trigger this failpoint one or many + # the failpoint, since the RTT hello may trigger this failpoint one or many # times as well. - name: failPoint object: testRunner @@ -294,11 +296,11 @@ tests: failCommands: - hello - isMaster - blockConnection: true, - blockTimeMS: 1500, + blockConnection: true + blockTimeMS: 1500 appName: interruptInUseRetryableWrite - name: waitForThread - object: testRunner, + object: testRunner arguments: thread: *thread1 @@ -330,7 +332,7 @@ tests: - connectionClosedEvent: {} - connectionCheckedOutEvent: {} - connectionCheckedInEvent: {} - + outcome: - collectionName: *collectionName databaseName: *databaseName diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.json b/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.json new file mode 100644 index 0000000000..45440d2557 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.json @@ -0,0 +1,150 @@ +{ + "description": "loadbalanced-logging", + "schemaVersion": "1.16", + "runOnRequirements": [ + { + "topologies": [ + "load-balanced" + ], + "minServerVersion": "4.4" + } + ], + "tests": [ + { + "description": "Topology lifecycle", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "topologyDescriptionChangedEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "topologyDescriptionChangedEvent": {} + }, + "count": 2 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring", + "topologyId": { + "$$exists": true + } + } + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.yml b/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.yml new file mode 100644 index 0000000000..3f6058270f --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.yml @@ -0,0 +1,74 @@ +description: "loadbalanced-logging" + +schemaVersion: "1.16" + +runOnRequirements: + - topologies: + - load-balanced + minServerVersion: "4.4" # awaitable hello + +tests: + - description: "Topology lifecycle" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeLogMessages: + topology: debug + observeEvents: + - topologyDescriptionChangedEvent + # ensure the topology has been fully discovered before closing the client. + # expected events are initial server discovery and server connect event. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + topologyDescriptionChangedEvent: {} + count: 2 + - name: close + object: *client + expectLogMessages: + - client: *client + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: { $$exists: true } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # unknown topology + newDescription: { $$exists: true } # unknown topology, disconnected server + - level: debug + component: topology + data: + message: "Starting server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # loadBalanced topology + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Stopped topology monitoring" + topologyId: { $$exists: true } \ No newline at end of file diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json new file mode 100644 index 0000000000..e6738225cd --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json @@ -0,0 +1,606 @@ +{ + "description": "replicaset-logging", + "schemaVersion": "1.16", + "runOnRequirements": [ + { + "topologies": [ + "replicaset" + ], + "minServerVersion": "4.4" + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient" + } + } + ], + "tests": [ + { + "description": "Topology lifecycle", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "topologyDescriptionChangedEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "topologyDescriptionChangedEvent": {} + }, + "count": 4 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring", + "topologyId": { + "$$exists": true + } + } + } + ] + } + ] + }, + { + "description": "Successful heartbeat", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "serverHeartbeatSucceededEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatSucceededEvent": {} + }, + "count": 3 + } + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreExtraMessages": true, + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "serverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "reply": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "ok": 1 + } + } + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "serverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "reply": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "ok": 1 + } + } + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "serverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "reply": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "ok": 1 + } + } + } + } + } + ] + } + ] + }, + { + "description": "Failing heartbeat", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "serverHeartbeatFailedEvent" + ], + "uriOptions": { + "appname": "failingHeartbeatLoggingTest" + } + } + } + ] + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "failPoint": { + "configureFailPoint": "failCommand", + "mode": "alwaysOn", + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "failingHeartbeatLoggingTest", + "closeConnection": true + } + }, + "client": "setupClient" + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatFailedEvent": {} + }, + "count": 1 + } + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreExtraMessages": true, + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "failure": { + "$$exists": true + } + } + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml new file mode 100644 index 0000000000..a0b856ec72 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml @@ -0,0 +1,289 @@ +description: "replicaset-logging" + +schemaVersion: "1.16" + +runOnRequirements: + - topologies: + - replicaset + minServerVersion: "4.4" # awaitable hello + +createEntities: + - client: + id: &setupClient setupClient + +tests: + - description: "Topology lifecycle" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeLogMessages: + topology: debug + observeEvents: + - topologyDescriptionChangedEvent + # ensure the topology has been fully discovered before closing the client. + # expected events are initial cluster type change from unknown to ReplicaSet, and connect events for each of 3 servers. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + topologyDescriptionChangedEvent: {} + count: 4 + - name: close + object: *client + expectLogMessages: + - client: *client + ignoreMessages: + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + - level: debug + component: topology + data: + message: "Server heartbeat failed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: { $$exists: true } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # unknown topology + newDescription: { $$exists: true } # ReplicaSet topology + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # server connected + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # server connected + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # server connected + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # ReplicaSet topology + newDescription: { $$exists: true } # unknown topology + - level: debug + component: topology + data: + message: "Stopped topology monitoring" + topologyId: { $$exists: true } + - description: Successful heartbeat + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: *client + observeLogMessages: + topology: debug + observeEvents: + - serverHeartbeatSucceededEvent + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverHeartbeatSucceededEvent: {} + count: 3 + expectLogMessages: + - client: *client + ignoreExtraMessages: true + ignoreMessages: + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Stopped server monitoring" + - level: debug + component: topology + data: + message: "Topology description changed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: { $$exists: true } + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + reply: + $$matchAsDocument: + "$$matchAsRoot": + ok: 1 + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + reply: + $$matchAsDocument: + "$$matchAsRoot": + ok: 1 + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + reply: + $$matchAsDocument: + "$$matchAsRoot": + ok: 1 + - description: Failing heartbeat + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: *client + observeLogMessages: + topology: debug + observeEvents: + - serverHeartbeatFailedEvent + uriOptions: + appname: failingHeartbeatLoggingTest + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: "alwaysOn" + data: + failCommands: + - hello + - isMaster + appName: failingHeartbeatLoggingTest + closeConnection: true + client: *setupClient + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverHeartbeatFailedEvent: {} + count: 1 + expectLogMessages: + - client: *client + ignoreExtraMessages: true + ignoreMessages: + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Stopped server monitoring" + - level: debug + component: topology + data: + message: "Topology description changed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: + "$$exists": true + - level: debug + component: topology + data: + message: "Server heartbeat failed" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + failure: { $$exists: true } \ No newline at end of file diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json new file mode 100644 index 0000000000..61b27f5be0 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json @@ -0,0 +1,492 @@ +{ + "description": "sharded-logging", + "schemaVersion": "1.16", + "runOnRequirements": [ + { + "topologies": [ + "sharded" + ], + "minServerVersion": "4.4" + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "tests": [ + { + "description": "Topology lifecycle", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "topologyDescriptionChangedEvent" + ], + "useMultipleMongoses": true + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "topologyDescriptionChangedEvent": {} + }, + "count": 3 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring", + "topologyId": { + "$$exists": true + } + } + } + ] + } + ] + }, + { + "description": "Successful heartbeat", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "serverHeartbeatSucceededEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatSucceededEvent": {} + }, + "count": 1 + } + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreExtraMessages": true, + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "serverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "reply": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "ok": 1 + } + } + } + } + } + ] + } + ] + }, + { + "description": "Failing heartbeat", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "serverHeartbeatStartedEvent", + "serverHeartbeatFailedEvent" + ], + "uriOptions": { + "appname": "failingHeartbeatLoggingTest" + } + } + } + ] + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "failPoint": { + "configureFailPoint": "failCommand", + "mode": "alwaysOn", + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "failingHeartbeatLoggingTest", + "closeConnection": true + } + }, + "client": "setupClient" + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatFailedEvent": {} + }, + "count": 1 + } + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreExtraMessages": true, + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "failure": { + "$$exists": true + } + } + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml new file mode 100644 index 0000000000..19870878b9 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml @@ -0,0 +1,248 @@ +description: "sharded-logging" + +schemaVersion: "1.16" + +runOnRequirements: + - topologies: + - sharded + minServerVersion: "4.4" # awaitable hello + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +tests: + - description: "Topology lifecycle" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeLogMessages: + topology: debug + observeEvents: + - topologyDescriptionChangedEvent + useMultipleMongoses: true + # ensure the topology has been fully discovered before closing the client. + # expected events are initial cluster type change from unknown to sharded, and connect events for each of 2 servers. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + topologyDescriptionChangedEvent: {} + count: 3 + - name: close + object: *client + expectLogMessages: + - client: *client + ignoreMessages: + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + - level: debug + component: topology + data: + message: "Server heartbeat failed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: { $$exists: true } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # unknown topology + newDescription: { $$exists: true } # Sharded topology + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # shard router connected + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # shard router connected + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # Sharded topology + newDescription: { $$exists: true } # unknown topology + - level: debug + component: topology + data: + message: "Stopped topology monitoring" + topologyId: { $$exists: true } + - description: Successful heartbeat + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: *client + observeLogMessages: + topology: debug + observeEvents: + - serverHeartbeatSucceededEvent + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverHeartbeatSucceededEvent: {} + count: 1 + expectLogMessages: + - client: *client + ignoreExtraMessages: true + ignoreMessages: + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Stopped server monitoring" + - level: debug + component: topology + data: + message: "Topology description changed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: { $$exists: true } + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + reply: + $$matchAsDocument: + "$$matchAsRoot": + ok: 1 + - description: Failing heartbeat + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: *client + observeLogMessages: + topology: debug + observeEvents: + - serverHeartbeatStartedEvent + - serverHeartbeatFailedEvent + uriOptions: + appname: failingHeartbeatLoggingTest + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: "alwaysOn" + data: + failCommands: + - hello + - isMaster + appName: failingHeartbeatLoggingTest + closeConnection: true + client: *setupClient + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverHeartbeatFailedEvent: {} + count: 1 + expectLogMessages: + - client: *client + ignoreExtraMessages: true + ignoreMessages: + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Stopped server monitoring" + - level: debug + component: topology + data: + message: "Topology description changed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: + "$$exists": true + - level: debug + component: topology + data: + message: "Server heartbeat failed" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + failure: { $$exists: true } \ No newline at end of file diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json new file mode 100644 index 0000000000..1ee6dbe899 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json @@ -0,0 +1,517 @@ +{ + "description": "standalone-logging", + "schemaVersion": "1.16", + "runOnRequirements": [ + { + "topologies": [ + "single" + ], + "minServerVersion": "4.4" + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient" + } + } + ], + "tests": [ + { + "description": "Topology lifecycle", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "topologyDescriptionChangedEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "topologyDescriptionChangedEvent": {} + }, + "count": 2 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring", + "topologyId": { + "$$exists": true + } + } + } + ] + } + ] + }, + { + "description": "Successful heartbeat", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "serverHeartbeatSucceededEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatSucceededEvent": {} + }, + "count": 1 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreExtraMessages": true, + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "serverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "reply": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "ok": 1 + } + } + } + } + } + ] + } + ] + }, + { + "description": "Failing heartbeat", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "serverHeartbeatFailedEvent" + ], + "uriOptions": { + "appname": "failingHeartbeatLoggingTest" + } + } + } + ] + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": "alwaysOn", + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "failingHeartbeatLoggingTest", + "closeConnection": true + } + } + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatFailedEvent": {} + }, + "count": 1 + } + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreExtraMessages": true, + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "failure": { + "$$exists": true + } + } + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-standalone.yml b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.yml new file mode 100644 index 0000000000..80cf98a20e --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.yml @@ -0,0 +1,258 @@ +description: "standalone-logging" + +schemaVersion: "1.16" + +runOnRequirements: + - topologies: + - single + minServerVersion: "4.4" # awaitable hello + +createEntities: + - client: + id: &setupClient setupClient + +tests: + - description: "Topology lifecycle" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeLogMessages: + topology: debug + observeEvents: + - topologyDescriptionChangedEvent + # ensure the topology has been fully discovered before closing the client. + # expected events are initial server discovery and server connect event. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + topologyDescriptionChangedEvent: {} + count: 2 + - name: close + object: *client + expectLogMessages: + - client: *client + ignoreMessages: + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + - level: debug + component: topology + data: + message: "Server heartbeat failed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: { $$exists: true } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # unknown topology + newDescription: { $$exists: true } # unknown topology, disconnected server + - level: debug + component: topology + data: + message: "Starting server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # standalone topology + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # standalone topology + newDescription: { $$exists: true } # unknown topology + - level: debug + component: topology + data: + message: "Stopped topology monitoring" + topologyId: { $$exists: true } + - description: Successful heartbeat + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeLogMessages: + topology: debug + observeEvents: + - serverHeartbeatSucceededEvent + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverHeartbeatSucceededEvent: {} + count: 1 + - name: close + object: *client + expectLogMessages: + - client: *client + ignoreExtraMessages: true + ignoreMessages: + - level: debug + component: topology + data: + message: "Topology description changed" + - level: debug + component: topology + data: + message: "Stopped topology monitoring" + - level: debug + component: topology + data: + message: "Stopped server monitoring" + - level: debug + component: topology + data: + message: "Topology description changed" + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Starting topology monitoring" + - level: debug + component: topology + data: + message: "Server heartbeat failed" + messages: + - level: debug + component: topology + data: + message: "Server heartbeat started" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + reply: + $$matchAsDocument: + "$$matchAsRoot": + ok: 1 + - description: Failing heartbeat + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeLogMessages: + topology: debug + observeEvents: + - serverHeartbeatFailedEvent + uriOptions: + appname: failingHeartbeatLoggingTest + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: "alwaysOn" + data: + failCommands: + - hello + - isMaster + appName: failingHeartbeatLoggingTest + closeConnection: true + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverHeartbeatFailedEvent: {} + count: 1 + expectLogMessages: + - client: *client + ignoreExtraMessages: true + ignoreMessages: + - level: debug + component: topology + data: + message: "Topology description changed" + - level: debug + component: topology + data: + message: "Stopped topology monitoring" + - level: debug + component: topology + data: + message: "Stopped server monitoring" + - level: debug + component: topology + data: + message: "Topology description changed" + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Starting topology monitoring" + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + messages: + - level: debug + component: topology + data: + message: "Server heartbeat failed" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + failure: { $$exists: true } \ No newline at end of file diff --git a/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.json b/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.json index 0234ac9929..7e294baf66 100644 --- a/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.json @@ -1,6 +1,6 @@ { "description": "minPoolSize-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.9", diff --git a/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.yml b/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.yml index cc72af578b..7d76174694 100644 --- a/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.yml @@ -1,7 +1,7 @@ --- description: minPoolSize-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.json b/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.json index 9a7dfd901c..b7f6924f2b 100644 --- a/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.json +++ b/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.json @@ -1,6 +1,6 @@ { "description": "pool-cleared-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.9", diff --git a/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.yml b/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.yml index 07bfc0c0d5..7a98e2b324 100644 --- a/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.yml +++ b/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.yml @@ -1,7 +1,7 @@ --- description: pool-cleared-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # This test requires retryable writes, failCommand appName, and diff --git a/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json b/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json index c7c2494857..3147a07a1e 100644 --- a/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json +++ b/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json @@ -1,6 +1,6 @@ { "description": "rediscover-quickly-after-step-down", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml b/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml index e5b49de35d..f3e7509160 100644 --- a/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml +++ b/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml @@ -1,7 +1,7 @@ --- description: rediscover-quickly-after-step-down -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # 4.4 is required for streaming. From 79d23edcf2a498eb6d04e790c9addb880466bc43 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Mon, 4 Dec 2023 18:08:06 -0500 Subject: [PATCH 02/22] Basic changes finished --- src/mongo_logger.ts | 93 ++++++++++++++++++++++++++++++++++-- src/mongo_types.ts | 2 +- src/sdam/events.ts | 111 +++++++++++++++++++++++++++++++++---------- src/sdam/monitor.ts | 4 +- src/sdam/topology.ts | 14 +++--- 5 files changed, 183 insertions(+), 41 deletions(-) diff --git a/src/mongo_logger.ts b/src/mongo_logger.ts index 27560ac0d6..b9780b66e0 100644 --- a/src/mongo_logger.ts +++ b/src/mongo_logger.ts @@ -35,8 +35,26 @@ import { CONNECTION_POOL_CLOSED, CONNECTION_POOL_CREATED, CONNECTION_POOL_READY, - CONNECTION_READY + CONNECTION_READY, + SERVER_CLOSED, + SERVER_HEARTBEAT_FAILED, + SERVER_HEARTBEAT_STARTED, + SERVER_HEARTBEAT_SUCCEEDED, + SERVER_OPENING, + TOPOLOGY_CLOSED, + TOPOLOGY_DESCRIPTION_CHANGED, + TOPOLOGY_OPENING } from './constants'; +import type { + ServerClosedEvent, + ServerDescriptionChangedEvent, + ServerHeartbeatFailedEvent, + ServerHeartbeatStartedEvent, + ServerOpeningEvent, + TopologyClosedEvent, + TopologyDescriptionChangedEvent, + TopologyOpeningEvent +} from './sdam/events'; import { HostAddress, parseUnsignedInteger } from './utils'; /** @internal */ @@ -285,7 +303,15 @@ export type LoggableEvent = | ConnectionCheckedInEvent | ConnectionCheckedOutEvent | ConnectionCheckOutStartedEvent - | ConnectionCheckOutFailedEvent; + | ConnectionCheckOutFailedEvent + | ServerClosedEvent + | ServerDescriptionChangedEvent + | ServerHeartbeatFailedEvent + | ServerHeartbeatStartedEvent + | ServerOpeningEvent + | TopologyClosedEvent + | TopologyDescriptionChangedEvent + | TopologyOpeningEvent; /** @internal */ export interface LogConvertible extends Record { @@ -338,6 +364,32 @@ function attachConnectionFields( return log; } +function attachSDAMFields( + log: Record, + sdamEvent: + | ServerClosedEvent + | ServerDescriptionChangedEvent + | ServerHeartbeatFailedEvent + | ServerHeartbeatStartedEvent + | ServerOpeningEvent + | TopologyClosedEvent + | TopologyDescriptionChangedEvent + | TopologyOpeningEvent +) { + log.topologyId = sdamEvent.topologyId; + if (sdamEvent?.address) { + const { host, port } = HostAddress.fromString(sdamEvent.address).toHostPort(); + log.serverHost = host; + log.serverPort = port; + } + log.driverConnectionId = sdamEvent?.connectionId; + log.awaited = sdamEvent?.awaited; + log.durationMS = sdamEvent?.durationMS; + log.reply = sdamEvent?.reply; + log.failure = sdamEvent?.failure; + return log; +} + function defaultLogTransform( logObject: LoggableEvent | Record, maxDocumentLength: number = DEFAULT_MAX_DOCUMENT_LENGTH @@ -454,16 +506,47 @@ function defaultLogTransform( } return log; case CONNECTION_CHECKED_OUT: - log = attachConnectionFields(log, logObject); + log = attachSDAMFields(log, logObject); log.message = 'Connection checked out'; - log.driverConnectionId = logObject.connectionId; return log; case CONNECTION_CHECKED_IN: - log = attachConnectionFields(log, logObject); + log = attachSDAMFields(log, logObject); log.message = 'Connection checked in'; log.driverConnectionId = logObject.connectionId; return log; + case SERVER_CLOSED: + log = attachSDAMFields(log, logObject); + log.message = 'Stopped server monitoring'; + return log; + case SERVER_HEARTBEAT_FAILED: + log = attachSDAMFields(log, logObject); + log.message = 'Server hearbeat failed'; + return log; + case SERVER_HEARTBEAT_STARTED: + log = attachSDAMFields(log, logObject); + log.message = 'Server heartbeat started'; + return log; + case SERVER_HEARTBEAT_SUCCEEDED: + log = attachSDAMFields(log, logObject); + log.message = 'Server heartbeat succeeded'; + return log; + case SERVER_OPENING: + log = attachSDAMFields(log, logObject); + log.message = 'Started server momitoring'; + return log; + case TOPOLOGY_CLOSED: + log = attachSDAMFields(log, logObject); + log.message = 'Stopped topology monitoring'; + return log; + case TOPOLOGY_DESCRIPTION_CHANGED: + log = attachSDAMFields(log, logObject); + log.message = 'Topology description changed'; + return log; + case TOPOLOGY_OPENING: + log = attachSDAMFields(log, logObject); + log.message = 'Started topology momitoring'; + return log; default: for (const [key, value] of Object.entries(logObject)) { if (value != null) log[key] = value; diff --git a/src/mongo_types.ts b/src/mongo_types.ts index adfec0af67..c149101b5e 100644 --- a/src/mongo_types.ts +++ b/src/mongo_types.ts @@ -405,7 +405,7 @@ export class TypedEventEmitter extends EventEm /** @internal */ protected component?: MongoLoggableComponent; /** @internal */ - protected emitAndLog( + emitAndLog( event: EventKey | symbol, ...args: Parameters ): void { diff --git a/src/sdam/events.ts b/src/sdam/events.ts index 4c8a1c1312..2e79e290bb 100644 --- a/src/sdam/events.ts +++ b/src/sdam/events.ts @@ -1,7 +1,44 @@ import type { Document } from '../bson'; +import { + SERVER_CLOSED, + SERVER_DESCRIPTION_CHANGED, + SERVER_HEARTBEAT_FAILED, + SERVER_HEARTBEAT_STARTED, + SERVER_HEARTBEAT_SUCCEEDED, + SERVER_OPENING, + TOPOLOGY_CLOSED, + TOPOLOGY_DESCRIPTION_CHANGED, + TOPOLOGY_OPENING +} from '../constants'; import type { ServerDescription } from './server_description'; import type { TopologyDescription } from './topology_description'; +/** + * The base export class for all monitoring events published from the connection pool + * @public + * @category Event + */ +export abstract class ServerDiscoveryAndMonitoringEvent { + /** A unique identifier for the topology */ + topologyId: number; + + /** @internal */ + abstract name: + | typeof SERVER_HEARTBEAT_FAILED + | typeof SERVER_HEARTBEAT_STARTED + | typeof SERVER_HEARTBEAT_SUCCEEDED + | typeof SERVER_OPENING + | typeof TOPOLOGY_CLOSED + | typeof TOPOLOGY_DESCRIPTION_CHANGED + | typeof TOPOLOGY_OPENING + | typeof SERVER_CLOSED; + + /** @internal */ + constructor(topologyId: number) { + this.topologyId = topologyId; + } +} + /** * Emitted when server description changes, but does NOT include changes to the RTT. * @public @@ -16,6 +53,7 @@ export class ServerDescriptionChangedEvent { previousDescription: ServerDescription; /** The new server description */ newDescription: ServerDescription; + name = SERVER_DESCRIPTION_CHANGED; /** @internal */ constructor( @@ -36,15 +74,15 @@ export class ServerDescriptionChangedEvent { * @public * @category Event */ -export class ServerOpeningEvent { - /** A unique identifier for the topology */ - topologyId: number; +export class ServerOpeningEvent extends ServerDiscoveryAndMonitoringEvent { /** The address (host/port pair) of the server */ address: string; + /** @internal */ + name = SERVER_OPENING; /** @internal */ constructor(topologyId: number, address: string) { - this.topologyId = topologyId; + super(topologyId); this.address = address; } } @@ -54,15 +92,15 @@ export class ServerOpeningEvent { * @public * @category Event */ -export class ServerClosedEvent { - /** A unique identifier for the topology */ - topologyId: number; +export class ServerClosedEvent extends ServerDiscoveryAndMonitoringEvent { /** The address (host/port pair) of the server */ address: string; + /** @internal */ + name = SERVER_CLOSED; /** @internal */ constructor(topologyId: number, address: string) { - this.topologyId = topologyId; + super(topologyId); this.address = address; } } @@ -72,13 +110,13 @@ export class ServerClosedEvent { * @public * @category Event */ -export class TopologyDescriptionChangedEvent { - /** A unique identifier for the topology */ - topologyId: number; +export class TopologyDescriptionChangedEvent extends ServerDiscoveryAndMonitoringEvent { /** The old topology description */ previousDescription: TopologyDescription; /** The new topology description */ newDescription: TopologyDescription; + /** @internal */ + name = TOPOLOGY_DESCRIPTION_CHANGED; /** @internal */ constructor( @@ -86,7 +124,7 @@ export class TopologyDescriptionChangedEvent { previousDescription: TopologyDescription, newDescription: TopologyDescription ) { - this.topologyId = topologyId; + super(topologyId); this.previousDescription = previousDescription; this.newDescription = newDescription; } @@ -97,13 +135,13 @@ export class TopologyDescriptionChangedEvent { * @public * @category Event */ -export class TopologyOpeningEvent { - /** A unique identifier for the topology */ - topologyId: number; +export class TopologyOpeningEvent extends ServerDiscoveryAndMonitoringEvent { + /** @internal */ + name = TOPOLOGY_OPENING; /** @internal */ constructor(topologyId: number) { - this.topologyId = topologyId; + super(topologyId); } } @@ -112,13 +150,13 @@ export class TopologyOpeningEvent { * @public * @category Event */ -export class TopologyClosedEvent { - /** A unique identifier for the topology */ - topologyId: number; +export class TopologyClosedEvent extends ServerDiscoveryAndMonitoringEvent { + /** @internal */ + name = TOPOLOGY_CLOSED; /** @internal */ constructor(topologyId: number) { - this.topologyId = topologyId; + super(topologyId); } } @@ -129,14 +167,17 @@ export class TopologyClosedEvent { * @public * @category Event */ -export class ServerHeartbeatStartedEvent { +export class ServerHeartbeatStartedEvent extends ServerDiscoveryAndMonitoringEvent { /** The connection id for the command */ connectionId: string; /** Is true when using the streaming protocol. */ awaited: boolean; + /** @internal */ + name = SERVER_HEARTBEAT_STARTED; /** @internal */ - constructor(connectionId: string, awaited: boolean) { + constructor(connectionId: string, awaited: boolean, topologyId: number) { + super(topologyId); this.connectionId = connectionId; this.awaited = awaited; } @@ -147,7 +188,7 @@ export class ServerHeartbeatStartedEvent { * @public * @category Event */ -export class ServerHeartbeatSucceededEvent { +export class ServerHeartbeatSucceededEvent extends ServerDiscoveryAndMonitoringEvent { /** The connection id for the command */ connectionId: string; /** The execution time of the event in ms */ @@ -156,9 +197,18 @@ export class ServerHeartbeatSucceededEvent { reply: Document; /** Is true when using the streaming protocol. */ awaited: boolean; + /** @internal */ + name = SERVER_HEARTBEAT_SUCCEEDED; /** @internal */ - constructor(connectionId: string, duration: number, reply: Document | null, awaited: boolean) { + constructor( + connectionId: string, + duration: number, + reply: Document | null, + awaited: boolean, + topologyId: number + ) { + super(topologyId); this.connectionId = connectionId; this.duration = duration; this.reply = reply ?? {}; @@ -171,7 +221,7 @@ export class ServerHeartbeatSucceededEvent { * @public * @category Event */ -export class ServerHeartbeatFailedEvent { +export class ServerHeartbeatFailedEvent extends ServerDiscoveryAndMonitoringEvent { /** The connection id for the command */ connectionId: string; /** The execution time of the event in ms */ @@ -180,9 +230,18 @@ export class ServerHeartbeatFailedEvent { failure: Error; /** Is true when using the streaming protocol. */ awaited: boolean; + /** @internal */ + name = SERVER_HEARTBEAT_FAILED; /** @internal */ - constructor(connectionId: string, duration: number, failure: Error, awaited: boolean) { + constructor( + connectionId: string, + duration: number, + failure: Error, + awaited: boolean, + topologyId: number + ) { + super(topologyId); this.connectionId = connectionId; this.duration = duration; this.failure = failure; diff --git a/src/sdam/monitor.ts b/src/sdam/monitor.ts index 137eae78e5..d83739b9e0 100644 --- a/src/sdam/monitor.ts +++ b/src/sdam/monitor.ts @@ -238,7 +238,7 @@ function checkServer(monitor: Monitor, callback: Callback) { let awaited: boolean; const topologyVersion = monitor[kServer].description.topologyVersion; const isAwaitable = useStreamingProtocol(monitor, topologyVersion); - monitor.emit( + monitor.emitAndLog( Server.SERVER_HEARTBEAT_STARTED, new ServerHeartbeatStartedEvent(monitor.address, isAwaitable) ); @@ -247,7 +247,7 @@ function checkServer(monitor: Monitor, callback: Callback) { monitor.connection?.destroy({ force: true }); monitor.connection = null; - monitor.emit( + monitor.emitAndLog( Server.SERVER_HEARTBEAT_FAILED, new ServerHeartbeatFailedEvent(monitor.address, calculateDurationInMs(start), err, awaited) ); diff --git a/src/sdam/topology.ts b/src/sdam/topology.ts index 3a73dac70d..bd2997bc84 100644 --- a/src/sdam/topology.ts +++ b/src/sdam/topology.ts @@ -361,7 +361,7 @@ export class Topology extends TypedEventEmitter { updateServers(this); - this.emit( + this.emitAndLog( Topology.TOPOLOGY_DESCRIPTION_CHANGED, new TopologyDescriptionChangedEvent( this.s.id, @@ -407,10 +407,10 @@ export class Topology extends TypedEventEmitter { stateTransition(this, STATE_CONNECTING); // emit SDAM monitoring events - this.emit(Topology.TOPOLOGY_OPENING, new TopologyOpeningEvent(this.s.id)); + this.emitAndLog(Topology.TOPOLOGY_OPENING, new TopologyOpeningEvent(this.s.id)); // emit an event for the topology change - this.emit( + this.emitAndLog( Topology.TOPOLOGY_DESCRIPTION_CHANGED, new TopologyDescriptionChangedEvent( this.s.id, @@ -507,7 +507,7 @@ export class Topology extends TypedEventEmitter { stateTransition(this, STATE_CLOSED); // emit an event for close - this.emit(Topology.TOPOLOGY_CLOSED, new TopologyClosedEvent(this.s.id)); + this.emitAndLog(Topology.TOPOLOGY_CLOSED, new TopologyClosedEvent(this.s.id)); }) .finally(() => callback?.()); } @@ -652,7 +652,7 @@ export class Topology extends TypedEventEmitter { } if (!equalDescriptions) { - this.emit( + this.emitAndLog( Topology.TOPOLOGY_DESCRIPTION_CHANGED, new TopologyDescriptionChangedEvent( this.s.id, @@ -724,7 +724,7 @@ function destroyServer( } server.destroy(options, () => { - topology.emit( + topology.emitAndLog( Topology.SERVER_CLOSED, new ServerClosedEvent(topology.s.id, server.description.address) ); @@ -762,7 +762,7 @@ function topologyTypeFromOptions(options?: TopologyOptions) { * @param serverDescription - The description for the server to initialize and connect to */ function createAndConnectServer(topology: Topology, serverDescription: ServerDescription) { - topology.emit( + topology.emitAndLog( Topology.SERVER_OPENING, new ServerOpeningEvent(topology.s.id, serverDescription.address) ); From 5a5f61250faff7864e205510a5666ed9a0347144 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Mon, 4 Dec 2023 18:57:46 -0500 Subject: [PATCH 03/22] Linting errors gone --- src/constants.ts | 9 ++++++ src/index.ts | 12 +++++++- src/mongo_logger.ts | 70 ++++++++++++++++++++++++--------------------- src/sdam/events.ts | 19 ++++++------ src/sdam/monitor.ts | 13 +++++++-- 5 files changed, 77 insertions(+), 46 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index e3da4efaae..fab65bee21 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -17,11 +17,17 @@ export const MESSAGE = 'message' as const; export const PINNED = 'pinned' as const; export const UNPINNED = 'unpinned' as const; export const DESCRIPTION_RECEIVED = 'descriptionReceived'; +/** @internal */ export const SERVER_OPENING = 'serverOpening' as const; +/** @internal */ export const SERVER_CLOSED = 'serverClosed' as const; +/** @internal */ export const SERVER_DESCRIPTION_CHANGED = 'serverDescriptionChanged' as const; +/** @internal */ export const TOPOLOGY_OPENING = 'topologyOpening' as const; +/** @internal */ export const TOPOLOGY_CLOSED = 'topologyClosed' as const; +/** @internal */ export const TOPOLOGY_DESCRIPTION_CHANGED = 'topologyDescriptionChanged' as const; /** @internal */ export const CONNECTION_POOL_CREATED = 'connectionPoolCreated' as const; @@ -49,8 +55,11 @@ export const CLUSTER_TIME_RECEIVED = 'clusterTimeReceived' as const; export const COMMAND_STARTED = 'commandStarted' as const; export const COMMAND_SUCCEEDED = 'commandSucceeded' as const; export const COMMAND_FAILED = 'commandFailed' as const; +/** @internal */ export const SERVER_HEARTBEAT_STARTED = 'serverHeartbeatStarted' as const; +/** @internal */ export const SERVER_HEARTBEAT_SUCCEEDED = 'serverHeartbeatSucceeded' as const; +/** @internal */ export const SERVER_HEARTBEAT_FAILED = 'serverHeartbeatFailed' as const; export const RESPONSE = 'response' as const; export const MORE = 'more' as const; diff --git a/src/index.ts b/src/index.ts index 0fa133483e..1b1566d9f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -139,6 +139,7 @@ export { export { ServerClosedEvent, ServerDescriptionChangedEvent, + ServerDiscoveryAndMonitoringEvent, ServerHeartbeatFailedEvent, ServerHeartbeatStartedEvent, ServerHeartbeatSucceededEvent, @@ -305,7 +306,16 @@ export type { CONNECTION_POOL_CREATED, CONNECTION_POOL_READY, CONNECTION_READY, - MONGO_CLIENT_EVENTS + MONGO_CLIENT_EVENTS, + SERVER_CLOSED, + SERVER_DESCRIPTION_CHANGED, + SERVER_HEARTBEAT_FAILED, + SERVER_HEARTBEAT_STARTED, + SERVER_HEARTBEAT_SUCCEEDED, + SERVER_OPENING, + TOPOLOGY_CLOSED, + TOPOLOGY_DESCRIPTION_CHANGED, + TOPOLOGY_OPENING } from './constants'; export type { AbstractCursorEvents, diff --git a/src/mongo_logger.ts b/src/mongo_logger.ts index b9780b66e0..9056ce4da9 100644 --- a/src/mongo_logger.ts +++ b/src/mongo_logger.ts @@ -48,8 +48,10 @@ import { import type { ServerClosedEvent, ServerDescriptionChangedEvent, + ServerDiscoveryAndMonitoringEvent, ServerHeartbeatFailedEvent, ServerHeartbeatStartedEvent, + ServerHeartbeatSucceededEvent, ServerOpeningEvent, TopologyClosedEvent, TopologyDescriptionChangedEvent, @@ -308,6 +310,7 @@ export type LoggableEvent = | ServerDescriptionChangedEvent | ServerHeartbeatFailedEvent | ServerHeartbeatStartedEvent + | ServerHeartbeatSucceededEvent | ServerOpeningEvent | TopologyClosedEvent | TopologyDescriptionChangedEvent @@ -355,7 +358,7 @@ function attachCommandFields( function attachConnectionFields( log: Record, - connectionPoolEvent: ConnectionPoolMonitoringEvent + connectionPoolEvent: ConnectionPoolMonitoringEvent | ServerOpeningEvent | ServerClosedEvent ) { const { host, port } = HostAddress.fromString(connectionPoolEvent.address).toHostPort(); log.serverHost = host; @@ -364,29 +367,21 @@ function attachConnectionFields( return log; } -function attachSDAMFields( +function attachSDAMFields(log: Record, sdamEvent: ServerDiscoveryAndMonitoringEvent) { + log.topologyId = sdamEvent.topologyId; + return log; +} + +function attachServerHeartbeatFields( log: Record, - sdamEvent: - | ServerClosedEvent - | ServerDescriptionChangedEvent + serverHeartbeatEvent: | ServerHeartbeatFailedEvent | ServerHeartbeatStartedEvent - | ServerOpeningEvent - | TopologyClosedEvent - | TopologyDescriptionChangedEvent - | TopologyOpeningEvent + | ServerHeartbeatSucceededEvent ) { - log.topologyId = sdamEvent.topologyId; - if (sdamEvent?.address) { - const { host, port } = HostAddress.fromString(sdamEvent.address).toHostPort(); - log.serverHost = host; - log.serverPort = port; - } - log.driverConnectionId = sdamEvent?.connectionId; - log.awaited = sdamEvent?.awaited; - log.durationMS = sdamEvent?.durationMS; - log.reply = sdamEvent?.reply; - log.failure = sdamEvent?.failure; + const { awaited, connectionId } = serverHeartbeatEvent; + log.awaited = awaited; + log.driverConnectionId = connectionId; return log; } @@ -506,34 +501,47 @@ function defaultLogTransform( } return log; case CONNECTION_CHECKED_OUT: - log = attachSDAMFields(log, logObject); + log = attachConnectionFields(log, logObject); log.message = 'Connection checked out'; log.driverConnectionId = logObject.connectionId; return log; case CONNECTION_CHECKED_IN: - log = attachSDAMFields(log, logObject); + log = attachConnectionFields(log, logObject); log.message = 'Connection checked in'; log.driverConnectionId = logObject.connectionId; return log; - case SERVER_CLOSED: + case SERVER_OPENING: log = attachSDAMFields(log, logObject); - log.message = 'Stopped server monitoring'; + log = attachConnectionFields(log, logObject); + log.message = 'Started server momitoring'; return log; - case SERVER_HEARTBEAT_FAILED: + case SERVER_CLOSED: log = attachSDAMFields(log, logObject); - log.message = 'Server hearbeat failed'; + log = attachConnectionFields(log, logObject); + log.message = 'Stopped server monitoring'; return log; case SERVER_HEARTBEAT_STARTED: log = attachSDAMFields(log, logObject); + log = attachServerHeartbeatFields(log, logObject); log.message = 'Server heartbeat started'; return log; case SERVER_HEARTBEAT_SUCCEEDED: log = attachSDAMFields(log, logObject); + log = attachServerHeartbeatFields(log, logObject); log.message = 'Server heartbeat succeeded'; + log.durationMS = logObject.duration; + log.reply = logObject.reply.toString(); return log; - case SERVER_OPENING: + case SERVER_HEARTBEAT_FAILED: log = attachSDAMFields(log, logObject); - log.message = 'Started server momitoring'; + log = attachServerHeartbeatFields(log, logObject); + log.message = 'Server hearbeat failed'; + log.durationMS = logObject.duration; + log.failure = logObject.failure; + return log; + case TOPOLOGY_OPENING: + log = attachSDAMFields(log, logObject); + log.message = 'Started topology momitoring'; return log; case TOPOLOGY_CLOSED: log = attachSDAMFields(log, logObject); @@ -542,10 +550,8 @@ function defaultLogTransform( case TOPOLOGY_DESCRIPTION_CHANGED: log = attachSDAMFields(log, logObject); log.message = 'Topology description changed'; - return log; - case TOPOLOGY_OPENING: - log = attachSDAMFields(log, logObject); - log.message = 'Started topology momitoring'; + log.previousDescription = logObject.previousDescription.toString(); + log.newDescription = logObject.newDescription.toString(); return log; default: for (const [key, value] of Object.entries(logObject)) { diff --git a/src/sdam/events.ts b/src/sdam/events.ts index 2e79e290bb..f73776f234 100644 --- a/src/sdam/events.ts +++ b/src/sdam/events.ts @@ -14,7 +14,7 @@ import type { ServerDescription } from './server_description'; import type { TopologyDescription } from './topology_description'; /** - * The base export class for all monitoring events published from the connection pool + * The base export class for all monitoring events published from server discovery and monitoring. * @public * @category Event */ @@ -24,14 +24,15 @@ export abstract class ServerDiscoveryAndMonitoringEvent { /** @internal */ abstract name: - | typeof SERVER_HEARTBEAT_FAILED - | typeof SERVER_HEARTBEAT_STARTED - | typeof SERVER_HEARTBEAT_SUCCEEDED - | typeof SERVER_OPENING | typeof TOPOLOGY_CLOSED | typeof TOPOLOGY_DESCRIPTION_CHANGED | typeof TOPOLOGY_OPENING - | typeof SERVER_CLOSED; + | typeof SERVER_OPENING + | typeof SERVER_CLOSED + | typeof SERVER_DESCRIPTION_CHANGED + | typeof SERVER_HEARTBEAT_FAILED + | typeof SERVER_HEARTBEAT_STARTED + | typeof SERVER_HEARTBEAT_SUCCEEDED; /** @internal */ constructor(topologyId: number) { @@ -44,9 +45,7 @@ export abstract class ServerDiscoveryAndMonitoringEvent { * @public * @category Event */ -export class ServerDescriptionChangedEvent { - /** A unique identifier for the topology */ - topologyId: number; +export class ServerDescriptionChangedEvent extends ServerDiscoveryAndMonitoringEvent { /** The address (host/port pair) of the server */ address: string; /** The previous server description */ @@ -62,7 +61,7 @@ export class ServerDescriptionChangedEvent { previousDescription: ServerDescription, newDescription: ServerDescription ) { - this.topologyId = topologyId; + super(topologyId); this.address = address; this.previousDescription = previousDescription; this.newDescription = newDescription; diff --git a/src/sdam/monitor.ts b/src/sdam/monitor.ts index d83739b9e0..fcbeed90e3 100644 --- a/src/sdam/monitor.ts +++ b/src/sdam/monitor.ts @@ -240,7 +240,7 @@ function checkServer(monitor: Monitor, callback: Callback) { const isAwaitable = useStreamingProtocol(monitor, topologyVersion); monitor.emitAndLog( Server.SERVER_HEARTBEAT_STARTED, - new ServerHeartbeatStartedEvent(monitor.address, isAwaitable) + new ServerHeartbeatStartedEvent(monitor.address, isAwaitable, monitor[kServer].topology.s.id) ); function onHeartbeatFailed(err: Error) { @@ -249,7 +249,13 @@ function checkServer(monitor: Monitor, callback: Callback) { monitor.emitAndLog( Server.SERVER_HEARTBEAT_FAILED, - new ServerHeartbeatFailedEvent(monitor.address, calculateDurationInMs(start), err, awaited) + new ServerHeartbeatFailedEvent( + monitor.address, + calculateDurationInMs(start), + err, + awaited, + monitor[kServer].topology.s.id + ) ); const error = !(err instanceof MongoError) @@ -369,7 +375,8 @@ function checkServer(monitor: Monitor, callback: Callback) { monitor.address, calculateDurationInMs(start), conn.hello, - useStreamingProtocol(monitor, conn.hello?.topologyVersion) + useStreamingProtocol(monitor, conn.hello?.topologyVersion), + monitor[kServer].topology.s.id ) ); From 1020dfaf6ab367d4bfcf4c19bad8cc12b6031ee1 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Tue, 5 Dec 2023 10:46:27 -0500 Subject: [PATCH 04/22] spec runner changes working, may need to add filter to logs --- src/mongo_logger.ts | 4 +- src/sdam/monitor.ts | 9 +- src/sdam/server.ts | 2 +- src/sdam/topology.ts | 3 + .../unified/auth-error.json | 230 ------- .../unified/auth-error.yml | 130 ---- .../unified/auth-misc-command-error.json | 230 ------- .../unified/auth-misc-command-error.yml | 132 ---- .../unified/auth-network-error.json | 230 ------- .../unified/auth-network-error.yml | 132 ---- .../unified/auth-network-timeout-error.json | 233 ------- .../unified/auth-network-timeout-error.yml | 138 ---- .../unified/auth-shutdown-error.json | 230 ------- .../unified/auth-shutdown-error.yml | 133 ---- .../unified/cancel-server-check.json | 201 ------ .../unified/cancel-server-check.yml | 143 ----- .../unified/connectTimeoutMS.json | 221 ------- .../unified/connectTimeoutMS.yml | 130 ---- .../unified/find-network-error.json | 234 ------- .../unified/find-network-error.yml | 135 ---- .../unified/find-network-timeout-error.json | 199 ------ .../unified/find-network-timeout-error.yml | 119 ---- .../unified/find-shutdown-error.json | 251 -------- .../unified/find-shutdown-error.yml | 163 ----- .../unified/hello-command-error.json | 376 ----------- .../unified/hello-command-error.yml | 233 ------- .../unified/hello-network-error.json | 346 ---------- .../unified/hello-network-error.yml | 227 ------- .../unified/hello-timeout.json | 514 --------------- .../unified/hello-timeout.yml | 318 --------- .../unified/insert-network-error.json | 246 ------- .../unified/insert-network-error.yml | 137 ---- .../unified/insert-shutdown-error.json | 250 -------- .../unified/insert-shutdown-error.yml | 162 ----- .../unified/interruptInUse-pool-clear.json | 591 ----------------- .../unified/interruptInUse-pool-clear.yml | 341 ---------- .../unified/logging-loadbalanced.json | 150 ----- .../unified/logging-loadbalanced.yml | 74 --- .../unified/logging-replicaset.json | 606 ------------------ .../unified/logging-replicaset.yml | 289 --------- .../unified/logging-sharded.json | 492 -------------- .../unified/logging-sharded.yml | 248 ------- .../unified/minPoolSize-error.json | 177 ----- .../unified/minPoolSize-error.yml | 125 ---- .../unified/pool-cleared-error.json | 373 ----------- .../unified/pool-cleared-error.yml | 239 ------- .../rediscover-quickly-after-step-down.json | 242 ------- .../rediscover-quickly-after-step-down.yml | 144 ----- .../unified/serverMonitoringMode.json | 449 ------------- .../unified/serverMonitoringMode.yml | 173 ----- test/tools/unified-spec-runner/entities.ts | 32 +- test/tools/unified-spec-runner/match.ts | 42 +- test/tools/unified-spec-runner/schema.ts | 34 +- 53 files changed, 114 insertions(+), 11148 deletions(-) delete mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-network-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-network-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/cancel-server-check.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/cancel-server-check.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/find-network-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/find-network-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/hello-command-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/hello-command-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/hello-network-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/hello-network-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/hello-timeout.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/hello-timeout.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/insert-network-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/insert-network-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-sharded.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml delete mode 100644 test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.yml diff --git a/src/mongo_logger.ts b/src/mongo_logger.ts index 9056ce4da9..66e82268f1 100644 --- a/src/mongo_logger.ts +++ b/src/mongo_logger.ts @@ -513,7 +513,7 @@ function defaultLogTransform( case SERVER_OPENING: log = attachSDAMFields(log, logObject); log = attachConnectionFields(log, logObject); - log.message = 'Started server momitoring'; + log.message = 'Started server monitoring'; return log; case SERVER_CLOSED: log = attachSDAMFields(log, logObject); @@ -541,7 +541,7 @@ function defaultLogTransform( return log; case TOPOLOGY_OPENING: log = attachSDAMFields(log, logObject); - log.message = 'Started topology momitoring'; + log.message = 'Started topology monitoring'; return log; case TOPOLOGY_CLOSED: log = attachSDAMFields(log, logObject); diff --git a/src/sdam/monitor.ts b/src/sdam/monitor.ts index fcbeed90e3..890347d49e 100644 --- a/src/sdam/monitor.ts +++ b/src/sdam/monitor.ts @@ -17,6 +17,7 @@ import { } from './events'; import { Server } from './server'; import type { TopologyVersion } from './server_description'; +import { MongoLogger } from '../mongo_logger'; /** @internal */ const kServer = Symbol('server'); @@ -98,6 +99,10 @@ export class Monitor extends TypedEventEmitter { [kMonitorId]?: MonitorInterval; rttPinger?: RTTPinger; + get connection(): Connection | undefined { + return this[kConnection]; + } + constructor(server: Server, options: MonitorOptions) { super(); @@ -109,7 +114,6 @@ export class Monitor extends TypedEventEmitter { this.s = { state: STATE_CLOSED }; - this.address = server.description.address; this.options = Object.freeze({ connectTimeoutMS: options.connectTimeoutMS ?? 10000, @@ -144,6 +148,9 @@ export class Monitor extends TypedEventEmitter { } this.connectOptions = Object.freeze(connectOptions); + + this.mongoLogger = mongoLogger; + this.component = 'topology'; } connect(): void { diff --git a/src/sdam/server.ts b/src/sdam/server.ts index 04139c991f..412ed294d4 100644 --- a/src/sdam/server.ts +++ b/src/sdam/server.ts @@ -178,7 +178,7 @@ export class Server extends TypedEventEmitter { } // create the monitor - this.monitor = new Monitor(this, this.s.options); + this.monitor = new Monitor(this, this.s.options, this.topology.mongoLogger); for (const event of HEARTBEAT_EVENTS) { this.monitor.on(event, (e: any) => this.emit(event, e)); diff --git a/src/sdam/topology.ts b/src/sdam/topology.ts index bd2997bc84..206b731f0d 100644 --- a/src/sdam/topology.ts +++ b/src/sdam/topology.ts @@ -319,6 +319,9 @@ export class Topology extends TypedEventEmitter { detectSrvRecords: ev => this.detectSrvRecords(ev) }; + this.mongoLogger = client.mongoLogger; + this.component = 'topology'; + if (options.srvHost && !options.loadBalanced) { this.s.srvPoller = options.srvPoller ?? diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-error.json deleted file mode 100644 index 62d26494c7..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/auth-error.json +++ /dev/null @@ -1,230 +0,0 @@ -{ - "description": "auth-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4", - "auth": true, - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "auth-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ], - "tests": [ - { - "description": "Reset server and pool after AuthenticationFailure error", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "saslContinue" - ], - "appName": "authErrorTest", - "errorCode": 18 - } - } - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "appname": "authErrorTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "auth-error" - } - } - ] - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "expectError": { - "isError": true - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "auth-error", - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "auth-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-error.yml deleted file mode 100644 index febf4a46dc..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/auth-error.yml +++ /dev/null @@ -1,130 +0,0 @@ -description: auth-error - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.4" - auth: true - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName auth-error - databaseName: &databaseName sdam-tests - documents: - - _id: 1 - - _id: 2 -tests: - - description: Reset server and pool after AuthenticationFailure error - operations: - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 1 - data: - failCommands: - - saslContinue - appName: authErrorTest - errorCode: 18 - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - appname: authErrorTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - - name: insertMany - object: *collection - arguments: - documents: - - _id: 3 - - _id: 4 - expectError: - isError: true - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform another operation to ensure the node is rediscovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 5 - - _id: 6 - # Assert the server was marked Unknown and pool was cleared exactly once. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - expectEvents: - # Note: The first insert command is never attempted because connection - # checkout fails. - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: auth-error - documents: - - _id: 5 - - _id: 6 - commandName: insert - databaseName: *databaseName - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 5 - - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.json deleted file mode 100644 index fd62fe604e..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.json +++ /dev/null @@ -1,230 +0,0 @@ -{ - "description": "auth-misc-command-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4", - "auth": true, - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "auth-misc-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ], - "tests": [ - { - "description": "Reset server and pool after misc command error", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "saslContinue" - ], - "appName": "authMiscErrorTest", - "errorCode": 1 - } - } - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "appname": "authMiscErrorTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "auth-misc-error" - } - } - ] - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "expectError": { - "isError": true - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "auth-misc-error", - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "auth-misc-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.yml deleted file mode 100644 index 9969ca92d4..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.yml +++ /dev/null @@ -1,132 +0,0 @@ ---- -description: auth-misc-command-error - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.4" - auth: true - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName auth-misc-error - databaseName: &databaseName sdam-tests - documents: - - _id: 1 - - _id: 2 - -tests: - - description: Reset server and pool after misc command error - operations: - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 1 - data: - failCommands: - - saslContinue - appName: authMiscErrorTest - errorCode: 1 # InternalError - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - appname: authMiscErrorTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - - name: insertMany - object: *collection - arguments: - documents: - - _id: 3 - - _id: 4 - expectError: - isError: true - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform another operation to ensure the node is rediscovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 5 - - _id: 6 - # Assert the server was marked Unknown and pool was cleared exactly once. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - expectEvents: - # Note: The first insert command is never attempted because connection - # checkout fails. - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: auth-misc-error - documents: - - _id: 5 - - _id: 6 - commandName: insert - databaseName: *databaseName - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 5 - - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-network-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-network-error.json deleted file mode 100644 index 84763af32e..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/auth-network-error.json +++ /dev/null @@ -1,230 +0,0 @@ -{ - "description": "auth-network-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4", - "auth": true, - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "auth-network-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ], - "tests": [ - { - "description": "Reset server and pool after network error during authentication", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "saslContinue" - ], - "closeConnection": true, - "appName": "authNetworkErrorTest" - } - } - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "appname": "authNetworkErrorTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "auth-network-error" - } - } - ] - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "expectError": { - "isError": true - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "auth-network-error", - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "auth-network-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-network-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-network-error.yml deleted file mode 100644 index cdf77c56df..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/auth-network-error.yml +++ /dev/null @@ -1,132 +0,0 @@ ---- -description: auth-network-error - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.4" - auth: true - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName auth-network-error - databaseName: &databaseName sdam-tests - documents: - - _id: 1 - - _id: 2 - -tests: - - description: Reset server and pool after network error during authentication - operations: - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 1 - data: - failCommands: - - saslContinue - closeConnection: true - appName: authNetworkErrorTest - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - appname: authNetworkErrorTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - - name: insertMany - object: *collection - arguments: - documents: - - _id: 3 - - _id: 4 - expectError: - isError: true - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform another operation to ensure the node is rediscovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 5 - - _id: 6 - # Assert the server was marked Unknown and pool was cleared exactly once. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - expectEvents: - # Note: The first insert command is never attempted because connection - # checkout fails. - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: auth-network-error - documents: - - _id: 5 - - _id: 6 - commandName: insert - databaseName: *databaseName - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 5 - - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.json deleted file mode 100644 index 3cf9576eba..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.json +++ /dev/null @@ -1,233 +0,0 @@ -{ - "description": "auth-network-timeout-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4", - "auth": true, - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "auth-network-timeout-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ], - "tests": [ - { - "description": "Reset server and pool after network timeout error during authentication", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "saslContinue" - ], - "blockConnection": true, - "blockTimeMS": 500, - "appName": "authNetworkTimeoutErrorTest" - } - } - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "appname": "authNetworkTimeoutErrorTest", - "connectTimeoutMS": 250, - "socketTimeoutMS": 250 - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "auth-network-timeout-error" - } - } - ] - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "expectError": { - "isError": true - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "auth-network-timeout-error", - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "auth-network-timeout-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.yml deleted file mode 100644 index 49b91d8373..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.yml +++ /dev/null @@ -1,138 +0,0 @@ ---- -description: auth-network-timeout-error - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.4" - auth: true - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName auth-network-timeout-error - databaseName: &databaseName sdam-tests - documents: - - _id: 1 - - _id: 2 - -tests: - - description: Reset server and pool after network timeout error during authentication - operations: - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 1 - data: - failCommands: - - saslContinue - blockConnection: true - blockTimeMS: 500 - appName: authNetworkTimeoutErrorTest - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - appname: authNetworkTimeoutErrorTest - # Set a short connect/socket timeout to ensure the fail point causes the - # connection establishment to timeout. - connectTimeoutMS: 250 - socketTimeoutMS: 250 - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - - name: insertMany - object: *collection - arguments: - documents: - - _id: 3 - - _id: 4 - expectError: - isError: true - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform another operation to ensure the node is rediscovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 5 - - _id: 6 - # Assert the server was marked Unknown and pool was cleared exactly once. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - expectEvents: - # Note: The first insert command is never attempted because connection - # checkout fails. - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: auth-network-timeout-error - documents: - - _id: 5 - - _id: 6 - commandName: insert - databaseName: *databaseName - - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 5 - - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.json deleted file mode 100644 index b9e503af66..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.json +++ /dev/null @@ -1,230 +0,0 @@ -{ - "description": "auth-shutdown-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4", - "auth": true, - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "auth-shutdown-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ], - "tests": [ - { - "description": "Reset server and pool after shutdown error during authentication", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "saslContinue" - ], - "appName": "authShutdownErrorTest", - "errorCode": 91 - } - } - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "appname": "authShutdownErrorTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "auth-shutdown-error" - } - } - ] - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "expectError": { - "isError": true - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "auth-shutdown-error", - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "auth-shutdown-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.yml deleted file mode 100644 index f0bb4d17df..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.yml +++ /dev/null @@ -1,133 +0,0 @@ ---- -description: auth-shutdown-error - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.4" - auth: true - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName auth-shutdown-error - databaseName: &databaseName sdam-tests - documents: - - _id: 1 - - _id: 2 - -tests: - - description: Reset server and pool after shutdown error during authentication - operations: - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 1 - data: - failCommands: - - saslContinue - appName: authShutdownErrorTest - errorCode: 91 - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - appname: authShutdownErrorTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - - name: insertMany - object: *collection - arguments: - documents: - - _id: 3 - - _id: 4 - expectError: - isError: true - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform another operation to ensure the node is rediscovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 5 - - _id: 6 - # Assert the server was marked Unknown and pool was cleared exactly once. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - expectEvents: - # Note: The first insert command is never attempted because connection - # checkout fails. - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: auth-shutdown-error - documents: - - _id: 5 - - _id: 6 - commandName: insert - databaseName: *databaseName - - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 5 - - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.json b/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.json deleted file mode 100644 index a60ccfcb41..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.json +++ /dev/null @@ -1,201 +0,0 @@ -{ - "description": "cancel-server-check", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.0", - "topologies": [ - "replicaset" - ], - "serverless": "forbid" - }, - { - "minServerVersion": "4.2", - "topologies": [ - "sharded" - ], - "serverless": "forbid" - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "cancel-server-check", - "databaseName": "sdam-tests", - "documents": [] - } - ], - "tests": [ - { - "description": "Cancel server check", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": true, - "heartbeatFrequencyMS": 10000, - "serverSelectionTimeoutMS": 5000, - "appname": "cancelServerCheckTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "cancel-server-check" - } - } - ] - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 1 - } - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "insert" - ], - "closeConnection": true - } - }, - "client": "setupClient" - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 2 - } - }, - "expectResult": { - "insertedId": 2 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 3 - } - }, - "expectResult": { - "insertedId": 3 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - } - ], - "outcome": [ - { - "collectionName": "cancel-server-check", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.yml b/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.yml deleted file mode 100644 index af46792546..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.yml +++ /dev/null @@ -1,143 +0,0 @@ ---- -description: cancel-server-check - -schemaVersion: "1.4" - -runOnRequirements: - # General failCommand requirements (this file does not use appName - # with failCommand). - - minServerVersion: "4.0" - topologies: - - replicaset - serverless: forbid - - minServerVersion: "4.2" - topologies: - - sharded - serverless: forbid - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName cancel-server-check - databaseName: &databaseName sdam-tests - documents: [] - -tests: - - description: Cancel server check - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: true - heartbeatFrequencyMS: 10000 - # Server selection timeout MUST be less than heartbeatFrequencyMS for - # this test. This setting ensures that the retried insert will fail - # after 5 seconds if the driver does not properly cancel the in progress - # check. - serverSelectionTimeoutMS: 5000 - appname: cancelServerCheckTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # Perform an operation to ensure the node is discovered. - - name: insertOne - object: *collection - arguments: - document: - _id: 1 - # Configure the next inserts to fail with a non-timeout network error. - # This should: - # 1) Mark the server Unknown - # 2) Clear the connection pool - # 3) Cancel the in progress hello or legacy hello check and close the Monitor - # connection - # 4) The write will be then we retried, server selection will request an - # immediate check, and block for ~500ms until the next Monitor check - # proceeds. - # 5) The write will succeed on the second attempt. - - name: failPoint - object: testRunner - arguments: - failPoint: - configureFailPoint: failCommand - mode: - times: 1 - data: - failCommands: - - insert - closeConnection: true - client: *setupClient - - name: insertOne - object: *collection - arguments: - document: - _id: 2 - expectResult: - insertedId: 2 - # The first error should mark the server Unknown and then clear the pool. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform another operation to ensure the node still selectable. - - name: insertOne - object: *collection - arguments: - document: - _id: 3 - expectResult: - insertedId: 3 - # Assert the server was marked Unknown and pool was cleared exactly once. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - - # Order of operations is non-deterministic so we cannot check events. - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 3 diff --git a/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.json b/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.json deleted file mode 100644 index d3e860a9cb..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.json +++ /dev/null @@ -1,221 +0,0 @@ -{ - "description": "connectTimeoutMS", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4", - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "connectTimeoutMS", - "databaseName": "sdam-tests", - "documents": [] - } - ], - "tests": [ - { - "description": "connectTimeoutMS=0", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "connectTimeoutMS": 0, - "heartbeatFrequencyMS": 500, - "appname": "connectTimeoutMS=0" - }, - "useMultipleMongoses": false - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "connectTimeoutMS" - } - } - ] - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "connectTimeoutMS=0", - "blockConnection": true, - "blockTimeMS": 550 - } - }, - "client": "setupClient" - } - }, - { - "name": "wait", - "object": "testRunner", - "arguments": { - "ms": 750 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 0 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 0 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "connectTimeoutMS", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - }, - { - "commandStartedEvent": { - "command": { - "insert": "connectTimeoutMS", - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "connectTimeoutMS", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.yml b/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.yml deleted file mode 100644 index 7c610623eb..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.yml +++ /dev/null @@ -1,130 +0,0 @@ ---- -description: connectTimeoutMS - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.4" - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName connectTimeoutMS - databaseName: &databaseName sdam-tests - documents: [] - -tests: - - description: connectTimeoutMS=0 - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - connectTimeoutMS: 0 - heartbeatFrequencyMS: 500 - appname: connectTimeoutMS=0 - useMultipleMongoses: false - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # Perform an operation to ensure the node is discovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 1 - - _id: 2 - # Block the next streaming hello check for longer than - # heartbeatFrequencyMS to ensure that the connection timeout remains - # unlimited. - - name: failPoint - object: testRunner - arguments: - failPoint: - configureFailPoint: failCommand - mode: - times: 2 - data: - failCommands: - - hello - - isMaster - appName: connectTimeoutMS=0 - blockConnection: true - blockTimeMS: 550 - client: *setupClient - - name: wait - object: testRunner - arguments: - ms: 750 - # Perform an operation to ensure the node is still selectable. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 3 - - _id: 4 - # Assert that the server was never marked Unknown and the pool was never - # cleared. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 0 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 0 - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: connectTimeoutMS - documents: - - _id: 1 - - _id: 2 - commandName: insert - databaseName: *databaseName - - commandStartedEvent: - command: - insert: connectTimeoutMS - documents: - - _id: 3 - - _id: 4 - commandName: insert - databaseName: *databaseName - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 diff --git a/test/spec/server-discovery-and-monitoring/unified/find-network-error.json b/test/spec/server-discovery-and-monitoring/unified/find-network-error.json deleted file mode 100644 index c1b6db40ca..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/find-network-error.json +++ /dev/null @@ -1,234 +0,0 @@ -{ - "description": "find-network-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4", - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "find-network-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ], - "tests": [ - { - "description": "Reset server and pool after network error on find", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "find" - ], - "closeConnection": true, - "appName": "findNetworkErrorTest" - } - } - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "retryReads": false, - "appname": "findNetworkErrorTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "find-network-error" - } - } - ] - } - }, - { - "name": "find", - "object": "collection", - "arguments": { - "filter": { - "_id": 1 - } - }, - "expectError": { - "isError": true - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "find": "find-network-error" - }, - "commandName": "find", - "databaseName": "sdam-tests" - } - }, - { - "commandStartedEvent": { - "command": { - "insert": "find-network-error", - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "find-network-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/find-network-error.yml b/test/spec/server-discovery-and-monitoring/unified/find-network-error.yml deleted file mode 100644 index f97d799a2a..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/find-network-error.yml +++ /dev/null @@ -1,135 +0,0 @@ ---- -description: find-network-error - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.4" - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName find-network-error - databaseName: &databaseName sdam-tests - documents: - - _id: 1 - - _id: 2 - -tests: - - description: Reset server and pool after network error on find - operations: - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 1 - data: - failCommands: - - find - closeConnection: true - appName: findNetworkErrorTest - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - retryReads: false - appname: findNetworkErrorTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - - name: find - object: *collection - arguments: - filter: - _id: 1 - expectError: - isError: true - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform another operation to ensure the node is rediscovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 5 - - _id: 6 - # Assert the server was marked Unknown and pool was cleared exactly once. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - find: find-network-error - commandName: find - databaseName: *databaseName - - commandStartedEvent: - command: - insert: find-network-error - documents: - - _id: 5 - - _id: 6 - commandName: insert - databaseName: *databaseName - - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 5 - - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.json b/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.json deleted file mode 100644 index e5ac9f21aa..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.json +++ /dev/null @@ -1,199 +0,0 @@ -{ - "description": "find-network-timeout-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4", - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "find-network-timeout-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ], - "tests": [ - { - "description": "Ignore network timeout error on find", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "find" - ], - "blockConnection": true, - "blockTimeMS": 500, - "appName": "findNetworkTimeoutErrorTest" - } - } - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "retryReads": false, - "appname": "findNetworkTimeoutErrorTest", - "socketTimeoutMS": 250 - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "find-network-timeout-error" - } - } - ] - } - }, - { - "name": "find", - "object": "collection", - "arguments": { - "filter": { - "_id": 1 - } - }, - "expectError": { - "isError": true - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 3 - } - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 0 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 0 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "find": "find-network-timeout-error" - }, - "commandName": "find", - "databaseName": "sdam-tests" - } - }, - { - "commandStartedEvent": { - "command": { - "insert": "find-network-timeout-error", - "documents": [ - { - "_id": 3 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "find-network-timeout-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.yml b/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.yml deleted file mode 100644 index e00b7a2be0..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.yml +++ /dev/null @@ -1,119 +0,0 @@ ---- -description: find-network-timeout-error - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.4" - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName find-network-timeout-error - databaseName: &databaseName sdam-tests - documents: - - _id: 1 - - _id: 2 - -tests: - - description: Ignore network timeout error on find - operations: - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 1 - data: - failCommands: - - find - blockConnection: true - blockTimeMS: 500 - appName: findNetworkTimeoutErrorTest - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - retryReads: false - appname: findNetworkTimeoutErrorTest - # Set a short socket timeout to ensure the find command times out. - socketTimeoutMS: 250 - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - - name: find - object: *collection - arguments: - filter: - _id: 1 - expectError: - isError: true - # Perform another operation to ensure the node is still usable. - - name: insertOne - object: *collection - arguments: - document: - _id: 3 - # Assert the server was not marked Unknown and the pool was not cleared. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 0 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 0 - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - find: find-network-timeout-error - commandName: find - databaseName: *databaseName - - commandStartedEvent: - command: - insert: find-network-timeout-error - documents: - - _id: 3 - commandName: insert - databaseName: *databaseName - - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 3 diff --git a/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.json b/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.json deleted file mode 100644 index 6e5a2cac05..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.json +++ /dev/null @@ -1,251 +0,0 @@ -{ - "description": "find-shutdown-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4", - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "find-shutdown-error", - "databaseName": "sdam-tests", - "documents": [] - } - ], - "tests": [ - { - "description": "Concurrent shutdown error on find", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "uriOptions": { - "retryWrites": false, - "retryReads": false, - "heartbeatFrequencyMS": 500, - "appname": "shutdownErrorFindTest" - }, - "observeEvents": [ - "serverDescriptionChangedEvent", - "poolClearedEvent" - ] - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "find-shutdown-error" - } - } - ] - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 1 - } - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "find" - ], - "appName": "shutdownErrorFindTest", - "errorCode": 91, - "blockConnection": true, - "blockTimeMS": 500 - } - }, - "client": "setupClient" - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "thread": { - "id": "thread0" - } - }, - { - "thread": { - "id": "thread1" - } - } - ] - } - }, - { - "name": "runOnThread", - "object": "testRunner", - "arguments": { - "thread": "thread0", - "operation": { - "name": "find", - "object": "collection", - "arguments": { - "filter": { - "_id": 1 - } - }, - "expectError": { - "isError": true - } - } - } - }, - { - "name": "runOnThread", - "object": "testRunner", - "arguments": { - "thread": "thread1", - "operation": { - "name": "find", - "object": "collection", - "arguments": { - "filter": { - "_id": 1 - } - }, - "expectError": { - "isError": true - } - } - } - }, - { - "name": "waitForThread", - "object": "testRunner", - "arguments": { - "thread": "thread0" - } - }, - { - "name": "waitForThread", - "object": "testRunner", - "arguments": { - "thread": "thread1" - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 4 - } - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - } - ], - "outcome": [ - { - "collectionName": "find-shutdown-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 4 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.yml b/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.yml deleted file mode 100644 index 395215244b..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.yml +++ /dev/null @@ -1,163 +0,0 @@ ---- -description: find-shutdown-error - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.4" - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName find-shutdown-error - databaseName: &databaseName sdam-tests - documents: [] - -tests: - - description: Concurrent shutdown error on find - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - uriOptions: - retryWrites: false - retryReads: false - heartbeatFrequencyMS: 500 - appname: shutdownErrorFindTest - observeEvents: - - serverDescriptionChangedEvent - - poolClearedEvent - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # Perform an operation to ensure the node is discovered. - - name: insertOne - object: *collection - arguments: - document: - _id: 1 - # Configure the next two finds to fail with a non-timeout shutdown - # errors. Block the connection for 500ms to ensure both operations check - # out connections from the same pool generation. - - name: failPoint - object: testRunner - arguments: - failPoint: - configureFailPoint: failCommand - mode: - times: 2 - data: - failCommands: - - find - appName: shutdownErrorFindTest - errorCode: 91 - blockConnection: true - blockTimeMS: 500 - client: *setupClient - # Start threads. - - name: createEntities - object: testRunner - arguments: - entities: - - thread: - id: &thread0 thread0 - - thread: - id: &thread1 thread1 - # Perform concurrent find operations. Both fail with shutdown errors. - - name: runOnThread - object: testRunner - arguments: - thread: *thread0 - operation: - name: find - object: *collection - arguments: - filter: - _id: 1 - expectError: - isError: true - - name: runOnThread - object: testRunner - arguments: - thread: *thread1 - operation: - name: find - object: *collection - arguments: - filter: - _id: 1 - expectError: - isError: true - # Stop threads. - - name: waitForThread - object: testRunner - arguments: - thread: *thread0 - - name: waitForThread - object: testRunner - arguments: - thread: *thread1 - # The first shutdown error should mark the server Unknown and then clear - # the pool. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform an operation to ensure the node is rediscovered. - - name: insertOne - object: *collection - arguments: - document: - _id: 4 - # Assert the server was marked Unknown and pool was cleared exactly once. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - - # Order of operations is non-deterministic so we cannot check events. - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 4 diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-command-error.json b/test/spec/server-discovery-and-monitoring/unified/hello-command-error.json deleted file mode 100644 index 9afea87e77..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/hello-command-error.json +++ /dev/null @@ -1,376 +0,0 @@ -{ - "description": "hello-command-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.9", - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "hello-command-error", - "databaseName": "sdam-tests", - "documents": [] - } - ], - "tests": [ - { - "description": "Command error on Monitor handshake", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 4 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "commandErrorHandshakeTest", - "closeConnection": false, - "errorCode": 91 - } - } - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "serverDescriptionChangedEvent", - "poolClearedEvent", - "commandStartedEvent" - ], - "uriOptions": { - "retryWrites": false, - "connectTimeoutMS": 250, - "heartbeatFrequencyMS": 500, - "appname": "commandErrorHandshakeTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "hello-command-error" - } - } - ] - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "hello-command-error", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "hello-command-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ] - }, - { - "description": "Command error on Monitor check", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "connectTimeoutMS": 1000, - "heartbeatFrequencyMS": 500, - "appname": "commandErrorCheckTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "hello-command-error" - } - } - ] - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "commandErrorCheckTest", - "closeConnection": false, - "blockConnection": true, - "blockTimeMS": 750, - "errorCode": 91 - } - }, - "client": "setupClient" - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "hello-command-error", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - }, - { - "commandStartedEvent": { - "command": { - "insert": "hello-command-error", - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "hello-command-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-command-error.yml b/test/spec/server-discovery-and-monitoring/unified/hello-command-error.yml deleted file mode 100644 index 3b1428deb0..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/hello-command-error.yml +++ /dev/null @@ -1,233 +0,0 @@ ---- -description: hello-command-error - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.9" - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName hello-command-error - databaseName: &databaseName sdam-tests - documents: [] - -tests: - - description: Command error on Monitor handshake - operations: - # Configure the next streaming hello check to fail with a command error. - # Use "times: 4" to increase the probability that the Monitor check fails - # since the RTT hello may trigger this failpoint one or many times as - # well. - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 4 - data: - failCommands: - - hello - - isMaster - appName: commandErrorHandshakeTest - closeConnection: false - errorCode: 91 - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - serverDescriptionChangedEvent - - poolClearedEvent - - commandStartedEvent - uriOptions: - retryWrites: false - connectTimeoutMS: 250 - heartbeatFrequencyMS: 500 - appname: commandErrorHandshakeTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # The command error on the initial handshake should mark the server - # Unknown (emitting a ServerDescriptionChangedEvent) and clear the pool. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - # Perform an operation to ensure the node is discovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 1 - - _id: 2 - # We cannot assert the server was marked Unknown and pool was cleared an - # exact number of times because the RTT hello may or may not have - # triggered this failpoint as well. - - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: hello-command-error - documents: - - _id: 1 - - _id: 2 - commandName: insert - databaseName: *databaseName - - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - - description: Command error on Monitor check - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - connectTimeoutMS: 1000 - heartbeatFrequencyMS: 500 - appname: commandErrorCheckTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # Perform an operation to ensure the node is discovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 1 - - _id: 2 - # Configure the next streaming hello check to fail with a command - # error. - # Use times: 2 so that the RTT hello is blocked as well. - - name: failPoint - object: testRunner - arguments: - failPoint: - configureFailPoint: failCommand - mode: - times: 2 - data: - failCommands: - - hello - - isMaster - appName: commandErrorCheckTest - closeConnection: false - blockConnection: true - blockTimeMS: 750 - errorCode: 91 - client: *setupClient - # The command error on the next check should mark the server Unknown and - # clear the pool. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform an operation to ensure the node is rediscovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 3 - - _id: 4 - # Assert the server was marked Unknown and pool was cleared exactly once. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: hello-command-error - documents: - - _id: 1 - - _id: 2 - commandName: insert - databaseName: *databaseName - - commandStartedEvent: - command: - insert: hello-command-error - documents: - - _id: 3 - - _id: 4 - commandName: insert - databaseName: *databaseName - - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-network-error.json b/test/spec/server-discovery-and-monitoring/unified/hello-network-error.json deleted file mode 100644 index 55373c90cc..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/hello-network-error.json +++ /dev/null @@ -1,346 +0,0 @@ -{ - "description": "hello-network-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.9", - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "hello-network-error", - "databaseName": "sdam-tests", - "documents": [] - } - ], - "tests": [ - { - "description": "Network error on Monitor handshake", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "networkErrorHandshakeTest", - "closeConnection": true - } - } - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "connectTimeoutMS": 250, - "heartbeatFrequencyMS": 500, - "appname": "networkErrorHandshakeTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "hello-network-error" - } - } - ] - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "hello-network-error", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "hello-network-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ] - }, - { - "description": "Network error on Monitor check", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "connectTimeoutMS": 250, - "heartbeatFrequencyMS": 500, - "appname": "networkErrorCheckTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "hello-network-error" - } - } - ] - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 4 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "networkErrorCheckTest", - "closeConnection": true - } - }, - "client": "setupClient" - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "hello-network-error", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - }, - { - "commandStartedEvent": { - "command": { - "insert": "hello-network-error", - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "hello-network-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-network-error.yml b/test/spec/server-discovery-and-monitoring/unified/hello-network-error.yml deleted file mode 100644 index 92c8cf243d..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/hello-network-error.yml +++ /dev/null @@ -1,227 +0,0 @@ ---- -description: hello-network-error - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.9" - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName hello-network-error - databaseName: &databaseName sdam-tests - documents: [] - -tests: - - description: Network error on Monitor handshake - # Configure the initial handshake to fail with a network error. - # Use times: 2 so that the RTT hello fails as well. - operations: - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 2 - data: - failCommands: - - hello - - isMaster - appName: networkErrorHandshakeTest - closeConnection: true - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - connectTimeoutMS: 250 - heartbeatFrequencyMS: 500 - appname: networkErrorHandshakeTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # The network error on the initial handshake should mark the server - # Unknown (emitting a ServerDescriptionChangedEvent) and clear the pool. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - # Perform an operation to ensure the node is discovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 1 - - _id: 2 - # We cannot assert the server was marked Unknown and pool was cleared an - # exact number of times because the RTT hello may or may not have - # triggered this failpoint as well. - - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: hello-network-error - documents: - - _id: 1 - - _id: 2 - commandName: insert - databaseName: *databaseName - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - - description: Network error on Monitor check - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - connectTimeoutMS: 250 - heartbeatFrequencyMS: 500 - appname: networkErrorCheckTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # Perform an operation to ensure the node is discovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 1 - - _id: 2 - # Configure the next streaming hello check to fail with a non-timeout - # network error. Use "times: 4" to increase the probability that the - # Monitor check fails since the RTT hello may trigger this failpoint one - # or many times as well. - - name: failPoint - object: testRunner - arguments: - failPoint: - configureFailPoint: failCommand - mode: - times: 4 - data: - failCommands: - - hello - - isMaster - appName: networkErrorCheckTest - closeConnection: true - client: *setupClient - # The network error on the next check should mark the server Unknown and - # clear the pool. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform an operation to ensure the node is rediscovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 3 - - _id: 4 - # We cannot assert the server was marked Unknown and pool was cleared an - # exact number of times because the RTT hello may or may not have - # triggered this failpoint as well. - # - name: assertEventCount - # object: testRunner - # arguments: - # client: *client - # event: - # serverDescriptionChangedEvent: - # newDescription: - # type: Unknown - # count: 1 - # - name: assertEventCount - # object: testRunner - # arguments: - # event: - # poolClearedEvent: {} - # count: 1 - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: hello-network-error - documents: - - _id: 1 - - _id: 2 - commandName: insert - databaseName: *databaseName - - commandStartedEvent: - command: - insert: hello-network-error - documents: - - _id: 3 - - _id: 4 - commandName: insert - databaseName: *databaseName - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-timeout.json b/test/spec/server-discovery-and-monitoring/unified/hello-timeout.json deleted file mode 100644 index fe7cf4e78d..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/hello-timeout.json +++ /dev/null @@ -1,514 +0,0 @@ -{ - "description": "hello-timeout", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4", - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "hello-timeout", - "databaseName": "sdam-tests", - "documents": [] - } - ], - "tests": [ - { - "description": "Network timeout on Monitor handshake", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "timeoutMonitorHandshakeTest", - "blockConnection": true, - "blockTimeMS": 1000 - } - } - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "connectTimeoutMS": 250, - "heartbeatFrequencyMS": 500, - "appname": "timeoutMonitorHandshakeTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "hello-timeout" - } - } - ] - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "hello-timeout", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "hello-timeout", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ] - }, - { - "description": "Network timeout on Monitor check", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "connectTimeoutMS": 750, - "heartbeatFrequencyMS": 500, - "appname": "timeoutMonitorCheckTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "hello-timeout" - } - } - ] - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 4 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "timeoutMonitorCheckTest", - "blockConnection": true, - "blockTimeMS": 1000 - } - }, - "client": "setupClient" - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "hello-timeout", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - }, - { - "commandStartedEvent": { - "command": { - "insert": "hello-timeout", - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "hello-timeout", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - ] - }, - { - "description": "Driver extends timeout while streaming", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "connectTimeoutMS": 250, - "heartbeatFrequencyMS": 500, - "appname": "extendsTimeoutTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "hello-timeout" - } - } - ] - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - }, - { - "name": "wait", - "object": "testRunner", - "arguments": { - "ms": 2000 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 0 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 0 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "hello-timeout", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - }, - { - "commandStartedEvent": { - "command": { - "insert": "hello-timeout", - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "hello-timeout", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-timeout.yml b/test/spec/server-discovery-and-monitoring/unified/hello-timeout.yml deleted file mode 100644 index 2a3374d1e7..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/hello-timeout.yml +++ /dev/null @@ -1,318 +0,0 @@ ---- -description: hello-timeout - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.4" - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName hello-timeout - databaseName: &databaseName sdam-tests - documents: [] - -tests: - - description: Network timeout on Monitor handshake - operations: - # Configure the initial handshake to fail with a timeout. - # Use times: 2 so that the RTT hello is blocked as well. - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 2 - data: - failCommands: - - hello - - isMaster - appName: timeoutMonitorHandshakeTest - blockConnection: true - blockTimeMS: 1000 - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - connectTimeoutMS: 250 - heartbeatFrequencyMS: 500 - appname: timeoutMonitorHandshakeTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # The network error on the initial handshake should mark the server - # Unknown (emitting a ServerDescriptionChangedEvent) and clear the pool. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - # Perform an operation to ensure the node is discovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 1 - - _id: 2 - # We cannot assert the server was marked Unknown and pool was cleared an - # exact number of times because the RTT hello may or may not have - # triggered this failpoint as well. - # - name: assertEventCount - # object: testRunner - # arguments: - # event: ServerMarkedUnknownEvent - # count: 1 - # - name: assertEventCount - # object: testRunner - # arguments: - # event: PoolClearedEvent - # count: 1 - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: hello-timeout - documents: - - _id: 1 - - _id: 2 - commandName: insert - databaseName: *databaseName - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - - description: Network timeout on Monitor check - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - connectTimeoutMS: 750 - heartbeatFrequencyMS: 500 - appname: timeoutMonitorCheckTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # Perform an operation to ensure the node is discovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 1 - - _id: 2 - # Configure the next streaming hello check to fail with a timeout. - # Use "times: 4" to increase the probability that the Monitor check times - # out since the RTT hello may trigger this failpoint one or many times as - # well. - - name: failPoint - object: testRunner - arguments: - failPoint: - configureFailPoint: failCommand - mode: - times: 4 - data: - failCommands: - - hello - - isMaster - appName: timeoutMonitorCheckTest - blockConnection: true - # blockTimeMS is evaluated after the waiting for heartbeatFrequencyMS server-side, so this value only - # needs to be greater than connectTimeoutMS. The driver will wait for (500+750)ms and the server will - # respond after (500+1000)ms. - blockTimeMS: 1000 - client: *setupClient - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - # The network error on the next check should mark the server Unknown and - # clear the pool. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform an operation to ensure the node is rediscovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 3 - - _id: 4 - # We cannot assert the server was marked Unknown and pool was cleared an - # exact number of times because the RTT hello may have triggered this - # failpoint one or many times as well. - - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: hello-timeout - documents: - - _id: 1 - - _id: 2 - commandName: insert - databaseName: *databaseName - - commandStartedEvent: - command: - insert: hello-timeout - documents: - - _id: 3 - - _id: 4 - commandName: insert - databaseName: *databaseName - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 - - - description: Driver extends timeout while streaming - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - connectTimeoutMS: 250 - heartbeatFrequencyMS: 500 - appname: extendsTimeoutTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # Perform an operation to ensure the node is discovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 1 - - _id: 2 - # Wait for multiple monitor checks to complete. - - name: wait - object: testRunner - arguments: - ms: 2000 - # Perform an operation to ensure the node is still selectable. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 3 - - _id: 4 - # Assert that the server was never marked Unknown and the pool was never - # cleared. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 0 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 0 - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: hello-timeout - documents: - - _id: 1 - - _id: 2 - commandName: insert - databaseName: *databaseName - - commandStartedEvent: - command: - insert: hello-timeout - documents: - - _id: 3 - - _id: 4 - commandName: insert - databaseName: *databaseName - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 diff --git a/test/spec/server-discovery-and-monitoring/unified/insert-network-error.json b/test/spec/server-discovery-and-monitoring/unified/insert-network-error.json deleted file mode 100644 index bfe41a4cb6..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/insert-network-error.json +++ /dev/null @@ -1,246 +0,0 @@ -{ - "description": "insert-network-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4", - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "insert-network-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ], - "tests": [ - { - "description": "Reset server and pool after network error on insert", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "insert" - ], - "closeConnection": true, - "appName": "insertNetworkErrorTest" - } - } - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeEvents": [ - "commandStartedEvent", - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": false, - "appname": "insertNetworkErrorTest" - }, - "useMultipleMongoses": false - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "insert-network-error" - } - } - ] - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "expectError": { - "isError": true - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "insert-network-error", - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - }, - { - "commandStartedEvent": { - "command": { - "insert": "insert-network-error", - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "insert-network-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/insert-network-error.yml b/test/spec/server-discovery-and-monitoring/unified/insert-network-error.yml deleted file mode 100644 index fcedf54357..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/insert-network-error.yml +++ /dev/null @@ -1,137 +0,0 @@ ---- -description: insert-network-error - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.4" - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName insert-network-error - databaseName: &databaseName sdam-tests - documents: - - _id: 1 - - _id: 2 - -tests: - - description: Reset server and pool after network error on insert - operations: - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 1 - data: - failCommands: - - insert - closeConnection: true - appName: insertNetworkErrorTest - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - observeEvents: - - commandStartedEvent - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: false - appname: insertNetworkErrorTest - useMultipleMongoses: false - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - - name: insertMany - object: *collection - arguments: - documents: - - _id: 3 - - _id: 4 - expectError: - isError: true - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform another operation to ensure the node is rediscovered. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 5 - - _id: 6 - # Assert the server was marked Unknown and pool was cleared exactly once. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: insert-network-error - documents: - - _id: 3 - - _id: 4 - commandName: insert - databaseName: *databaseName - - commandStartedEvent: - command: - insert: insert-network-error - documents: - - _id: 5 - - _id: 6 - commandName: insert - databaseName: *databaseName - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 5 - - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.json b/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.json deleted file mode 100644 index af7c6c987a..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.json +++ /dev/null @@ -1,250 +0,0 @@ -{ - "description": "insert-shutdown-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4", - "serverless": "forbid", - "topologies": [ - "single", - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "insert-shutdown-error", - "databaseName": "sdam-tests", - "documents": [] - } - ], - "tests": [ - { - "description": "Concurrent shutdown error on insert", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "uriOptions": { - "retryWrites": false, - "heartbeatFrequencyMS": 500, - "appname": "shutdownErrorInsertTest" - }, - "observeEvents": [ - "serverDescriptionChangedEvent", - "poolClearedEvent" - ] - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "insert-shutdown-error" - } - } - ] - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 1 - } - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "insert" - ], - "appName": "shutdownErrorInsertTest", - "errorCode": 91, - "blockConnection": true, - "blockTimeMS": 500 - } - }, - "client": "setupClient" - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "thread": { - "id": "thread0" - } - }, - { - "thread": { - "id": "thread1" - } - } - ] - } - }, - { - "name": "runOnThread", - "object": "testRunner", - "arguments": { - "thread": "thread0", - "operation": { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 2 - } - }, - "expectError": { - "isError": true - } - } - } - }, - { - "name": "runOnThread", - "object": "testRunner", - "arguments": { - "thread": "thread1", - "operation": { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 3 - } - }, - "expectError": { - "isError": true - } - } - } - }, - { - "name": "waitForThread", - "object": "testRunner", - "arguments": { - "thread": "thread0" - } - }, - { - "name": "waitForThread", - "object": "testRunner", - "arguments": { - "thread": "thread1" - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 4 - } - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - } - ], - "outcome": [ - { - "collectionName": "insert-shutdown-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 4 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.yml b/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.yml deleted file mode 100644 index ae32229ffa..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.yml +++ /dev/null @@ -1,162 +0,0 @@ ---- -description: insert-shutdown-error - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.4" - serverless: forbid - topologies: [ single, replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName insert-shutdown-error - databaseName: &databaseName sdam-tests - documents: [] - -tests: - - description: Concurrent shutdown error on insert - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - uriOptions: - retryWrites: false - heartbeatFrequencyMS: 500 - appname: shutdownErrorInsertTest - observeEvents: - - serverDescriptionChangedEvent - - poolClearedEvent - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # Perform an operation to ensure the node is discovered. - - name: insertOne - object: *collection - arguments: - document: - _id: 1 - # Configure the next two inserts to fail with a non-timeout shutdown - # errors. Block the connection for 500ms to ensure both operations check - # out connections from the same pool generation. - - name: failPoint - object: testRunner - arguments: - failPoint: - configureFailPoint: failCommand - mode: - times: 2 - data: - failCommands: - - insert - appName: shutdownErrorInsertTest - errorCode: 91 - blockConnection: true - blockTimeMS: 500 - client: *setupClient - # Start threads. - - name: createEntities - object: testRunner - arguments: - entities: - - thread: - id: &thread0 thread0 - - thread: - id: &thread1 thread1 - # Perform concurrent insert operations. Both fail with shutdown errors. - - name: runOnThread - object: testRunner - arguments: - thread: *thread0 - operation: - name: insertOne - object: *collection - arguments: - document: - _id: 2 - expectError: - isError: true - - name: runOnThread - object: testRunner - arguments: - thread: *thread1 - operation: - name: insertOne - object: *collection - arguments: - document: - _id: 3 - expectError: - isError: true - # Stop threads. - - name: waitForThread - object: testRunner - arguments: - thread: *thread0 - - name: waitForThread - object: testRunner - arguments: - thread: *thread1 - # The first shutdown error should mark the server Unknown and then clear - # the pool. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform an operation to ensure the node is rediscovered. - - name: insertOne - object: *collection - arguments: - document: - _id: 4 - # Assert the server was marked Unknown and pool was cleared exactly once. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - - # Order of operations is non-deterministic so we cannot check events. - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 4 diff --git a/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json b/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json deleted file mode 100644 index a20d79030a..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json +++ /dev/null @@ -1,591 +0,0 @@ -{ - "description": "interruptInUse", - "schemaVersion": "1.11", - "runOnRequirements": [ - { - "minServerVersion": "4.9", - "serverless": "forbid", - "topologies": [ - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "interruptInUse", - "databaseName": "sdam-tests", - "documents": [] - } - ], - "tests": [ - { - "description": "Connection pool clear uses interruptInUseConnections=true after monitor timeout", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "poolClearedEvent", - "connectionClosedEvent", - "commandStartedEvent", - "commandSucceededEvent", - "commandFailedEvent", - "connectionCheckedOutEvent", - "connectionCheckedInEvent" - ], - "uriOptions": { - "connectTimeoutMS": 500, - "heartbeatFrequencyMS": 500, - "appname": "interruptInUse", - "retryReads": false, - "minPoolSize": 0 - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "interruptInUse" - } - }, - { - "thread": { - "id": "thread1" - } - } - ] - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 1 - } - } - }, - { - "name": "runOnThread", - "object": "testRunner", - "arguments": { - "thread": "thread1", - "operation": { - "name": "find", - "object": "collection", - "arguments": { - "filter": { - "$where": "sleep(2000) || true" - } - }, - "expectError": { - "isError": true - } - } - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 4 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "blockConnection": true, - "blockTimeMS": 1500, - "appName": "interruptInUse" - } - } - } - }, - { - "name": "waitForThread", - "object": "testRunner", - "arguments": { - "thread": "thread1" - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "commandName": "insert" - } - }, - { - "commandSucceededEvent": { - "commandName": "insert" - } - }, - { - "commandStartedEvent": { - "commandName": "find" - } - }, - { - "commandFailedEvent": { - "commandName": "find" - } - } - ] - }, - { - "client": "client", - "eventType": "cmap", - "events": [ - { - "connectionCheckedOutEvent": {} - }, - { - "connectionCheckedInEvent": {} - }, - { - "connectionCheckedOutEvent": {} - }, - { - "poolClearedEvent": { - "interruptInUseConnections": true - } - }, - { - "connectionCheckedInEvent": {} - }, - { - "connectionClosedEvent": {} - } - ] - } - ], - "outcome": [ - { - "collectionName": "interruptInUse", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - } - ] - } - ] - }, - { - "description": "Error returned from connection pool clear with interruptInUseConnections=true is retryable", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "poolClearedEvent", - "connectionClosedEvent", - "commandStartedEvent", - "commandFailedEvent", - "commandSucceededEvent", - "connectionCheckedOutEvent", - "connectionCheckedInEvent" - ], - "uriOptions": { - "connectTimeoutMS": 500, - "heartbeatFrequencyMS": 500, - "appname": "interruptInUseRetryable", - "retryReads": true, - "minPoolSize": 0 - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "interruptInUse" - } - }, - { - "thread": { - "id": "thread1" - } - } - ] - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 1 - } - } - }, - { - "name": "runOnThread", - "object": "testRunner", - "arguments": { - "thread": "thread1", - "operation": { - "name": "find", - "object": "collection", - "arguments": { - "filter": { - "$where": "sleep(2000) || true" - } - } - } - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 4 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "blockConnection": true, - "blockTimeMS": 1500, - "appName": "interruptInUseRetryable" - } - } - } - }, - { - "name": "waitForThread", - "object": "testRunner", - "arguments": { - "thread": "thread1" - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "commandName": "insert" - } - }, - { - "commandSucceededEvent": { - "commandName": "insert" - } - }, - { - "commandStartedEvent": { - "commandName": "find" - } - }, - { - "commandFailedEvent": { - "commandName": "find" - } - }, - { - "commandStartedEvent": { - "commandName": "find" - } - }, - { - "commandSucceededEvent": { - "commandName": "find" - } - } - ] - }, - { - "client": "client", - "eventType": "cmap", - "events": [ - { - "connectionCheckedOutEvent": {} - }, - { - "connectionCheckedInEvent": {} - }, - { - "connectionCheckedOutEvent": {} - }, - { - "poolClearedEvent": { - "interruptInUseConnections": true - } - }, - { - "connectionCheckedInEvent": {} - }, - { - "connectionClosedEvent": {} - }, - { - "connectionCheckedOutEvent": {} - }, - { - "connectionCheckedInEvent": {} - } - ] - } - ], - "outcome": [ - { - "collectionName": "interruptInUse", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - } - ] - } - ] - }, - { - "description": "Error returned from connection pool clear with interruptInUseConnections=true is retryable for write", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "poolClearedEvent", - "connectionClosedEvent", - "commandStartedEvent", - "commandFailedEvent", - "commandSucceededEvent", - "connectionCheckedOutEvent", - "connectionCheckedInEvent" - ], - "uriOptions": { - "connectTimeoutMS": 500, - "heartbeatFrequencyMS": 500, - "appname": "interruptInUseRetryableWrite", - "retryWrites": true, - "minPoolSize": 0 - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "interruptInUse" - } - }, - { - "thread": { - "id": "thread1" - } - } - ] - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 1 - } - } - }, - { - "name": "runOnThread", - "object": "testRunner", - "arguments": { - "thread": "thread1", - "operation": { - "name": "updateOne", - "object": "collection", - "arguments": { - "filter": { - "$where": "sleep(2000) || true" - }, - "update": { - "$set": { - "a": "bar" - } - } - } - } - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 4 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "blockConnection": true, - "blockTimeMS": 1500, - "appName": "interruptInUseRetryableWrite" - } - } - } - }, - { - "name": "waitForThread", - "object": "testRunner", - "arguments": { - "thread": "thread1" - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "commandName": "insert" - } - }, - { - "commandSucceededEvent": { - "commandName": "insert" - } - }, - { - "commandStartedEvent": { - "commandName": "update" - } - }, - { - "commandFailedEvent": { - "commandName": "update" - } - }, - { - "commandStartedEvent": { - "commandName": "update" - } - }, - { - "commandSucceededEvent": { - "commandName": "update" - } - } - ] - }, - { - "client": "client", - "eventType": "cmap", - "events": [ - { - "connectionCheckedOutEvent": {} - }, - { - "connectionCheckedInEvent": {} - }, - { - "connectionCheckedOutEvent": {} - }, - { - "poolClearedEvent": { - "interruptInUseConnections": true - } - }, - { - "connectionCheckedInEvent": {} - }, - { - "connectionClosedEvent": {} - }, - { - "connectionCheckedOutEvent": {} - }, - { - "connectionCheckedInEvent": {} - } - ] - } - ], - "outcome": [ - { - "collectionName": "interruptInUse", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1, - "a": "bar" - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml b/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml deleted file mode 100644 index 1f241e8536..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml +++ /dev/null @@ -1,341 +0,0 @@ ---- -description: interruptInUse - -schemaVersion: "1.11" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.9" - serverless: forbid - topologies: [ replicaset, sharded ] - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName interruptInUse - databaseName: &databaseName sdam-tests - documents: [] - -tests: - - description: Connection pool clear uses interruptInUseConnections=true after monitor timeout - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - poolClearedEvent - - connectionClosedEvent - - commandStartedEvent - - commandSucceededEvent - - commandFailedEvent - - connectionCheckedOutEvent - - connectionCheckedInEvent - uriOptions: - connectTimeoutMS: 500 - heartbeatFrequencyMS: 500 - appname: interruptInUse - retryReads: false - minPoolSize: 0 - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - - thread: - id: &thread1 thread1 - - name: insertOne - object: *collection - arguments: - document: { _id: 1 } - # simulate a long-running query - - name: runOnThread - object: testRunner - arguments: - thread: *thread1 - operation: - name: find - object: *collection - arguments: - filter: - $where : sleep(2000) || true - expectError: - isError: true - # Configure the monitor check to fail with a timeout. - # Use "times: 4" to increase the probability that the Monitor check triggers - # the failpoint, since the RTT hello may trigger this failpoint one or many - # times as well. - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 4 - data: - failCommands: - - hello - - isMaster - blockConnection: true - blockTimeMS: 1500 - appName: interruptInUse - - name: waitForThread - object: testRunner - arguments: - thread: *thread1 - - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - commandName: insert - - commandSucceededEvent: - commandName: insert - - commandStartedEvent: - commandName: find - - commandFailedEvent: - commandName: find - - client: *client - eventType: cmap - events: - - connectionCheckedOutEvent: {} - - connectionCheckedInEvent: {} - - connectionCheckedOutEvent: {} - - poolClearedEvent: - interruptInUseConnections: true - - connectionCheckedInEvent: {} - - connectionClosedEvent: {} - - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - - description: Error returned from connection pool clear with interruptInUseConnections=true is retryable - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - poolClearedEvent - - connectionClosedEvent - - commandStartedEvent - - commandFailedEvent - - commandSucceededEvent - - connectionCheckedOutEvent - - connectionCheckedInEvent - uriOptions: - connectTimeoutMS: 500 - heartbeatFrequencyMS: 500 - appname: interruptInUseRetryable - retryReads: true - minPoolSize: 0 - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - - thread: - id: &thread1 thread1 - - name: insertOne - object: *collection - arguments: - document: { _id: 1 } - # simulate a long-running query - - name: runOnThread - object: testRunner - arguments: - thread: *thread1 - operation: - name: find - object: *collection - arguments: - filter: - $where : sleep(2000) || true - # Configure the monitor check to fail with a timeout. - # Use "times: 4" to increase the probability that the Monitor check triggers - # the failpoint, since the RTT hello may trigger this failpoint one or many - # times as well. - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 4 - data: - failCommands: - - hello - - isMaster - blockConnection: true - blockTimeMS: 1500 - appName: interruptInUseRetryable - - name: waitForThread - object: testRunner - arguments: - thread: *thread1 - - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - commandName: insert - - commandSucceededEvent: - commandName: insert - - commandStartedEvent: - commandName: find - - commandFailedEvent: - commandName: find - - commandStartedEvent: - commandName: find - - commandSucceededEvent: - commandName: find - - client: *client - eventType: cmap - events: - - connectionCheckedOutEvent: {} - - connectionCheckedInEvent: {} - - connectionCheckedOutEvent: {} - - poolClearedEvent: - interruptInUseConnections: true - - connectionCheckedInEvent: {} - - connectionClosedEvent: {} - - connectionCheckedOutEvent: {} - - connectionCheckedInEvent: {} - - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - description: Error returned from connection pool clear with interruptInUseConnections=true is retryable for write - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - poolClearedEvent - - connectionClosedEvent - - commandStartedEvent - - commandFailedEvent - - commandSucceededEvent - - connectionCheckedOutEvent - - connectionCheckedInEvent - uriOptions: - connectTimeoutMS: 500 - heartbeatFrequencyMS: 500 - appname: interruptInUseRetryableWrite - retryWrites: true - minPoolSize: 0 - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - - thread: - id: &thread1 thread1 - # ensure the primary is discovered - - name: insertOne - object: *collection - arguments: - document: { _id: 1 } - # simulate a long-running query - - name: runOnThread - object: testRunner - arguments: - thread: *thread1 - operation: - name: updateOne - object: *collection - arguments: - filter: - $where: sleep(2000) || true - update: - "$set": { "a": "bar" } - # Configure the monitor check to fail with a timeout. - # Use "times: 4" to increase the probability that the Monitor check triggers - # the failpoint, since the RTT hello may trigger this failpoint one or many - # times as well. - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 4 - data: - failCommands: - - hello - - isMaster - blockConnection: true - blockTimeMS: 1500 - appName: interruptInUseRetryableWrite - - name: waitForThread - object: testRunner - arguments: - thread: *thread1 - - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - commandName: insert - - commandSucceededEvent: - commandName: insert - - commandStartedEvent: - commandName: update - - commandFailedEvent: - commandName: update - - commandStartedEvent: - commandName: update - - commandSucceededEvent: - commandName: update - - client: *client - eventType: cmap - events: - - connectionCheckedOutEvent: {} - - connectionCheckedInEvent: {} - - connectionCheckedOutEvent: {} - - poolClearedEvent: - interruptInUseConnections: true - - connectionCheckedInEvent: {} - - connectionClosedEvent: {} - - connectionCheckedOutEvent: {} - - connectionCheckedInEvent: {} - - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - { _id: 1, a : bar } - diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.json b/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.json deleted file mode 100644 index 45440d2557..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.json +++ /dev/null @@ -1,150 +0,0 @@ -{ - "description": "loadbalanced-logging", - "schemaVersion": "1.16", - "runOnRequirements": [ - { - "topologies": [ - "load-balanced" - ], - "minServerVersion": "4.4" - } - ], - "tests": [ - { - "description": "Topology lifecycle", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeLogMessages": { - "topology": "debug" - }, - "observeEvents": [ - "topologyDescriptionChangedEvent" - ] - } - } - ] - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "topologyDescriptionChangedEvent": {} - }, - "count": 2 - } - }, - { - "name": "close", - "object": "client" - } - ], - "expectLogMessages": [ - { - "client": "client", - "messages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting topology monitoring", - "topologyId": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting server monitoring", - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring", - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped topology monitoring", - "topologyId": { - "$$exists": true - } - } - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.yml b/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.yml deleted file mode 100644 index 3f6058270f..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.yml +++ /dev/null @@ -1,74 +0,0 @@ -description: "loadbalanced-logging" - -schemaVersion: "1.16" - -runOnRequirements: - - topologies: - - load-balanced - minServerVersion: "4.4" # awaitable hello - -tests: - - description: "Topology lifecycle" - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - observeLogMessages: - topology: debug - observeEvents: - - topologyDescriptionChangedEvent - # ensure the topology has been fully discovered before closing the client. - # expected events are initial server discovery and server connect event. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - topologyDescriptionChangedEvent: {} - count: 2 - - name: close - object: *client - expectLogMessages: - - client: *client - messages: - - level: debug - component: topology - data: - message: "Starting topology monitoring" - topologyId: { $$exists: true } - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } # unknown topology - newDescription: { $$exists: true } # unknown topology, disconnected server - - level: debug - component: topology - data: - message: "Starting server monitoring" - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } - newDescription: { $$exists: true } # loadBalanced topology - - level: debug - component: topology - data: - message: "Stopped server monitoring" - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - - level: debug - component: topology - data: - message: "Stopped topology monitoring" - topologyId: { $$exists: true } \ No newline at end of file diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json deleted file mode 100644 index e6738225cd..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json +++ /dev/null @@ -1,606 +0,0 @@ -{ - "description": "replicaset-logging", - "schemaVersion": "1.16", - "runOnRequirements": [ - { - "topologies": [ - "replicaset" - ], - "minServerVersion": "4.4" - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient" - } - } - ], - "tests": [ - { - "description": "Topology lifecycle", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeLogMessages": { - "topology": "debug" - }, - "observeEvents": [ - "topologyDescriptionChangedEvent" - ] - } - } - ] - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "topologyDescriptionChangedEvent": {} - }, - "count": 4 - } - }, - { - "name": "close", - "object": "client" - } - ], - "expectLogMessages": [ - { - "client": "client", - "ignoreMessages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat started" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat succeeded" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat failed" - } - } - ], - "messages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting topology monitoring", - "topologyId": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring", - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring", - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring", - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped topology monitoring", - "topologyId": { - "$$exists": true - } - } - } - ] - } - ] - }, - { - "description": "Successful heartbeat", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeLogMessages": { - "topology": "debug" - }, - "observeEvents": [ - "serverHeartbeatSucceededEvent" - ] - } - } - ] - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverHeartbeatSucceededEvent": {} - }, - "count": 3 - } - } - ], - "expectLogMessages": [ - { - "client": "client", - "ignoreExtraMessages": true, - "ignoreMessages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat started" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed" - } - } - ], - "messages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting topology monitoring", - "topologyId": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat succeeded", - "awaited": { - "$$exists": true - }, - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - }, - "driverConnectionId": { - "$$exists": true - }, - "serverConnectionId": { - "$$exists": true - }, - "durationMS": { - "$$type": [ - "int", - "long" - ] - }, - "reply": { - "$$matchAsDocument": { - "$$matchAsRoot": { - "ok": 1 - } - } - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat succeeded", - "awaited": { - "$$exists": true - }, - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - }, - "driverConnectionId": { - "$$exists": true - }, - "serverConnectionId": { - "$$exists": true - }, - "durationMS": { - "$$type": [ - "int", - "long" - ] - }, - "reply": { - "$$matchAsDocument": { - "$$matchAsRoot": { - "ok": 1 - } - } - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat succeeded", - "awaited": { - "$$exists": true - }, - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - }, - "driverConnectionId": { - "$$exists": true - }, - "serverConnectionId": { - "$$exists": true - }, - "durationMS": { - "$$type": [ - "int", - "long" - ] - }, - "reply": { - "$$matchAsDocument": { - "$$matchAsRoot": { - "ok": 1 - } - } - } - } - } - ] - } - ] - }, - { - "description": "Failing heartbeat", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeLogMessages": { - "topology": "debug" - }, - "observeEvents": [ - "serverHeartbeatFailedEvent" - ], - "uriOptions": { - "appname": "failingHeartbeatLoggingTest" - } - } - } - ] - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "failPoint": { - "configureFailPoint": "failCommand", - "mode": "alwaysOn", - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "failingHeartbeatLoggingTest", - "closeConnection": true - } - }, - "client": "setupClient" - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverHeartbeatFailedEvent": {} - }, - "count": 1 - } - } - ], - "expectLogMessages": [ - { - "client": "client", - "ignoreExtraMessages": true, - "ignoreMessages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat started" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat succeeded" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed" - } - } - ], - "messages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting topology monitoring", - "topologyId": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat failed", - "awaited": { - "$$exists": true - }, - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - }, - "driverConnectionId": { - "$$exists": true - }, - "durationMS": { - "$$type": [ - "int", - "long" - ] - }, - "failure": { - "$$exists": true - } - } - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml deleted file mode 100644 index a0b856ec72..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml +++ /dev/null @@ -1,289 +0,0 @@ -description: "replicaset-logging" - -schemaVersion: "1.16" - -runOnRequirements: - - topologies: - - replicaset - minServerVersion: "4.4" # awaitable hello - -createEntities: - - client: - id: &setupClient setupClient - -tests: - - description: "Topology lifecycle" - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - observeLogMessages: - topology: debug - observeEvents: - - topologyDescriptionChangedEvent - # ensure the topology has been fully discovered before closing the client. - # expected events are initial cluster type change from unknown to ReplicaSet, and connect events for each of 3 servers. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - topologyDescriptionChangedEvent: {} - count: 4 - - name: close - object: *client - expectLogMessages: - - client: *client - ignoreMessages: - - level: debug - component: topology - data: - message: "Starting server monitoring" - - level: debug - component: topology - data: - message: "Server heartbeat started" - - level: debug - component: topology - data: - message: "Server heartbeat succeeded" - - level: debug - component: topology - data: - message: "Server heartbeat failed" - messages: - - level: debug - component: topology - data: - message: "Starting topology monitoring" - topologyId: { $$exists: true } - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } # unknown topology - newDescription: { $$exists: true } # ReplicaSet topology - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } - newDescription: { $$exists: true } # server connected - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } - newDescription: { $$exists: true } # server connected - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } - newDescription: { $$exists: true } # server connected - - level: debug - component: topology - data: - message: "Stopped server monitoring" - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - - level: debug - component: topology - data: - message: "Stopped server monitoring" - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - - level: debug - component: topology - data: - message: "Stopped server monitoring" - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } # ReplicaSet topology - newDescription: { $$exists: true } # unknown topology - - level: debug - component: topology - data: - message: "Stopped topology monitoring" - topologyId: { $$exists: true } - - description: Successful heartbeat - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: *client - observeLogMessages: - topology: debug - observeEvents: - - serverHeartbeatSucceededEvent - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverHeartbeatSucceededEvent: {} - count: 3 - expectLogMessages: - - client: *client - ignoreExtraMessages: true - ignoreMessages: - - level: debug - component: topology - data: - message: "Server heartbeat started" - - level: debug - component: topology - data: - message: "Starting server monitoring" - - level: debug - component: topology - data: - message: "Stopped server monitoring" - - level: debug - component: topology - data: - message: "Topology description changed" - messages: - - level: debug - component: topology - data: - message: "Starting topology monitoring" - topologyId: { $$exists: true } - - level: debug - component: topology - data: - message: "Server heartbeat succeeded" - awaited: { $$exists: true } - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - driverConnectionId: { $$exists: true } - serverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } - reply: - $$matchAsDocument: - "$$matchAsRoot": - ok: 1 - - level: debug - component: topology - data: - message: "Server heartbeat succeeded" - awaited: { $$exists: true } - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - driverConnectionId: { $$exists: true } - serverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } - reply: - $$matchAsDocument: - "$$matchAsRoot": - ok: 1 - - level: debug - component: topology - data: - message: "Server heartbeat succeeded" - awaited: { $$exists: true } - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - driverConnectionId: { $$exists: true } - serverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } - reply: - $$matchAsDocument: - "$$matchAsRoot": - ok: 1 - - description: Failing heartbeat - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: *client - observeLogMessages: - topology: debug - observeEvents: - - serverHeartbeatFailedEvent - uriOptions: - appname: failingHeartbeatLoggingTest - - name: failPoint - object: testRunner - arguments: - failPoint: - configureFailPoint: failCommand - mode: "alwaysOn" - data: - failCommands: - - hello - - isMaster - appName: failingHeartbeatLoggingTest - closeConnection: true - client: *setupClient - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverHeartbeatFailedEvent: {} - count: 1 - expectLogMessages: - - client: *client - ignoreExtraMessages: true - ignoreMessages: - - level: debug - component: topology - data: - message: "Server heartbeat started" - - level: debug - component: topology - data: - message: "Server heartbeat succeeded" - - level: debug - component: topology - data: - message: "Starting server monitoring" - - level: debug - component: topology - data: - message: "Stopped server monitoring" - - level: debug - component: topology - data: - message: "Topology description changed" - messages: - - level: debug - component: topology - data: - message: "Starting topology monitoring" - topologyId: - "$$exists": true - - level: debug - component: topology - data: - message: "Server heartbeat failed" - awaited: { $$exists: true } - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - driverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } - failure: { $$exists: true } \ No newline at end of file diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json deleted file mode 100644 index 61b27f5be0..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json +++ /dev/null @@ -1,492 +0,0 @@ -{ - "description": "sharded-logging", - "schemaVersion": "1.16", - "runOnRequirements": [ - { - "topologies": [ - "sharded" - ], - "minServerVersion": "4.4" - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "tests": [ - { - "description": "Topology lifecycle", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeLogMessages": { - "topology": "debug" - }, - "observeEvents": [ - "topologyDescriptionChangedEvent" - ], - "useMultipleMongoses": true - } - } - ] - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "topologyDescriptionChangedEvent": {} - }, - "count": 3 - } - }, - { - "name": "close", - "object": "client" - } - ], - "expectLogMessages": [ - { - "client": "client", - "ignoreMessages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat started" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat succeeded" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat failed" - } - } - ], - "messages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting topology monitoring", - "topologyId": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring", - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring", - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped topology monitoring", - "topologyId": { - "$$exists": true - } - } - } - ] - } - ] - }, - { - "description": "Successful heartbeat", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeLogMessages": { - "topology": "debug" - }, - "observeEvents": [ - "serverHeartbeatSucceededEvent" - ] - } - } - ] - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverHeartbeatSucceededEvent": {} - }, - "count": 1 - } - } - ], - "expectLogMessages": [ - { - "client": "client", - "ignoreExtraMessages": true, - "ignoreMessages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat started" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed" - } - } - ], - "messages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting topology monitoring", - "topologyId": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat succeeded", - "awaited": { - "$$exists": true - }, - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - }, - "driverConnectionId": { - "$$exists": true - }, - "serverConnectionId": { - "$$exists": true - }, - "durationMS": { - "$$type": [ - "int", - "long" - ] - }, - "reply": { - "$$matchAsDocument": { - "$$matchAsRoot": { - "ok": 1 - } - } - } - } - } - ] - } - ] - }, - { - "description": "Failing heartbeat", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeLogMessages": { - "topology": "debug" - }, - "observeEvents": [ - "serverHeartbeatStartedEvent", - "serverHeartbeatFailedEvent" - ], - "uriOptions": { - "appname": "failingHeartbeatLoggingTest" - } - } - } - ] - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "failPoint": { - "configureFailPoint": "failCommand", - "mode": "alwaysOn", - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "failingHeartbeatLoggingTest", - "closeConnection": true - } - }, - "client": "setupClient" - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverHeartbeatFailedEvent": {} - }, - "count": 1 - } - } - ], - "expectLogMessages": [ - { - "client": "client", - "ignoreExtraMessages": true, - "ignoreMessages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat started" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat succeeded" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed" - } - } - ], - "messages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting topology monitoring", - "topologyId": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat failed", - "awaited": { - "$$exists": true - }, - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - }, - "driverConnectionId": { - "$$exists": true - }, - "durationMS": { - "$$type": [ - "int", - "long" - ] - }, - "failure": { - "$$exists": true - } - } - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml deleted file mode 100644 index 19870878b9..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml +++ /dev/null @@ -1,248 +0,0 @@ -description: "sharded-logging" - -schemaVersion: "1.16" - -runOnRequirements: - - topologies: - - sharded - minServerVersion: "4.4" # awaitable hello - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -tests: - - description: "Topology lifecycle" - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - observeLogMessages: - topology: debug - observeEvents: - - topologyDescriptionChangedEvent - useMultipleMongoses: true - # ensure the topology has been fully discovered before closing the client. - # expected events are initial cluster type change from unknown to sharded, and connect events for each of 2 servers. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - topologyDescriptionChangedEvent: {} - count: 3 - - name: close - object: *client - expectLogMessages: - - client: *client - ignoreMessages: - - level: debug - component: topology - data: - message: "Starting server monitoring" - - level: debug - component: topology - data: - message: "Server heartbeat started" - - level: debug - component: topology - data: - message: "Server heartbeat succeeded" - - level: debug - component: topology - data: - message: "Server heartbeat failed" - messages: - - level: debug - component: topology - data: - message: "Starting topology monitoring" - topologyId: { $$exists: true } - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } # unknown topology - newDescription: { $$exists: true } # Sharded topology - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } - newDescription: { $$exists: true } # shard router connected - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } - newDescription: { $$exists: true } # shard router connected - - level: debug - component: topology - data: - message: "Stopped server monitoring" - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - - level: debug - component: topology - data: - message: "Stopped server monitoring" - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } # Sharded topology - newDescription: { $$exists: true } # unknown topology - - level: debug - component: topology - data: - message: "Stopped topology monitoring" - topologyId: { $$exists: true } - - description: Successful heartbeat - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: *client - observeLogMessages: - topology: debug - observeEvents: - - serverHeartbeatSucceededEvent - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverHeartbeatSucceededEvent: {} - count: 1 - expectLogMessages: - - client: *client - ignoreExtraMessages: true - ignoreMessages: - - level: debug - component: topology - data: - message: "Server heartbeat started" - - level: debug - component: topology - data: - message: "Starting server monitoring" - - level: debug - component: topology - data: - message: "Stopped server monitoring" - - level: debug - component: topology - data: - message: "Topology description changed" - messages: - - level: debug - component: topology - data: - message: "Starting topology monitoring" - topologyId: { $$exists: true } - - level: debug - component: topology - data: - message: "Server heartbeat succeeded" - awaited: { $$exists: true } - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - driverConnectionId: { $$exists: true } - serverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } - reply: - $$matchAsDocument: - "$$matchAsRoot": - ok: 1 - - description: Failing heartbeat - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: *client - observeLogMessages: - topology: debug - observeEvents: - - serverHeartbeatStartedEvent - - serverHeartbeatFailedEvent - uriOptions: - appname: failingHeartbeatLoggingTest - - name: failPoint - object: testRunner - arguments: - failPoint: - configureFailPoint: failCommand - mode: "alwaysOn" - data: - failCommands: - - hello - - isMaster - appName: failingHeartbeatLoggingTest - closeConnection: true - client: *setupClient - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverHeartbeatFailedEvent: {} - count: 1 - expectLogMessages: - - client: *client - ignoreExtraMessages: true - ignoreMessages: - - level: debug - component: topology - data: - message: "Server heartbeat started" - - level: debug - component: topology - data: - message: "Server heartbeat succeeded" - - level: debug - component: topology - data: - message: "Starting server monitoring" - - level: debug - component: topology - data: - message: "Stopped server monitoring" - - level: debug - component: topology - data: - message: "Topology description changed" - messages: - - level: debug - component: topology - data: - message: "Starting topology monitoring" - topologyId: - "$$exists": true - - level: debug - component: topology - data: - message: "Server heartbeat failed" - awaited: { $$exists: true } - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - driverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } - failure: { $$exists: true } \ No newline at end of file diff --git a/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.json b/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.json deleted file mode 100644 index 7e294baf66..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - "description": "minPoolSize-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.9", - "serverless": "forbid", - "topologies": [ - "single" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "sdam-minPoolSize-error", - "databaseName": "sdam-tests", - "documents": [] - } - ], - "tests": [ - { - "description": "Network error on minPoolSize background creation", - "operations": [ - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "skip": 3 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "SDAMminPoolSizeError", - "closeConnection": true - } - } - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "serverDescriptionChangedEvent", - "poolClearedEvent", - "poolReadyEvent" - ], - "uriOptions": { - "heartbeatFrequencyMS": 10000, - "appname": "SDAMminPoolSizeError", - "minPoolSize": 10, - "serverSelectionTimeoutMS": 1000 - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "sdam-minPoolSize-error" - } - } - ] - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolReadyEvent": {} - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "runCommand", - "object": "database", - "arguments": { - "command": { - "ping": {} - }, - "commandName": "ping" - }, - "expectError": { - "isError": true - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "failPoint": { - "configureFailPoint": "failCommand", - "mode": "off" - }, - "client": "setupClient" - } - }, - { - "name": "runCommand", - "object": "database", - "arguments": { - "command": { - "ping": 1 - }, - "commandName": "ping" - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolReadyEvent": {} - }, - "count": 2 - } - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.yml b/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.yml deleted file mode 100644 index 7d76174694..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -description: minPoolSize-error - -schemaVersion: "1.4" - -runOnRequirements: - # failCommand appName requirements - - minServerVersion: "4.9" - serverless: forbid - topologies: - - single - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName sdam-minPoolSize-error - databaseName: &databaseName sdam-tests - documents: [] - -tests: - - description: Network error on minPoolSize background creation - operations: - # Configure the initial monitor handshake to succeed but the - # first or second background minPoolSize establishments to fail. - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - skip: 3 - data: - failCommands: - - hello - - isMaster - appName: SDAMminPoolSizeError - closeConnection: true - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - serverDescriptionChangedEvent - - poolClearedEvent - - poolReadyEvent - uriOptions: - heartbeatFrequencyMS: 10000 - appname: SDAMminPoolSizeError - minPoolSize: 10 - serverSelectionTimeoutMS: 1000 - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # Wait for monitor to succeed handshake and mark the pool as ready. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolReadyEvent: {} - count: 1 - # Background connection establishment ensuring minPoolSize should fail, - # causing the pool to be cleared. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # The server should be marked as Unknown as part of this. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - # Executing a command should fail server selection due to not being able - # to find the primary. - - name: runCommand - object: *database - arguments: - command: - ping: {} - commandName: ping - expectError: - isError: true - # Disable the failpoint, allowing the monitor to discover the primary again. - - name: failPoint - object: testRunner - arguments: - failPoint: - configureFailPoint: failCommand - mode: "off" - client: *setupClient - # Perform an operation to ensure the node is discovered. - - name: runCommand - object: *database - arguments: - command: - ping: 1 - commandName: ping - # Assert that the monitor discovered the primary and mark the pool as ready again. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolReadyEvent: {} - count: 2 diff --git a/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.json b/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.json deleted file mode 100644 index b7f6924f2b..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.json +++ /dev/null @@ -1,373 +0,0 @@ -{ - "description": "pool-cleared-error", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.9", - "serverless": "forbid", - "topologies": [ - "replicaset", - "sharded" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient", - "useMultipleMongoses": false - } - } - ], - "initialData": [ - { - "collectionName": "pool-cleared-error", - "databaseName": "sdam-tests", - "documents": [] - } - ], - "tests": [ - { - "description": "PoolClearedError does not mark server unknown", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "serverDescriptionChangedEvent", - "poolClearedEvent" - ], - "uriOptions": { - "retryWrites": true, - "maxPoolSize": 1, - "appname": "poolClearedErrorTest" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "pool-cleared-error" - } - } - ] - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 1 - } - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "insert" - ], - "blockConnection": true, - "blockTimeMS": 100, - "closeConnection": true, - "appName": "poolClearedErrorTest" - } - }, - "client": "setupClient" - } - }, - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "thread": { - "id": "thread0" - } - }, - { - "thread": { - "id": "thread1" - } - }, - { - "thread": { - "id": "thread2" - } - }, - { - "thread": { - "id": "thread3" - } - }, - { - "thread": { - "id": "thread4" - } - }, - { - "thread": { - "id": "thread5" - } - } - ] - } - }, - { - "name": "runOnThread", - "object": "testRunner", - "arguments": { - "thread": "thread0", - "operation": { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 2 - } - } - } - } - }, - { - "name": "runOnThread", - "object": "testRunner", - "arguments": { - "thread": "thread1", - "operation": { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 3 - } - } - } - } - }, - { - "name": "runOnThread", - "object": "testRunner", - "arguments": { - "thread": "thread2", - "operation": { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 4 - } - } - } - } - }, - { - "name": "runOnThread", - "object": "testRunner", - "arguments": { - "thread": "thread3", - "operation": { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 5 - } - } - } - } - }, - { - "name": "runOnThread", - "object": "testRunner", - "arguments": { - "thread": "thread4", - "operation": { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 6 - } - } - } - } - }, - { - "name": "runOnThread", - "object": "testRunner", - "arguments": { - "thread": "thread5", - "operation": { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 7 - } - } - } - } - }, - { - "name": "waitForThread", - "object": "testRunner", - "arguments": { - "thread": "thread0" - } - }, - { - "name": "waitForThread", - "object": "testRunner", - "arguments": { - "thread": "thread1" - } - }, - { - "name": "waitForThread", - "object": "testRunner", - "arguments": { - "thread": "thread2" - } - }, - { - "name": "waitForThread", - "object": "testRunner", - "arguments": { - "thread": "thread3" - } - }, - { - "name": "waitForThread", - "object": "testRunner", - "arguments": { - "thread": "thread4" - } - }, - { - "name": "waitForThread", - "object": "testRunner", - "arguments": { - "thread": "thread5" - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "document": { - "_id": 8 - } - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverDescriptionChangedEvent": { - "newDescription": { - "type": "Unknown" - } - } - }, - "count": 1 - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - } - ], - "outcome": [ - { - "collectionName": "pool-cleared-error", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - }, - { - "_id": 5 - }, - { - "_id": 6 - }, - { - "_id": 7 - }, - { - "_id": 8 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.yml b/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.yml deleted file mode 100644 index 7a98e2b324..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.yml +++ /dev/null @@ -1,239 +0,0 @@ ---- -description: pool-cleared-error - -schemaVersion: "1.4" - -runOnRequirements: - # This test requires retryable writes, failCommand appName, and - # failCommand blockConnection with closeConnection:true (SERVER-53512). - - minServerVersion: "4.9" - serverless: forbid - topologies: - - replicaset - - sharded - -createEntities: - - client: - id: &setupClient setupClient - useMultipleMongoses: false - -initialData: &initialData - - collectionName: &collectionName pool-cleared-error - databaseName: &databaseName sdam-tests - documents: [] - -tests: - - description: PoolClearedError does not mark server unknown - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - serverDescriptionChangedEvent - - poolClearedEvent - uriOptions: - retryWrites: true - maxPoolSize: 1 - appname: poolClearedErrorTest - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # Perform an operation to ensure the node is discovered. - - name: insertOne - object: *collection - arguments: - document: - _id: 1 - # Configure the next insert to fail with a network error which will - # clear the pool leaving it paused until the server is rediscovered. - - name: failPoint - object: testRunner - arguments: - failPoint: - configureFailPoint: failCommand - mode: - times: 1 - data: - failCommands: - - insert - blockConnection: true - blockTimeMS: 100 - closeConnection: true - appName: poolClearedErrorTest - client: *setupClient - # Start threads. - - name: createEntities - object: testRunner - arguments: - entities: - - thread: - id: &thread0 thread0 - - thread: - id: &thread1 thread1 - - thread: - id: &thread2 thread2 - - thread: - id: &thread3 thread3 - - thread: - id: &thread4 thread4 - - thread: - id: &thread5 thread5 - # Perform concurrent insert operations. The first one to execute will - # fail with a network error, mark the server Unknown, clear the pool, - # and retry. - # The other operations will either: - # - Notice the pool is paused, fail with a PoolClearedError, and retry. - # - Or block waiting in server selection until the server is - # rediscovered. - # - # Note that this test does not guarantee that a PoolClearedError will be - # raised but it is likely since the initial insert is delayed. - - name: runOnThread - object: testRunner - arguments: - thread: *thread0 - operation: - name: insertOne - object: *collection - arguments: - document: - _id: 2 - - name: runOnThread - object: testRunner - arguments: - thread: *thread1 - operation: - name: insertOne - object: *collection - arguments: - document: - _id: 3 - - name: runOnThread - object: testRunner - arguments: - thread: *thread2 - operation: - name: insertOne - object: *collection - arguments: - document: - _id: 4 - - name: runOnThread - object: testRunner - arguments: - thread: *thread3 - operation: - name: insertOne - object: *collection - arguments: - document: - _id: 5 - - name: runOnThread - object: testRunner - arguments: - thread: *thread4 - operation: - name: insertOne - object: *collection - arguments: - document: - _id: 6 - - name: runOnThread - object: testRunner - arguments: - thread: *thread5 - operation: - name: insertOne - object: *collection - arguments: - document: - _id: 7 - # Stop threads. - - name: waitForThread - object: testRunner - arguments: - thread: *thread0 - - name: waitForThread - object: testRunner - arguments: - thread: *thread1 - - name: waitForThread - object: testRunner - arguments: - thread: *thread2 - - name: waitForThread - object: testRunner - arguments: - thread: *thread3 - - name: waitForThread - object: testRunner - arguments: - thread: *thread4 - - name: waitForThread - object: testRunner - arguments: - thread: *thread5 - # The first shutdown error should mark the server Unknown and then clear - # the pool. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - # Perform an operation to ensure the node still useable. - - name: insertOne - object: *collection - arguments: - document: - _id: 8 - # Assert the server was marked Unknown and pool was cleared exactly once. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - serverDescriptionChangedEvent: - newDescription: - type: Unknown - count: 1 - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - - # Order of operations is non-deterministic so we cannot check events. - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 - - _id: 5 - - _id: 6 - - _id: 7 - - _id: 8 diff --git a/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json b/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json deleted file mode 100644 index 3147a07a1e..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json +++ /dev/null @@ -1,242 +0,0 @@ -{ - "description": "rediscover-quickly-after-step-down", - "schemaVersion": "1.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4", - "serverless": "forbid", - "topologies": [ - "replicaset" - ] - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient" - } - }, - { - "database": { - "id": "adminDatabase", - "client": "setupClient", - "databaseName": "admin" - } - } - ], - "initialData": [ - { - "collectionName": "test-replSetStepDown", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - ], - "tests": [ - { - "description": "Rediscover quickly after replSetStepDown", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeEvents": [ - "poolClearedEvent", - "commandStartedEvent" - ], - "uriOptions": { - "appname": "replSetStepDownTest", - "heartbeatFrequencyMS": 60000, - "serverSelectionTimeoutMS": 5000, - "w": "majority" - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "sdam-tests" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "test-replSetStepDown" - } - } - ] - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - }, - { - "name": "recordTopologyDescription", - "object": "testRunner", - "arguments": { - "client": "client", - "id": "topologyDescription" - } - }, - { - "name": "assertTopologyType", - "object": "testRunner", - "arguments": { - "topologyDescription": "topologyDescription", - "topologyType": "ReplicaSetWithPrimary" - } - }, - { - "name": "runCommand", - "object": "adminDatabase", - "arguments": { - "command": { - "replSetFreeze": 0 - }, - "readPreference": { - "mode": "secondary" - }, - "commandName": "replSetFreeze" - } - }, - { - "name": "runCommand", - "object": "adminDatabase", - "arguments": { - "command": { - "replSetStepDown": 30, - "secondaryCatchUpPeriodSecs": 30, - "force": false - }, - "commandName": "replSetStepDown" - } - }, - { - "name": "waitForPrimaryChange", - "object": "testRunner", - "arguments": { - "client": "client", - "priorTopologyDescription": "topologyDescription", - "timeoutMS": 15000 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - }, - { - "name": "assertEventCount", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 0 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "command", - "events": [ - { - "commandStartedEvent": { - "command": { - "insert": "test-replSetStepDown", - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - }, - { - "commandStartedEvent": { - "command": { - "insert": "test-replSetStepDown", - "documents": [ - { - "_id": 5 - }, - { - "_id": 6 - } - ] - }, - "commandName": "insert", - "databaseName": "sdam-tests" - } - } - ] - } - ], - "outcome": [ - { - "collectionName": "test-replSetStepDown", - "databaseName": "sdam-tests", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - }, - { - "_id": 5 - }, - { - "_id": 6 - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml b/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml deleted file mode 100644 index f3e7509160..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml +++ /dev/null @@ -1,144 +0,0 @@ ---- -description: rediscover-quickly-after-step-down - -schemaVersion: "1.4" - -runOnRequirements: - # 4.4 is required for streaming. - # A replica set is required for replSetStepDown. - - minServerVersion: "4.4" - serverless: forbid - topologies: - - replicaset - -createEntities: - - client: - id: &setupClient setupClient - - database: - id: &adminDatabase adminDatabase - client: *setupClient - databaseName: admin - -initialData: &initialData - - collectionName: &collectionName test-replSetStepDown - databaseName: &databaseName sdam-tests - documents: - - _id: 1 - - _id: 2 - -tests: - - description: Rediscover quickly after replSetStepDown - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - observeEvents: - - poolClearedEvent - - commandStartedEvent - uriOptions: - appname: replSetStepDownTest - # Configure a large heartbeatFrequencyMS - heartbeatFrequencyMS: 60000 - # Configure a much smaller server selection timeout so that the test - # will error when it cannot discover the new primary soon. - serverSelectionTimeoutMS: 5000 - w: majority - - database: - id: &database database - client: *client - databaseName: *databaseName - - collection: - id: &collection collection - database: *database - collectionName: *collectionName - # Discover the primary. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 3 - - _id: 4 - - name: recordTopologyDescription - object: testRunner - arguments: - client: *client - id: &topologyDescription topologyDescription - - name: assertTopologyType - object: testRunner - arguments: - topologyDescription: *topologyDescription - topologyType: ReplicaSetWithPrimary - # Unfreeze a secondary with replSetFreeze:0 to ensure a speedy election. - - name: runCommand - object: *adminDatabase - arguments: - command: - replSetFreeze: 0 - readPreference: - mode: secondary - commandName: replSetFreeze - # Run replSetStepDown on the meta client. - - name: runCommand - object: *adminDatabase - arguments: - command: - replSetStepDown: 30 - secondaryCatchUpPeriodSecs: 30 - force: false - commandName: replSetStepDown - - name: waitForPrimaryChange - object: testRunner - arguments: - client: *client - priorTopologyDescription: *topologyDescription - # We use a relatively large timeout here to workaround slow - # elections on Windows, possibly caused by SERVER-48154. - timeoutMS: 15000 - # Rediscover the new primary. - - name: insertMany - object: *collection - arguments: - documents: - - _id: 5 - - _id: 6 - # Assert that no pools were cleared. - - name: assertEventCount - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 0 - expectEvents: - - client: *client - eventType: command - events: - - commandStartedEvent: - command: - insert: test-replSetStepDown - documents: - - _id: 3 - - _id: 4 - commandName: insert - databaseName: *databaseName - - commandStartedEvent: - command: - insert: test-replSetStepDown - documents: - - _id: 5 - - _id: 6 - commandName: insert - databaseName: *databaseName - outcome: - - collectionName: *collectionName - databaseName: *databaseName - documents: - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 - - _id: 5 - - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.json b/test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.json deleted file mode 100644 index 7d681b4f9e..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.json +++ /dev/null @@ -1,449 +0,0 @@ -{ - "description": "serverMonitoringMode", - "schemaVersion": "1.17", - "runOnRequirements": [ - { - "topologies": [ - "single", - "sharded", - "sharded-replicaset" - ], - "serverless": "forbid" - } - ], - "tests": [ - { - "description": "connect with serverMonitoringMode=auto >=4.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4.0" - } - ], - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "uriOptions": { - "serverMonitoringMode": "auto" - }, - "useMultipleMongoses": false, - "observeEvents": [ - "serverHeartbeatStartedEvent", - "serverHeartbeatSucceededEvent", - "serverHeartbeatFailedEvent" - ] - } - }, - { - "database": { - "id": "db", - "client": "client", - "databaseName": "sdam-tests" - } - } - ] - } - }, - { - "name": "runCommand", - "object": "db", - "arguments": { - "commandName": "ping", - "command": { - "ping": 1 - } - }, - "expectResult": { - "ok": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverHeartbeatStartedEvent": {} - }, - "count": 2 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "sdam", - "ignoreExtraEvents": true, - "events": [ - { - "serverHeartbeatStartedEvent": { - "awaited": false - } - }, - { - "serverHeartbeatSucceededEvent": { - "awaited": false - } - }, - { - "serverHeartbeatStartedEvent": { - "awaited": true - } - } - ] - } - ] - }, - { - "description": "connect with serverMonitoringMode=auto <4.4", - "runOnRequirements": [ - { - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "uriOptions": { - "serverMonitoringMode": "auto", - "heartbeatFrequencyMS": 500 - }, - "useMultipleMongoses": false, - "observeEvents": [ - "serverHeartbeatStartedEvent", - "serverHeartbeatSucceededEvent", - "serverHeartbeatFailedEvent" - ] - } - }, - { - "database": { - "id": "db", - "client": "client", - "databaseName": "sdam-tests" - } - } - ] - } - }, - { - "name": "runCommand", - "object": "db", - "arguments": { - "commandName": "ping", - "command": { - "ping": 1 - } - }, - "expectResult": { - "ok": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverHeartbeatStartedEvent": {} - }, - "count": 2 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "sdam", - "ignoreExtraEvents": true, - "events": [ - { - "serverHeartbeatStartedEvent": { - "awaited": false - } - }, - { - "serverHeartbeatSucceededEvent": { - "awaited": false - } - }, - { - "serverHeartbeatStartedEvent": { - "awaited": false - } - } - ] - } - ] - }, - { - "description": "connect with serverMonitoringMode=stream >=4.4", - "runOnRequirements": [ - { - "minServerVersion": "4.4.0" - } - ], - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "uriOptions": { - "serverMonitoringMode": "stream" - }, - "useMultipleMongoses": false, - "observeEvents": [ - "serverHeartbeatStartedEvent", - "serverHeartbeatSucceededEvent", - "serverHeartbeatFailedEvent" - ] - } - }, - { - "database": { - "id": "db", - "client": "client", - "databaseName": "sdam-tests" - } - } - ] - } - }, - { - "name": "runCommand", - "object": "db", - "arguments": { - "commandName": "ping", - "command": { - "ping": 1 - } - }, - "expectResult": { - "ok": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverHeartbeatStartedEvent": {} - }, - "count": 2 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "sdam", - "ignoreExtraEvents": true, - "events": [ - { - "serverHeartbeatStartedEvent": { - "awaited": false - } - }, - { - "serverHeartbeatSucceededEvent": { - "awaited": false - } - }, - { - "serverHeartbeatStartedEvent": { - "awaited": true - } - } - ] - } - ] - }, - { - "description": "connect with serverMonitoringMode=stream <4.4", - "runOnRequirements": [ - { - "maxServerVersion": "4.2.99" - } - ], - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "uriOptions": { - "serverMonitoringMode": "stream", - "heartbeatFrequencyMS": 500 - }, - "useMultipleMongoses": false, - "observeEvents": [ - "serverHeartbeatStartedEvent", - "serverHeartbeatSucceededEvent", - "serverHeartbeatFailedEvent" - ] - } - }, - { - "database": { - "id": "db", - "client": "client", - "databaseName": "sdam-tests" - } - } - ] - } - }, - { - "name": "runCommand", - "object": "db", - "arguments": { - "commandName": "ping", - "command": { - "ping": 1 - } - }, - "expectResult": { - "ok": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverHeartbeatStartedEvent": {} - }, - "count": 2 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "sdam", - "ignoreExtraEvents": true, - "events": [ - { - "serverHeartbeatStartedEvent": { - "awaited": false - } - }, - { - "serverHeartbeatSucceededEvent": { - "awaited": false - } - }, - { - "serverHeartbeatStartedEvent": { - "awaited": false - } - } - ] - } - ] - }, - { - "description": "connect with serverMonitoringMode=poll", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "uriOptions": { - "serverMonitoringMode": "poll", - "heartbeatFrequencyMS": 500 - }, - "useMultipleMongoses": false, - "observeEvents": [ - "serverHeartbeatStartedEvent", - "serverHeartbeatSucceededEvent", - "serverHeartbeatFailedEvent" - ] - } - }, - { - "database": { - "id": "db", - "client": "client", - "databaseName": "sdam-tests" - } - } - ] - } - }, - { - "name": "runCommand", - "object": "db", - "arguments": { - "commandName": "ping", - "command": { - "ping": 1 - } - }, - "expectResult": { - "ok": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverHeartbeatStartedEvent": {} - }, - "count": 2 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "sdam", - "ignoreExtraEvents": true, - "events": [ - { - "serverHeartbeatStartedEvent": { - "awaited": false - } - }, - { - "serverHeartbeatSucceededEvent": { - "awaited": false - } - }, - { - "serverHeartbeatStartedEvent": { - "awaited": false - } - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.yml b/test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.yml deleted file mode 100644 index 28c7853d04..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.yml +++ /dev/null @@ -1,173 +0,0 @@ -description: serverMonitoringMode - -schemaVersion: "1.17" -# These tests cannot run on replica sets because the order of the expected -# SDAM events are non-deterministic when monitoring multiple servers. -# They also cannot run on Serverless or load balanced clusters where SDAM is disabled. -runOnRequirements: - - topologies: [single, sharded, sharded-replicaset] - serverless: forbid -tests: - - description: "connect with serverMonitoringMode=auto >=4.4" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: client - uriOptions: - serverMonitoringMode: "auto" - useMultipleMongoses: false - observeEvents: - - serverHeartbeatStartedEvent - - serverHeartbeatSucceededEvent - - serverHeartbeatFailedEvent - - database: - id: db - client: client - databaseName: sdam-tests - - &ping - name: runCommand - object: db - arguments: - commandName: ping - command: { ping: 1 } - expectResult: { ok: 1 } - # Wait for the second serverHeartbeatStartedEvent to ensure we start streaming. - - &waitForSecondHeartbeatStarted - name: waitForEvent - object: testRunner - arguments: - client: client - event: - serverHeartbeatStartedEvent: {} - count: 2 - expectEvents: &streamingStartedEvents - - client: client - eventType: sdam - ignoreExtraEvents: true - events: - - serverHeartbeatStartedEvent: - awaited: False - - serverHeartbeatSucceededEvent: - awaited: False - - serverHeartbeatStartedEvent: - awaited: True - - - description: "connect with serverMonitoringMode=auto <4.4" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: client - uriOptions: - serverMonitoringMode: "auto" - heartbeatFrequencyMS: 500 - useMultipleMongoses: false - observeEvents: - - serverHeartbeatStartedEvent - - serverHeartbeatSucceededEvent - - serverHeartbeatFailedEvent - - database: - id: db - client: client - databaseName: sdam-tests - - *ping - # Wait for the second serverHeartbeatStartedEvent to ensure we do not stream. - - *waitForSecondHeartbeatStarted - expectEvents: &pollingStartedEvents - - client: client - eventType: sdam - ignoreExtraEvents: true - events: - - serverHeartbeatStartedEvent: - awaited: False - - serverHeartbeatSucceededEvent: - awaited: False - - serverHeartbeatStartedEvent: - awaited: False - - - description: "connect with serverMonitoringMode=stream >=4.4" - runOnRequirements: - - minServerVersion: "4.4.0" - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: client - uriOptions: - serverMonitoringMode: "stream" - useMultipleMongoses: false - observeEvents: - - serverHeartbeatStartedEvent - - serverHeartbeatSucceededEvent - - serverHeartbeatFailedEvent - - database: - id: db - client: client - databaseName: sdam-tests - - *ping - # Wait for the second serverHeartbeatStartedEvent to ensure we start streaming. - - *waitForSecondHeartbeatStarted - expectEvents: *streamingStartedEvents - - - description: "connect with serverMonitoringMode=stream <4.4" - runOnRequirements: - - maxServerVersion: "4.2.99" - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: client - uriOptions: - serverMonitoringMode: "stream" - heartbeatFrequencyMS: 500 - useMultipleMongoses: false - observeEvents: - - serverHeartbeatStartedEvent - - serverHeartbeatSucceededEvent - - serverHeartbeatFailedEvent - - database: - id: db - client: client - databaseName: sdam-tests - - *ping - # Wait for the second serverHeartbeatStartedEvent to ensure we do not stream. - - *waitForSecondHeartbeatStarted - expectEvents: *pollingStartedEvents - - - description: "connect with serverMonitoringMode=poll" - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: client - uriOptions: - serverMonitoringMode: "poll" - heartbeatFrequencyMS: 500 - useMultipleMongoses: false - observeEvents: - - serverHeartbeatStartedEvent - - serverHeartbeatSucceededEvent - - serverHeartbeatFailedEvent - - database: - id: db - client: client - databaseName: sdam-tests - - *ping - # Wait for the second serverHeartbeatStartedEvent to ensure we do not stream. - - *waitForSecondHeartbeatStarted - expectEvents: *pollingStartedEvents diff --git a/test/tools/unified-spec-runner/entities.ts b/test/tools/unified-spec-runner/entities.ts index 3c0b2b9aaa..5890f6a286 100644 --- a/test/tools/unified-spec-runner/entities.ts +++ b/test/tools/unified-spec-runner/entities.ts @@ -32,11 +32,16 @@ import { ReadConcern, ReadPreference, SENSITIVE_COMMANDS, + type ServerClosedEvent, type ServerDescriptionChangedEvent, type ServerHeartbeatFailedEvent, type ServerHeartbeatStartedEvent, type ServerHeartbeatSucceededEvent, + type ServerOpeningEvent, + type TopologyClosedEvent, type TopologyDescription, + type TopologyDescriptionChangedEvent, + type TopologyOpeningEvent, WriteConcern } from '../../mongodb'; import { ejson, getEnvironmentalOptions } from '../../tools/utils'; @@ -104,7 +109,12 @@ export type SdamEvent = | ServerDescriptionChangedEvent | ServerHeartbeatStartedEvent | ServerHeartbeatFailedEvent - | ServerHeartbeatSucceededEvent; + | ServerHeartbeatSucceededEvent + | TopologyOpeningEvent + | TopologyDescriptionChangedEvent + | TopologyClosedEvent + | ServerOpeningEvent + | ServerClosedEvent; export type LogMessage = Omit; function getClient(address) { @@ -134,10 +144,15 @@ export class UnifiedMongoClient extends MongoClient { | 'connectionCheckedIn' )[]; observedSdamEvents: ( - | 'serverDescriptionChangedEvent' - | 'serverHeartbeatStartedEvent' - | 'serverHeartbeatFailedEvent' - | 'serverHeartbeatSucceededEvent' + | 'serverDescriptionChanged' + | 'serverHeartbeatStarted' + | 'serverHeartbeatFailed' + | 'serverHeartbeatSucceeded' + | 'serverOpened' + | 'serverClosed' + | 'topologyOpened' + | 'topologyClosed' + | 'topologyDescriptionChangedEvent' )[]; observedEventEmitter = new EventEmitter(); _credentials: MongoCredentials | null; @@ -166,7 +181,12 @@ export class UnifiedMongoClient extends MongoClient { serverDescriptionChangedEvent: 'serverDescriptionChanged', serverHeartbeatStartedEvent: 'serverHeartbeatStarted', serverHeartbeatFailedEvent: 'serverHeartbeatFailed', - serverHeartbeatSucceededEvent: 'serverHeartbeatSucceeded' + serverHeartbeatSucceededEvent: 'serverHeartbeatSucceeded', + serverOpeningEvent: 'serverOpening', + serverClosedEvent: 'serverClosed', + topologyOpeningEvent: 'topologyOpening', + topologyClosedEvent: 'topologyClosed', + topologyDescriptionChangedEvent: 'topologyDescriptionChanged' } as const; static LOGGING_COMPONENT_TO_ENV_VAR_NAME = { diff --git a/test/tools/unified-spec-runner/match.ts b/test/tools/unified-spec-runner/match.ts index 3267df42b6..70bb8a3593 100644 --- a/test/tools/unified-spec-runner/match.ts +++ b/test/tools/unified-spec-runner/match.ts @@ -26,10 +26,15 @@ import { MongoServerError, ObjectId, type OneOrMore, + ServerClosedEvent, ServerDescriptionChangedEvent, ServerHeartbeatFailedEvent, ServerHeartbeatStartedEvent, - ServerHeartbeatSucceededEvent + ServerHeartbeatSucceededEvent, + ServerOpeningEvent, + TopologyClosedEvent, + TopologyDescriptionChangedEvent, + TopologyOpeningEvent } from '../../mongodb'; import { ejson } from '../utils'; import { type CmapEvent, type CommandEvent, type EntitiesMap, type SdamEvent } from './entities'; @@ -561,6 +566,41 @@ function compareEvents( expect(actualEvent[property]).to.equal(expectedSdamEvent[property]); } return; + } else if (expectedEvent.serverOpeningEvent) { + expect(actualEvent).to.be.instanceOf(ServerOpeningEvent); + const expectedSdamEvent = expectedEvent.serverOpeningEvent; + for (const property of Object.keys(expectedSdamEvent)) { + expect(actualEvent[property]).to.equal(expectedSdamEvent[property]); + } + return; + } else if (expectedEvent.serverClosedEvent) { + expect(actualEvent).to.be.instanceOf(ServerClosedEvent); + const expectedSdamEvent = expectedEvent.serverClosedEvent; + for (const property of Object.keys(expectedSdamEvent)) { + expect(actualEvent[property]).to.equal(expectedSdamEvent[property]); + } + return; + } else if (expectedEvent.topologyOpeningEvent) { + expect(actualEvent).to.be.instanceOf(TopologyOpeningEvent); + const expectedSdamEvent = expectedEvent.topologyOpeningEvent; + for (const property of Object.keys(expectedSdamEvent)) { + expect(actualEvent[property]).to.equal(expectedSdamEvent[property]); + } + return; + } else if (expectedEvent.topologyClosingEvent) { + expect(actualEvent).to.be.instanceOf(TopologyClosedEvent); + const expectedSdamEvent = expectedEvent.topologyClosingEvent; + for (const property of Object.keys(expectedSdamEvent)) { + expect(actualEvent[property]).to.equal(expectedSdamEvent[property]); + } + return; + } else if (expectedEvent.topologyDescriptionChangedEvent) { + expect(actualEvent).to.be.instanceOf(TopologyDescriptionChangedEvent); + const expectedSdamEvent = expectedEvent.topologyDescriptionChangedEvent; + for (const property of Object.keys(expectedSdamEvent)) { + expect(actualEvent[property]).to.equal(expectedSdamEvent[property]); + } + return; } else { expect.fail(`Encountered unexpected event - ${inspect(actualEvent)}`); } diff --git a/test/tools/unified-spec-runner/schema.ts b/test/tools/unified-spec-runner/schema.ts index 5fac932d74..cefec5c560 100644 --- a/test/tools/unified-spec-runner/schema.ts +++ b/test/tools/unified-spec-runner/schema.ts @@ -129,12 +129,22 @@ export type ObservableCmapEventId = | 'connectionCheckOutFailedEvent' | 'connectionCheckedOutEvent' | 'connectionCheckedInEvent'; +export type ObservableSdamEventId = + | 'serverDescriptionChangedEvent' + | 'serverHeartbeatStartedEvent' + | 'serverHeartbeatFailedEvent' + | 'serverHeartbeatSucceededEvent' + | 'topologyOpeningEvent' + | 'topologyDescriptionChangedEvent' + | 'topologyClosedEvent' + | 'serverOpeningEvent' + | 'serverClosedEvent'; export interface ClientEntity { id: string; uriOptions?: Document; useMultipleMongoses?: boolean; - observeEvents?: (ObservableCommandEventId | ObservableCmapEventId)[]; + observeEvents?: (ObservableCommandEventId | ObservableCmapEventId | ObservableSdamEventId)[]; observeLogMessages?: Record; ignoreCommandMonitoringEvents?: string[]; serverApi?: ServerApi; @@ -315,8 +325,30 @@ export interface ExpectedSdamEvent { awaited?: boolean; }; serverHeartbeatSucceededEvent?: { + topologyId?: any; awaited?: boolean; }; + topologyDescriptionChangedEvent?: { + topologyId?: any; + previousDescription?: { + type?: string; + }; + newDescription?: { + type?: string; + }; + }; + topologyOpeningEvent?: { + topologyId?: any; + }; + topologyClosingEvent?: { + topologyId?: any; + }; + serverOpeningEvent?: { + topologyId?: any; + }; + serverClosedEvent?: { + topologyId?: any; + }; } export interface StoreEventsAsEntity { id: string; From f2c9e846f45a5aadc8255ccd036a5153928df990 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Tue, 5 Dec 2023 10:48:53 -0500 Subject: [PATCH 05/22] spec runner changes working, may need to add filter to logs --- .../unified/auth-error.json | 230 +++++++ .../unified/auth-error.yml | 130 ++++ .../unified/auth-misc-command-error.json | 230 +++++++ .../unified/auth-misc-command-error.yml | 132 ++++ .../unified/auth-network-error.json | 230 +++++++ .../unified/auth-network-error.yml | 132 ++++ .../unified/auth-network-timeout-error.json | 233 +++++++ .../unified/auth-network-timeout-error.yml | 138 ++++ .../unified/auth-shutdown-error.json | 230 +++++++ .../unified/auth-shutdown-error.yml | 133 ++++ .../unified/cancel-server-check.json | 201 ++++++ .../unified/cancel-server-check.yml | 143 +++++ .../unified/connectTimeoutMS.json | 221 +++++++ .../unified/connectTimeoutMS.yml | 130 ++++ .../unified/find-network-error.json | 234 +++++++ .../unified/find-network-error.yml | 135 ++++ .../unified/find-network-timeout-error.json | 199 ++++++ .../unified/find-network-timeout-error.yml | 119 ++++ .../unified/find-shutdown-error.json | 251 ++++++++ .../unified/find-shutdown-error.yml | 163 +++++ .../unified/hello-command-error.json | 376 +++++++++++ .../unified/hello-command-error.yml | 233 +++++++ .../unified/hello-network-error.json | 346 ++++++++++ .../unified/hello-network-error.yml | 227 +++++++ .../unified/hello-timeout.json | 514 +++++++++++++++ .../unified/hello-timeout.yml | 318 +++++++++ .../unified/insert-network-error.json | 246 +++++++ .../unified/insert-network-error.yml | 137 ++++ .../unified/insert-shutdown-error.json | 250 ++++++++ .../unified/insert-shutdown-error.yml | 162 +++++ .../unified/interruptInUse-pool-clear.json | 591 +++++++++++++++++ .../unified/interruptInUse-pool-clear.yml | 341 ++++++++++ .../unified/logging-loadbalanced.json | 150 +++++ .../unified/logging-loadbalanced.yml | 74 +++ .../unified/logging-replicaset.json | 606 ++++++++++++++++++ .../unified/logging-replicaset.yml | 289 +++++++++ .../unified/logging-sharded.json | 492 ++++++++++++++ .../unified/logging-sharded.yml | 248 +++++++ .../unified/minPoolSize-error.json | 177 +++++ .../unified/minPoolSize-error.yml | 125 ++++ .../unified/pool-cleared-error.json | 373 +++++++++++ .../unified/pool-cleared-error.yml | 239 +++++++ .../rediscover-quickly-after-step-down.json | 242 +++++++ .../rediscover-quickly-after-step-down.yml | 144 +++++ .../unified/serverMonitoringMode.json | 449 +++++++++++++ .../unified/serverMonitoringMode.yml | 173 +++++ 46 files changed, 11136 insertions(+) create mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-network-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-network-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/cancel-server-check.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/cancel-server-check.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/find-network-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/find-network-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/hello-command-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/hello-command-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/hello-network-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/hello-network-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/hello-timeout.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/hello-timeout.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/insert-network-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/insert-network-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-sharded.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml create mode 100644 test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.json create mode 100644 test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.yml diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-error.json new file mode 100644 index 0000000000..62d26494c7 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/auth-error.json @@ -0,0 +1,230 @@ +{ + "description": "auth-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "auth": true, + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "auth-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "Reset server and pool after AuthenticationFailure error", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "saslContinue" + ], + "appName": "authErrorTest", + "errorCode": 18 + } + } + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "appname": "authErrorTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "auth-error" + } + } + ] + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "expectError": { + "isError": true + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "auth-error", + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "auth-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-error.yml new file mode 100644 index 0000000000..febf4a46dc --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/auth-error.yml @@ -0,0 +1,130 @@ +description: auth-error + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.4" + auth: true + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName auth-error + databaseName: &databaseName sdam-tests + documents: + - _id: 1 + - _id: 2 +tests: + - description: Reset server and pool after AuthenticationFailure error + operations: + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 1 + data: + failCommands: + - saslContinue + appName: authErrorTest + errorCode: 18 + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + appname: authErrorTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + expectError: + isError: true + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform another operation to ensure the node is rediscovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 5 + - _id: 6 + # Assert the server was marked Unknown and pool was cleared exactly once. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + expectEvents: + # Note: The first insert command is never attempted because connection + # checkout fails. + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: auth-error + documents: + - _id: 5 + - _id: 6 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 5 + - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.json new file mode 100644 index 0000000000..fd62fe604e --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.json @@ -0,0 +1,230 @@ +{ + "description": "auth-misc-command-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "auth": true, + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "auth-misc-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "Reset server and pool after misc command error", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "saslContinue" + ], + "appName": "authMiscErrorTest", + "errorCode": 1 + } + } + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "appname": "authMiscErrorTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "auth-misc-error" + } + } + ] + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "expectError": { + "isError": true + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "auth-misc-error", + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "auth-misc-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.yml new file mode 100644 index 0000000000..9969ca92d4 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/auth-misc-command-error.yml @@ -0,0 +1,132 @@ +--- +description: auth-misc-command-error + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.4" + auth: true + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName auth-misc-error + databaseName: &databaseName sdam-tests + documents: + - _id: 1 + - _id: 2 + +tests: + - description: Reset server and pool after misc command error + operations: + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 1 + data: + failCommands: + - saslContinue + appName: authMiscErrorTest + errorCode: 1 # InternalError + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + appname: authMiscErrorTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + expectError: + isError: true + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform another operation to ensure the node is rediscovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 5 + - _id: 6 + # Assert the server was marked Unknown and pool was cleared exactly once. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + expectEvents: + # Note: The first insert command is never attempted because connection + # checkout fails. + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: auth-misc-error + documents: + - _id: 5 + - _id: 6 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 5 + - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-network-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-network-error.json new file mode 100644 index 0000000000..84763af32e --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/auth-network-error.json @@ -0,0 +1,230 @@ +{ + "description": "auth-network-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "auth": true, + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "auth-network-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "Reset server and pool after network error during authentication", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "saslContinue" + ], + "closeConnection": true, + "appName": "authNetworkErrorTest" + } + } + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "appname": "authNetworkErrorTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "auth-network-error" + } + } + ] + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "expectError": { + "isError": true + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "auth-network-error", + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "auth-network-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-network-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-network-error.yml new file mode 100644 index 0000000000..cdf77c56df --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/auth-network-error.yml @@ -0,0 +1,132 @@ +--- +description: auth-network-error + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.4" + auth: true + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName auth-network-error + databaseName: &databaseName sdam-tests + documents: + - _id: 1 + - _id: 2 + +tests: + - description: Reset server and pool after network error during authentication + operations: + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 1 + data: + failCommands: + - saslContinue + closeConnection: true + appName: authNetworkErrorTest + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + appname: authNetworkErrorTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + expectError: + isError: true + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform another operation to ensure the node is rediscovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 5 + - _id: 6 + # Assert the server was marked Unknown and pool was cleared exactly once. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + expectEvents: + # Note: The first insert command is never attempted because connection + # checkout fails. + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: auth-network-error + documents: + - _id: 5 + - _id: 6 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 5 + - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.json new file mode 100644 index 0000000000..3cf9576eba --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.json @@ -0,0 +1,233 @@ +{ + "description": "auth-network-timeout-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "auth": true, + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "auth-network-timeout-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "Reset server and pool after network timeout error during authentication", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "saslContinue" + ], + "blockConnection": true, + "blockTimeMS": 500, + "appName": "authNetworkTimeoutErrorTest" + } + } + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "appname": "authNetworkTimeoutErrorTest", + "connectTimeoutMS": 250, + "socketTimeoutMS": 250 + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "auth-network-timeout-error" + } + } + ] + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "expectError": { + "isError": true + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "auth-network-timeout-error", + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "auth-network-timeout-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.yml new file mode 100644 index 0000000000..49b91d8373 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/auth-network-timeout-error.yml @@ -0,0 +1,138 @@ +--- +description: auth-network-timeout-error + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.4" + auth: true + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName auth-network-timeout-error + databaseName: &databaseName sdam-tests + documents: + - _id: 1 + - _id: 2 + +tests: + - description: Reset server and pool after network timeout error during authentication + operations: + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 1 + data: + failCommands: + - saslContinue + blockConnection: true + blockTimeMS: 500 + appName: authNetworkTimeoutErrorTest + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + appname: authNetworkTimeoutErrorTest + # Set a short connect/socket timeout to ensure the fail point causes the + # connection establishment to timeout. + connectTimeoutMS: 250 + socketTimeoutMS: 250 + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + expectError: + isError: true + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform another operation to ensure the node is rediscovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 5 + - _id: 6 + # Assert the server was marked Unknown and pool was cleared exactly once. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + expectEvents: + # Note: The first insert command is never attempted because connection + # checkout fails. + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: auth-network-timeout-error + documents: + - _id: 5 + - _id: 6 + commandName: insert + databaseName: *databaseName + + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 5 + - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.json b/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.json new file mode 100644 index 0000000000..b9e503af66 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.json @@ -0,0 +1,230 @@ +{ + "description": "auth-shutdown-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "auth": true, + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "auth-shutdown-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "Reset server and pool after shutdown error during authentication", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "saslContinue" + ], + "appName": "authShutdownErrorTest", + "errorCode": 91 + } + } + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "appname": "authShutdownErrorTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "auth-shutdown-error" + } + } + ] + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "expectError": { + "isError": true + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "auth-shutdown-error", + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "auth-shutdown-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.yml b/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.yml new file mode 100644 index 0000000000..f0bb4d17df --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/auth-shutdown-error.yml @@ -0,0 +1,133 @@ +--- +description: auth-shutdown-error + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.4" + auth: true + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName auth-shutdown-error + databaseName: &databaseName sdam-tests + documents: + - _id: 1 + - _id: 2 + +tests: + - description: Reset server and pool after shutdown error during authentication + operations: + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 1 + data: + failCommands: + - saslContinue + appName: authShutdownErrorTest + errorCode: 91 + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + appname: authShutdownErrorTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + expectError: + isError: true + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform another operation to ensure the node is rediscovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 5 + - _id: 6 + # Assert the server was marked Unknown and pool was cleared exactly once. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + expectEvents: + # Note: The first insert command is never attempted because connection + # checkout fails. + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: auth-shutdown-error + documents: + - _id: 5 + - _id: 6 + commandName: insert + databaseName: *databaseName + + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 5 + - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.json b/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.json new file mode 100644 index 0000000000..a60ccfcb41 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.json @@ -0,0 +1,201 @@ +{ + "description": "cancel-server-check", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ], + "serverless": "forbid" + }, + { + "minServerVersion": "4.2", + "topologies": [ + "sharded" + ], + "serverless": "forbid" + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "cancel-server-check", + "databaseName": "sdam-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "Cancel server check", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": true, + "heartbeatFrequencyMS": 10000, + "serverSelectionTimeoutMS": 5000, + "appname": "cancelServerCheckTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "cancel-server-check" + } + } + ] + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 1 + } + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "insert" + ], + "closeConnection": true + } + }, + "client": "setupClient" + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 2 + } + }, + "expectResult": { + "insertedId": 2 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 3 + } + }, + "expectResult": { + "insertedId": 3 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + } + ], + "outcome": [ + { + "collectionName": "cancel-server-check", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.yml b/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.yml new file mode 100644 index 0000000000..af46792546 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/cancel-server-check.yml @@ -0,0 +1,143 @@ +--- +description: cancel-server-check + +schemaVersion: "1.4" + +runOnRequirements: + # General failCommand requirements (this file does not use appName + # with failCommand). + - minServerVersion: "4.0" + topologies: + - replicaset + serverless: forbid + - minServerVersion: "4.2" + topologies: + - sharded + serverless: forbid + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName cancel-server-check + databaseName: &databaseName sdam-tests + documents: [] + +tests: + - description: Cancel server check + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: true + heartbeatFrequencyMS: 10000 + # Server selection timeout MUST be less than heartbeatFrequencyMS for + # this test. This setting ensures that the retried insert will fail + # after 5 seconds if the driver does not properly cancel the in progress + # check. + serverSelectionTimeoutMS: 5000 + appname: cancelServerCheckTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Perform an operation to ensure the node is discovered. + - name: insertOne + object: *collection + arguments: + document: + _id: 1 + # Configure the next inserts to fail with a non-timeout network error. + # This should: + # 1) Mark the server Unknown + # 2) Clear the connection pool + # 3) Cancel the in progress hello or legacy hello check and close the Monitor + # connection + # 4) The write will be then we retried, server selection will request an + # immediate check, and block for ~500ms until the next Monitor check + # proceeds. + # 5) The write will succeed on the second attempt. + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: + times: 1 + data: + failCommands: + - insert + closeConnection: true + client: *setupClient + - name: insertOne + object: *collection + arguments: + document: + _id: 2 + expectResult: + insertedId: 2 + # The first error should mark the server Unknown and then clear the pool. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform another operation to ensure the node still selectable. + - name: insertOne + object: *collection + arguments: + document: + _id: 3 + expectResult: + insertedId: 3 + # Assert the server was marked Unknown and pool was cleared exactly once. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + + # Order of operations is non-deterministic so we cannot check events. + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 3 diff --git a/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.json b/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.json new file mode 100644 index 0000000000..d3e860a9cb --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.json @@ -0,0 +1,221 @@ +{ + "description": "connectTimeoutMS", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "connectTimeoutMS", + "databaseName": "sdam-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "connectTimeoutMS=0", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "connectTimeoutMS": 0, + "heartbeatFrequencyMS": 500, + "appname": "connectTimeoutMS=0" + }, + "useMultipleMongoses": false + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "connectTimeoutMS" + } + } + ] + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "connectTimeoutMS=0", + "blockConnection": true, + "blockTimeMS": 550 + } + }, + "client": "setupClient" + } + }, + { + "name": "wait", + "object": "testRunner", + "arguments": { + "ms": 750 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 0 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 0 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "connectTimeoutMS", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "connectTimeoutMS", + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "connectTimeoutMS", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.yml b/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.yml new file mode 100644 index 0000000000..7c610623eb --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/connectTimeoutMS.yml @@ -0,0 +1,130 @@ +--- +description: connectTimeoutMS + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.4" + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName connectTimeoutMS + databaseName: &databaseName sdam-tests + documents: [] + +tests: + - description: connectTimeoutMS=0 + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + connectTimeoutMS: 0 + heartbeatFrequencyMS: 500 + appname: connectTimeoutMS=0 + useMultipleMongoses: false + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Perform an operation to ensure the node is discovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 1 + - _id: 2 + # Block the next streaming hello check for longer than + # heartbeatFrequencyMS to ensure that the connection timeout remains + # unlimited. + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: + times: 2 + data: + failCommands: + - hello + - isMaster + appName: connectTimeoutMS=0 + blockConnection: true + blockTimeMS: 550 + client: *setupClient + - name: wait + object: testRunner + arguments: + ms: 750 + # Perform an operation to ensure the node is still selectable. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + # Assert that the server was never marked Unknown and the pool was never + # cleared. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 0 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 0 + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: connectTimeoutMS + documents: + - _id: 1 + - _id: 2 + commandName: insert + databaseName: *databaseName + - commandStartedEvent: + command: + insert: connectTimeoutMS + documents: + - _id: 3 + - _id: 4 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 3 + - _id: 4 diff --git a/test/spec/server-discovery-and-monitoring/unified/find-network-error.json b/test/spec/server-discovery-and-monitoring/unified/find-network-error.json new file mode 100644 index 0000000000..c1b6db40ca --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/find-network-error.json @@ -0,0 +1,234 @@ +{ + "description": "find-network-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "find-network-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "Reset server and pool after network error on find", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "find" + ], + "closeConnection": true, + "appName": "findNetworkErrorTest" + } + } + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "retryReads": false, + "appname": "findNetworkErrorTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "find-network-error" + } + } + ] + } + }, + { + "name": "find", + "object": "collection", + "arguments": { + "filter": { + "_id": 1 + } + }, + "expectError": { + "isError": true + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "find-network-error" + }, + "commandName": "find", + "databaseName": "sdam-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "find-network-error", + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "find-network-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/find-network-error.yml b/test/spec/server-discovery-and-monitoring/unified/find-network-error.yml new file mode 100644 index 0000000000..f97d799a2a --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/find-network-error.yml @@ -0,0 +1,135 @@ +--- +description: find-network-error + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.4" + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName find-network-error + databaseName: &databaseName sdam-tests + documents: + - _id: 1 + - _id: 2 + +tests: + - description: Reset server and pool after network error on find + operations: + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 1 + data: + failCommands: + - find + closeConnection: true + appName: findNetworkErrorTest + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + retryReads: false + appname: findNetworkErrorTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + - name: find + object: *collection + arguments: + filter: + _id: 1 + expectError: + isError: true + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform another operation to ensure the node is rediscovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 5 + - _id: 6 + # Assert the server was marked Unknown and pool was cleared exactly once. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + find: find-network-error + commandName: find + databaseName: *databaseName + - commandStartedEvent: + command: + insert: find-network-error + documents: + - _id: 5 + - _id: 6 + commandName: insert + databaseName: *databaseName + + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 5 + - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.json b/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.json new file mode 100644 index 0000000000..e5ac9f21aa --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.json @@ -0,0 +1,199 @@ +{ + "description": "find-network-timeout-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "find-network-timeout-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "Ignore network timeout error on find", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "find" + ], + "blockConnection": true, + "blockTimeMS": 500, + "appName": "findNetworkTimeoutErrorTest" + } + } + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "retryReads": false, + "appname": "findNetworkTimeoutErrorTest", + "socketTimeoutMS": 250 + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "find-network-timeout-error" + } + } + ] + } + }, + { + "name": "find", + "object": "collection", + "arguments": { + "filter": { + "_id": 1 + } + }, + "expectError": { + "isError": true + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 3 + } + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 0 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 0 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "find-network-timeout-error" + }, + "commandName": "find", + "databaseName": "sdam-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "find-network-timeout-error", + "documents": [ + { + "_id": 3 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "find-network-timeout-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.yml b/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.yml new file mode 100644 index 0000000000..e00b7a2be0 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/find-network-timeout-error.yml @@ -0,0 +1,119 @@ +--- +description: find-network-timeout-error + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.4" + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName find-network-timeout-error + databaseName: &databaseName sdam-tests + documents: + - _id: 1 + - _id: 2 + +tests: + - description: Ignore network timeout error on find + operations: + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 1 + data: + failCommands: + - find + blockConnection: true + blockTimeMS: 500 + appName: findNetworkTimeoutErrorTest + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + retryReads: false + appname: findNetworkTimeoutErrorTest + # Set a short socket timeout to ensure the find command times out. + socketTimeoutMS: 250 + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + - name: find + object: *collection + arguments: + filter: + _id: 1 + expectError: + isError: true + # Perform another operation to ensure the node is still usable. + - name: insertOne + object: *collection + arguments: + document: + _id: 3 + # Assert the server was not marked Unknown and the pool was not cleared. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 0 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 0 + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + find: find-network-timeout-error + commandName: find + databaseName: *databaseName + - commandStartedEvent: + command: + insert: find-network-timeout-error + documents: + - _id: 3 + commandName: insert + databaseName: *databaseName + + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 3 diff --git a/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.json b/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.json new file mode 100644 index 0000000000..6e5a2cac05 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.json @@ -0,0 +1,251 @@ +{ + "description": "find-shutdown-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "find-shutdown-error", + "databaseName": "sdam-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "Concurrent shutdown error on find", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "uriOptions": { + "retryWrites": false, + "retryReads": false, + "heartbeatFrequencyMS": 500, + "appname": "shutdownErrorFindTest" + }, + "observeEvents": [ + "serverDescriptionChangedEvent", + "poolClearedEvent" + ] + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "find-shutdown-error" + } + } + ] + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 1 + } + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "find" + ], + "appName": "shutdownErrorFindTest", + "errorCode": 91, + "blockConnection": true, + "blockTimeMS": 500 + } + }, + "client": "setupClient" + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "thread": { + "id": "thread0" + } + }, + { + "thread": { + "id": "thread1" + } + } + ] + } + }, + { + "name": "runOnThread", + "object": "testRunner", + "arguments": { + "thread": "thread0", + "operation": { + "name": "find", + "object": "collection", + "arguments": { + "filter": { + "_id": 1 + } + }, + "expectError": { + "isError": true + } + } + } + }, + { + "name": "runOnThread", + "object": "testRunner", + "arguments": { + "thread": "thread1", + "operation": { + "name": "find", + "object": "collection", + "arguments": { + "filter": { + "_id": 1 + } + }, + "expectError": { + "isError": true + } + } + } + }, + { + "name": "waitForThread", + "object": "testRunner", + "arguments": { + "thread": "thread0" + } + }, + { + "name": "waitForThread", + "object": "testRunner", + "arguments": { + "thread": "thread1" + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 4 + } + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + } + ], + "outcome": [ + { + "collectionName": "find-shutdown-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 4 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.yml b/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.yml new file mode 100644 index 0000000000..395215244b --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/find-shutdown-error.yml @@ -0,0 +1,163 @@ +--- +description: find-shutdown-error + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.4" + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName find-shutdown-error + databaseName: &databaseName sdam-tests + documents: [] + +tests: + - description: Concurrent shutdown error on find + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + uriOptions: + retryWrites: false + retryReads: false + heartbeatFrequencyMS: 500 + appname: shutdownErrorFindTest + observeEvents: + - serverDescriptionChangedEvent + - poolClearedEvent + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Perform an operation to ensure the node is discovered. + - name: insertOne + object: *collection + arguments: + document: + _id: 1 + # Configure the next two finds to fail with a non-timeout shutdown + # errors. Block the connection for 500ms to ensure both operations check + # out connections from the same pool generation. + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: + times: 2 + data: + failCommands: + - find + appName: shutdownErrorFindTest + errorCode: 91 + blockConnection: true + blockTimeMS: 500 + client: *setupClient + # Start threads. + - name: createEntities + object: testRunner + arguments: + entities: + - thread: + id: &thread0 thread0 + - thread: + id: &thread1 thread1 + # Perform concurrent find operations. Both fail with shutdown errors. + - name: runOnThread + object: testRunner + arguments: + thread: *thread0 + operation: + name: find + object: *collection + arguments: + filter: + _id: 1 + expectError: + isError: true + - name: runOnThread + object: testRunner + arguments: + thread: *thread1 + operation: + name: find + object: *collection + arguments: + filter: + _id: 1 + expectError: + isError: true + # Stop threads. + - name: waitForThread + object: testRunner + arguments: + thread: *thread0 + - name: waitForThread + object: testRunner + arguments: + thread: *thread1 + # The first shutdown error should mark the server Unknown and then clear + # the pool. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform an operation to ensure the node is rediscovered. + - name: insertOne + object: *collection + arguments: + document: + _id: 4 + # Assert the server was marked Unknown and pool was cleared exactly once. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + + # Order of operations is non-deterministic so we cannot check events. + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 4 diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-command-error.json b/test/spec/server-discovery-and-monitoring/unified/hello-command-error.json new file mode 100644 index 0000000000..9afea87e77 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/hello-command-error.json @@ -0,0 +1,376 @@ +{ + "description": "hello-command-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.9", + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "hello-command-error", + "databaseName": "sdam-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "Command error on Monitor handshake", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 4 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "commandErrorHandshakeTest", + "closeConnection": false, + "errorCode": 91 + } + } + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "serverDescriptionChangedEvent", + "poolClearedEvent", + "commandStartedEvent" + ], + "uriOptions": { + "retryWrites": false, + "connectTimeoutMS": 250, + "heartbeatFrequencyMS": 500, + "appname": "commandErrorHandshakeTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "hello-command-error" + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "hello-command-error", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "hello-command-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "Command error on Monitor check", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "connectTimeoutMS": 1000, + "heartbeatFrequencyMS": 500, + "appname": "commandErrorCheckTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "hello-command-error" + } + } + ] + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "commandErrorCheckTest", + "closeConnection": false, + "blockConnection": true, + "blockTimeMS": 750, + "errorCode": 91 + } + }, + "client": "setupClient" + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "hello-command-error", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "hello-command-error", + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "hello-command-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-command-error.yml b/test/spec/server-discovery-and-monitoring/unified/hello-command-error.yml new file mode 100644 index 0000000000..3b1428deb0 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/hello-command-error.yml @@ -0,0 +1,233 @@ +--- +description: hello-command-error + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.9" + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName hello-command-error + databaseName: &databaseName sdam-tests + documents: [] + +tests: + - description: Command error on Monitor handshake + operations: + # Configure the next streaming hello check to fail with a command error. + # Use "times: 4" to increase the probability that the Monitor check fails + # since the RTT hello may trigger this failpoint one or many times as + # well. + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 4 + data: + failCommands: + - hello + - isMaster + appName: commandErrorHandshakeTest + closeConnection: false + errorCode: 91 + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - serverDescriptionChangedEvent + - poolClearedEvent + - commandStartedEvent + uriOptions: + retryWrites: false + connectTimeoutMS: 250 + heartbeatFrequencyMS: 500 + appname: commandErrorHandshakeTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # The command error on the initial handshake should mark the server + # Unknown (emitting a ServerDescriptionChangedEvent) and clear the pool. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + # Perform an operation to ensure the node is discovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 1 + - _id: 2 + # We cannot assert the server was marked Unknown and pool was cleared an + # exact number of times because the RTT hello may or may not have + # triggered this failpoint as well. + + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: hello-command-error + documents: + - _id: 1 + - _id: 2 + commandName: insert + databaseName: *databaseName + + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + + - description: Command error on Monitor check + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + connectTimeoutMS: 1000 + heartbeatFrequencyMS: 500 + appname: commandErrorCheckTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Perform an operation to ensure the node is discovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 1 + - _id: 2 + # Configure the next streaming hello check to fail with a command + # error. + # Use times: 2 so that the RTT hello is blocked as well. + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: + times: 2 + data: + failCommands: + - hello + - isMaster + appName: commandErrorCheckTest + closeConnection: false + blockConnection: true + blockTimeMS: 750 + errorCode: 91 + client: *setupClient + # The command error on the next check should mark the server Unknown and + # clear the pool. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform an operation to ensure the node is rediscovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + # Assert the server was marked Unknown and pool was cleared exactly once. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: hello-command-error + documents: + - _id: 1 + - _id: 2 + commandName: insert + databaseName: *databaseName + - commandStartedEvent: + command: + insert: hello-command-error + documents: + - _id: 3 + - _id: 4 + commandName: insert + databaseName: *databaseName + + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 3 + - _id: 4 diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-network-error.json b/test/spec/server-discovery-and-monitoring/unified/hello-network-error.json new file mode 100644 index 0000000000..55373c90cc --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/hello-network-error.json @@ -0,0 +1,346 @@ +{ + "description": "hello-network-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.9", + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "hello-network-error", + "databaseName": "sdam-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "Network error on Monitor handshake", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "networkErrorHandshakeTest", + "closeConnection": true + } + } + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "connectTimeoutMS": 250, + "heartbeatFrequencyMS": 500, + "appname": "networkErrorHandshakeTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "hello-network-error" + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "hello-network-error", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "hello-network-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "Network error on Monitor check", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "connectTimeoutMS": 250, + "heartbeatFrequencyMS": 500, + "appname": "networkErrorCheckTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "hello-network-error" + } + } + ] + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 4 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "networkErrorCheckTest", + "closeConnection": true + } + }, + "client": "setupClient" + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "hello-network-error", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "hello-network-error", + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "hello-network-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-network-error.yml b/test/spec/server-discovery-and-monitoring/unified/hello-network-error.yml new file mode 100644 index 0000000000..92c8cf243d --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/hello-network-error.yml @@ -0,0 +1,227 @@ +--- +description: hello-network-error + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.9" + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName hello-network-error + databaseName: &databaseName sdam-tests + documents: [] + +tests: + - description: Network error on Monitor handshake + # Configure the initial handshake to fail with a network error. + # Use times: 2 so that the RTT hello fails as well. + operations: + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 2 + data: + failCommands: + - hello + - isMaster + appName: networkErrorHandshakeTest + closeConnection: true + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + connectTimeoutMS: 250 + heartbeatFrequencyMS: 500 + appname: networkErrorHandshakeTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # The network error on the initial handshake should mark the server + # Unknown (emitting a ServerDescriptionChangedEvent) and clear the pool. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + # Perform an operation to ensure the node is discovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 1 + - _id: 2 + # We cannot assert the server was marked Unknown and pool was cleared an + # exact number of times because the RTT hello may or may not have + # triggered this failpoint as well. + + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: hello-network-error + documents: + - _id: 1 + - _id: 2 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + + - description: Network error on Monitor check + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + connectTimeoutMS: 250 + heartbeatFrequencyMS: 500 + appname: networkErrorCheckTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Perform an operation to ensure the node is discovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 1 + - _id: 2 + # Configure the next streaming hello check to fail with a non-timeout + # network error. Use "times: 4" to increase the probability that the + # Monitor check fails since the RTT hello may trigger this failpoint one + # or many times as well. + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: + times: 4 + data: + failCommands: + - hello + - isMaster + appName: networkErrorCheckTest + closeConnection: true + client: *setupClient + # The network error on the next check should mark the server Unknown and + # clear the pool. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform an operation to ensure the node is rediscovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + # We cannot assert the server was marked Unknown and pool was cleared an + # exact number of times because the RTT hello may or may not have + # triggered this failpoint as well. + # - name: assertEventCount + # object: testRunner + # arguments: + # client: *client + # event: + # serverDescriptionChangedEvent: + # newDescription: + # type: Unknown + # count: 1 + # - name: assertEventCount + # object: testRunner + # arguments: + # event: + # poolClearedEvent: {} + # count: 1 + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: hello-network-error + documents: + - _id: 1 + - _id: 2 + commandName: insert + databaseName: *databaseName + - commandStartedEvent: + command: + insert: hello-network-error + documents: + - _id: 3 + - _id: 4 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 3 + - _id: 4 diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-timeout.json b/test/spec/server-discovery-and-monitoring/unified/hello-timeout.json new file mode 100644 index 0000000000..fe7cf4e78d --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/hello-timeout.json @@ -0,0 +1,514 @@ +{ + "description": "hello-timeout", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "hello-timeout", + "databaseName": "sdam-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "Network timeout on Monitor handshake", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "timeoutMonitorHandshakeTest", + "blockConnection": true, + "blockTimeMS": 1000 + } + } + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "connectTimeoutMS": 250, + "heartbeatFrequencyMS": 500, + "appname": "timeoutMonitorHandshakeTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "hello-timeout" + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "hello-timeout", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "hello-timeout", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "Network timeout on Monitor check", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "connectTimeoutMS": 750, + "heartbeatFrequencyMS": 500, + "appname": "timeoutMonitorCheckTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "hello-timeout" + } + } + ] + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 4 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "timeoutMonitorCheckTest", + "blockConnection": true, + "blockTimeMS": 1000 + } + }, + "client": "setupClient" + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "hello-timeout", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "hello-timeout", + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "hello-timeout", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + }, + { + "description": "Driver extends timeout while streaming", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "connectTimeoutMS": 250, + "heartbeatFrequencyMS": 500, + "appname": "extendsTimeoutTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "hello-timeout" + } + } + ] + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + }, + { + "name": "wait", + "object": "testRunner", + "arguments": { + "ms": 2000 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 0 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 0 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "hello-timeout", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "hello-timeout", + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "hello-timeout", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/hello-timeout.yml b/test/spec/server-discovery-and-monitoring/unified/hello-timeout.yml new file mode 100644 index 0000000000..2a3374d1e7 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/hello-timeout.yml @@ -0,0 +1,318 @@ +--- +description: hello-timeout + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.4" + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName hello-timeout + databaseName: &databaseName sdam-tests + documents: [] + +tests: + - description: Network timeout on Monitor handshake + operations: + # Configure the initial handshake to fail with a timeout. + # Use times: 2 so that the RTT hello is blocked as well. + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 2 + data: + failCommands: + - hello + - isMaster + appName: timeoutMonitorHandshakeTest + blockConnection: true + blockTimeMS: 1000 + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + connectTimeoutMS: 250 + heartbeatFrequencyMS: 500 + appname: timeoutMonitorHandshakeTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # The network error on the initial handshake should mark the server + # Unknown (emitting a ServerDescriptionChangedEvent) and clear the pool. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + # Perform an operation to ensure the node is discovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 1 + - _id: 2 + # We cannot assert the server was marked Unknown and pool was cleared an + # exact number of times because the RTT hello may or may not have + # triggered this failpoint as well. + # - name: assertEventCount + # object: testRunner + # arguments: + # event: ServerMarkedUnknownEvent + # count: 1 + # - name: assertEventCount + # object: testRunner + # arguments: + # event: PoolClearedEvent + # count: 1 + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: hello-timeout + documents: + - _id: 1 + - _id: 2 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + + - description: Network timeout on Monitor check + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + connectTimeoutMS: 750 + heartbeatFrequencyMS: 500 + appname: timeoutMonitorCheckTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Perform an operation to ensure the node is discovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 1 + - _id: 2 + # Configure the next streaming hello check to fail with a timeout. + # Use "times: 4" to increase the probability that the Monitor check times + # out since the RTT hello may trigger this failpoint one or many times as + # well. + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: + times: 4 + data: + failCommands: + - hello + - isMaster + appName: timeoutMonitorCheckTest + blockConnection: true + # blockTimeMS is evaluated after the waiting for heartbeatFrequencyMS server-side, so this value only + # needs to be greater than connectTimeoutMS. The driver will wait for (500+750)ms and the server will + # respond after (500+1000)ms. + blockTimeMS: 1000 + client: *setupClient + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + # The network error on the next check should mark the server Unknown and + # clear the pool. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform an operation to ensure the node is rediscovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + # We cannot assert the server was marked Unknown and pool was cleared an + # exact number of times because the RTT hello may have triggered this + # failpoint one or many times as well. + + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: hello-timeout + documents: + - _id: 1 + - _id: 2 + commandName: insert + databaseName: *databaseName + - commandStartedEvent: + command: + insert: hello-timeout + documents: + - _id: 3 + - _id: 4 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 3 + - _id: 4 + + - description: Driver extends timeout while streaming + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + connectTimeoutMS: 250 + heartbeatFrequencyMS: 500 + appname: extendsTimeoutTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Perform an operation to ensure the node is discovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 1 + - _id: 2 + # Wait for multiple monitor checks to complete. + - name: wait + object: testRunner + arguments: + ms: 2000 + # Perform an operation to ensure the node is still selectable. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + # Assert that the server was never marked Unknown and the pool was never + # cleared. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 0 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 0 + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: hello-timeout + documents: + - _id: 1 + - _id: 2 + commandName: insert + databaseName: *databaseName + - commandStartedEvent: + command: + insert: hello-timeout + documents: + - _id: 3 + - _id: 4 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 3 + - _id: 4 diff --git a/test/spec/server-discovery-and-monitoring/unified/insert-network-error.json b/test/spec/server-discovery-and-monitoring/unified/insert-network-error.json new file mode 100644 index 0000000000..bfe41a4cb6 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/insert-network-error.json @@ -0,0 +1,246 @@ +{ + "description": "insert-network-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "insert-network-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "Reset server and pool after network error on insert", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "insert" + ], + "closeConnection": true, + "appName": "insertNetworkErrorTest" + } + } + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeEvents": [ + "commandStartedEvent", + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "appname": "insertNetworkErrorTest" + }, + "useMultipleMongoses": false + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "insert-network-error" + } + } + ] + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "expectError": { + "isError": true + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "insert-network-error", + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "insert-network-error", + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "insert-network-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/insert-network-error.yml b/test/spec/server-discovery-and-monitoring/unified/insert-network-error.yml new file mode 100644 index 0000000000..fcedf54357 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/insert-network-error.yml @@ -0,0 +1,137 @@ +--- +description: insert-network-error + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.4" + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName insert-network-error + databaseName: &databaseName sdam-tests + documents: + - _id: 1 + - _id: 2 + +tests: + - description: Reset server and pool after network error on insert + operations: + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 1 + data: + failCommands: + - insert + closeConnection: true + appName: insertNetworkErrorTest + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + appname: insertNetworkErrorTest + useMultipleMongoses: false + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + expectError: + isError: true + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform another operation to ensure the node is rediscovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 5 + - _id: 6 + # Assert the server was marked Unknown and pool was cleared exactly once. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: insert-network-error + documents: + - _id: 3 + - _id: 4 + commandName: insert + databaseName: *databaseName + - commandStartedEvent: + command: + insert: insert-network-error + documents: + - _id: 5 + - _id: 6 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 5 + - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.json b/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.json new file mode 100644 index 0000000000..af7c6c987a --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.json @@ -0,0 +1,250 @@ +{ + "description": "insert-shutdown-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "insert-shutdown-error", + "databaseName": "sdam-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "Concurrent shutdown error on insert", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "uriOptions": { + "retryWrites": false, + "heartbeatFrequencyMS": 500, + "appname": "shutdownErrorInsertTest" + }, + "observeEvents": [ + "serverDescriptionChangedEvent", + "poolClearedEvent" + ] + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "insert-shutdown-error" + } + } + ] + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 1 + } + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "insert" + ], + "appName": "shutdownErrorInsertTest", + "errorCode": 91, + "blockConnection": true, + "blockTimeMS": 500 + } + }, + "client": "setupClient" + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "thread": { + "id": "thread0" + } + }, + { + "thread": { + "id": "thread1" + } + } + ] + } + }, + { + "name": "runOnThread", + "object": "testRunner", + "arguments": { + "thread": "thread0", + "operation": { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 2 + } + }, + "expectError": { + "isError": true + } + } + } + }, + { + "name": "runOnThread", + "object": "testRunner", + "arguments": { + "thread": "thread1", + "operation": { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 3 + } + }, + "expectError": { + "isError": true + } + } + } + }, + { + "name": "waitForThread", + "object": "testRunner", + "arguments": { + "thread": "thread0" + } + }, + { + "name": "waitForThread", + "object": "testRunner", + "arguments": { + "thread": "thread1" + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 4 + } + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + } + ], + "outcome": [ + { + "collectionName": "insert-shutdown-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 4 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.yml b/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.yml new file mode 100644 index 0000000000..ae32229ffa --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/insert-shutdown-error.yml @@ -0,0 +1,162 @@ +--- +description: insert-shutdown-error + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.4" + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName insert-shutdown-error + databaseName: &databaseName sdam-tests + documents: [] + +tests: + - description: Concurrent shutdown error on insert + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + uriOptions: + retryWrites: false + heartbeatFrequencyMS: 500 + appname: shutdownErrorInsertTest + observeEvents: + - serverDescriptionChangedEvent + - poolClearedEvent + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Perform an operation to ensure the node is discovered. + - name: insertOne + object: *collection + arguments: + document: + _id: 1 + # Configure the next two inserts to fail with a non-timeout shutdown + # errors. Block the connection for 500ms to ensure both operations check + # out connections from the same pool generation. + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: + times: 2 + data: + failCommands: + - insert + appName: shutdownErrorInsertTest + errorCode: 91 + blockConnection: true + blockTimeMS: 500 + client: *setupClient + # Start threads. + - name: createEntities + object: testRunner + arguments: + entities: + - thread: + id: &thread0 thread0 + - thread: + id: &thread1 thread1 + # Perform concurrent insert operations. Both fail with shutdown errors. + - name: runOnThread + object: testRunner + arguments: + thread: *thread0 + operation: + name: insertOne + object: *collection + arguments: + document: + _id: 2 + expectError: + isError: true + - name: runOnThread + object: testRunner + arguments: + thread: *thread1 + operation: + name: insertOne + object: *collection + arguments: + document: + _id: 3 + expectError: + isError: true + # Stop threads. + - name: waitForThread + object: testRunner + arguments: + thread: *thread0 + - name: waitForThread + object: testRunner + arguments: + thread: *thread1 + # The first shutdown error should mark the server Unknown and then clear + # the pool. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform an operation to ensure the node is rediscovered. + - name: insertOne + object: *collection + arguments: + document: + _id: 4 + # Assert the server was marked Unknown and pool was cleared exactly once. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + + # Order of operations is non-deterministic so we cannot check events. + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 4 diff --git a/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json b/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json new file mode 100644 index 0000000000..a20d79030a --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json @@ -0,0 +1,591 @@ +{ + "description": "interruptInUse", + "schemaVersion": "1.11", + "runOnRequirements": [ + { + "minServerVersion": "4.9", + "serverless": "forbid", + "topologies": [ + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "interruptInUse", + "databaseName": "sdam-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "Connection pool clear uses interruptInUseConnections=true after monitor timeout", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "poolClearedEvent", + "connectionClosedEvent", + "commandStartedEvent", + "commandSucceededEvent", + "commandFailedEvent", + "connectionCheckedOutEvent", + "connectionCheckedInEvent" + ], + "uriOptions": { + "connectTimeoutMS": 500, + "heartbeatFrequencyMS": 500, + "appname": "interruptInUse", + "retryReads": false, + "minPoolSize": 0 + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "interruptInUse" + } + }, + { + "thread": { + "id": "thread1" + } + } + ] + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 1 + } + } + }, + { + "name": "runOnThread", + "object": "testRunner", + "arguments": { + "thread": "thread1", + "operation": { + "name": "find", + "object": "collection", + "arguments": { + "filter": { + "$where": "sleep(2000) || true" + } + }, + "expectError": { + "isError": true + } + } + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 4 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "blockConnection": true, + "blockTimeMS": 1500, + "appName": "interruptInUse" + } + } + } + }, + { + "name": "waitForThread", + "object": "testRunner", + "arguments": { + "thread": "thread1" + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "commandName": "insert" + } + }, + { + "commandSucceededEvent": { + "commandName": "insert" + } + }, + { + "commandStartedEvent": { + "commandName": "find" + } + }, + { + "commandFailedEvent": { + "commandName": "find" + } + } + ] + }, + { + "client": "client", + "eventType": "cmap", + "events": [ + { + "connectionCheckedOutEvent": {} + }, + { + "connectionCheckedInEvent": {} + }, + { + "connectionCheckedOutEvent": {} + }, + { + "poolClearedEvent": { + "interruptInUseConnections": true + } + }, + { + "connectionCheckedInEvent": {} + }, + { + "connectionClosedEvent": {} + } + ] + } + ], + "outcome": [ + { + "collectionName": "interruptInUse", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "Error returned from connection pool clear with interruptInUseConnections=true is retryable", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "poolClearedEvent", + "connectionClosedEvent", + "commandStartedEvent", + "commandFailedEvent", + "commandSucceededEvent", + "connectionCheckedOutEvent", + "connectionCheckedInEvent" + ], + "uriOptions": { + "connectTimeoutMS": 500, + "heartbeatFrequencyMS": 500, + "appname": "interruptInUseRetryable", + "retryReads": true, + "minPoolSize": 0 + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "interruptInUse" + } + }, + { + "thread": { + "id": "thread1" + } + } + ] + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 1 + } + } + }, + { + "name": "runOnThread", + "object": "testRunner", + "arguments": { + "thread": "thread1", + "operation": { + "name": "find", + "object": "collection", + "arguments": { + "filter": { + "$where": "sleep(2000) || true" + } + } + } + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 4 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "blockConnection": true, + "blockTimeMS": 1500, + "appName": "interruptInUseRetryable" + } + } + } + }, + { + "name": "waitForThread", + "object": "testRunner", + "arguments": { + "thread": "thread1" + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "commandName": "insert" + } + }, + { + "commandSucceededEvent": { + "commandName": "insert" + } + }, + { + "commandStartedEvent": { + "commandName": "find" + } + }, + { + "commandFailedEvent": { + "commandName": "find" + } + }, + { + "commandStartedEvent": { + "commandName": "find" + } + }, + { + "commandSucceededEvent": { + "commandName": "find" + } + } + ] + }, + { + "client": "client", + "eventType": "cmap", + "events": [ + { + "connectionCheckedOutEvent": {} + }, + { + "connectionCheckedInEvent": {} + }, + { + "connectionCheckedOutEvent": {} + }, + { + "poolClearedEvent": { + "interruptInUseConnections": true + } + }, + { + "connectionCheckedInEvent": {} + }, + { + "connectionClosedEvent": {} + }, + { + "connectionCheckedOutEvent": {} + }, + { + "connectionCheckedInEvent": {} + } + ] + } + ], + "outcome": [ + { + "collectionName": "interruptInUse", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "Error returned from connection pool clear with interruptInUseConnections=true is retryable for write", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "poolClearedEvent", + "connectionClosedEvent", + "commandStartedEvent", + "commandFailedEvent", + "commandSucceededEvent", + "connectionCheckedOutEvent", + "connectionCheckedInEvent" + ], + "uriOptions": { + "connectTimeoutMS": 500, + "heartbeatFrequencyMS": 500, + "appname": "interruptInUseRetryableWrite", + "retryWrites": true, + "minPoolSize": 0 + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "interruptInUse" + } + }, + { + "thread": { + "id": "thread1" + } + } + ] + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 1 + } + } + }, + { + "name": "runOnThread", + "object": "testRunner", + "arguments": { + "thread": "thread1", + "operation": { + "name": "updateOne", + "object": "collection", + "arguments": { + "filter": { + "$where": "sleep(2000) || true" + }, + "update": { + "$set": { + "a": "bar" + } + } + } + } + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 4 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "blockConnection": true, + "blockTimeMS": 1500, + "appName": "interruptInUseRetryableWrite" + } + } + } + }, + { + "name": "waitForThread", + "object": "testRunner", + "arguments": { + "thread": "thread1" + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "commandName": "insert" + } + }, + { + "commandSucceededEvent": { + "commandName": "insert" + } + }, + { + "commandStartedEvent": { + "commandName": "update" + } + }, + { + "commandFailedEvent": { + "commandName": "update" + } + }, + { + "commandStartedEvent": { + "commandName": "update" + } + }, + { + "commandSucceededEvent": { + "commandName": "update" + } + } + ] + }, + { + "client": "client", + "eventType": "cmap", + "events": [ + { + "connectionCheckedOutEvent": {} + }, + { + "connectionCheckedInEvent": {} + }, + { + "connectionCheckedOutEvent": {} + }, + { + "poolClearedEvent": { + "interruptInUseConnections": true + } + }, + { + "connectionCheckedInEvent": {} + }, + { + "connectionClosedEvent": {} + }, + { + "connectionCheckedOutEvent": {} + }, + { + "connectionCheckedInEvent": {} + } + ] + } + ], + "outcome": [ + { + "collectionName": "interruptInUse", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1, + "a": "bar" + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml b/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml new file mode 100644 index 0000000000..1f241e8536 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml @@ -0,0 +1,341 @@ +--- +description: interruptInUse + +schemaVersion: "1.11" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.9" + serverless: forbid + topologies: [ replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName interruptInUse + databaseName: &databaseName sdam-tests + documents: [] + +tests: + - description: Connection pool clear uses interruptInUseConnections=true after monitor timeout + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - poolClearedEvent + - connectionClosedEvent + - commandStartedEvent + - commandSucceededEvent + - commandFailedEvent + - connectionCheckedOutEvent + - connectionCheckedInEvent + uriOptions: + connectTimeoutMS: 500 + heartbeatFrequencyMS: 500 + appname: interruptInUse + retryReads: false + minPoolSize: 0 + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + - thread: + id: &thread1 thread1 + - name: insertOne + object: *collection + arguments: + document: { _id: 1 } + # simulate a long-running query + - name: runOnThread + object: testRunner + arguments: + thread: *thread1 + operation: + name: find + object: *collection + arguments: + filter: + $where : sleep(2000) || true + expectError: + isError: true + # Configure the monitor check to fail with a timeout. + # Use "times: 4" to increase the probability that the Monitor check triggers + # the failpoint, since the RTT hello may trigger this failpoint one or many + # times as well. + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 4 + data: + failCommands: + - hello + - isMaster + blockConnection: true + blockTimeMS: 1500 + appName: interruptInUse + - name: waitForThread + object: testRunner + arguments: + thread: *thread1 + + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + commandName: insert + - commandSucceededEvent: + commandName: insert + - commandStartedEvent: + commandName: find + - commandFailedEvent: + commandName: find + - client: *client + eventType: cmap + events: + - connectionCheckedOutEvent: {} + - connectionCheckedInEvent: {} + - connectionCheckedOutEvent: {} + - poolClearedEvent: + interruptInUseConnections: true + - connectionCheckedInEvent: {} + - connectionClosedEvent: {} + + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + + - description: Error returned from connection pool clear with interruptInUseConnections=true is retryable + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - poolClearedEvent + - connectionClosedEvent + - commandStartedEvent + - commandFailedEvent + - commandSucceededEvent + - connectionCheckedOutEvent + - connectionCheckedInEvent + uriOptions: + connectTimeoutMS: 500 + heartbeatFrequencyMS: 500 + appname: interruptInUseRetryable + retryReads: true + minPoolSize: 0 + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + - thread: + id: &thread1 thread1 + - name: insertOne + object: *collection + arguments: + document: { _id: 1 } + # simulate a long-running query + - name: runOnThread + object: testRunner + arguments: + thread: *thread1 + operation: + name: find + object: *collection + arguments: + filter: + $where : sleep(2000) || true + # Configure the monitor check to fail with a timeout. + # Use "times: 4" to increase the probability that the Monitor check triggers + # the failpoint, since the RTT hello may trigger this failpoint one or many + # times as well. + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 4 + data: + failCommands: + - hello + - isMaster + blockConnection: true + blockTimeMS: 1500 + appName: interruptInUseRetryable + - name: waitForThread + object: testRunner + arguments: + thread: *thread1 + + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + commandName: insert + - commandSucceededEvent: + commandName: insert + - commandStartedEvent: + commandName: find + - commandFailedEvent: + commandName: find + - commandStartedEvent: + commandName: find + - commandSucceededEvent: + commandName: find + - client: *client + eventType: cmap + events: + - connectionCheckedOutEvent: {} + - connectionCheckedInEvent: {} + - connectionCheckedOutEvent: {} + - poolClearedEvent: + interruptInUseConnections: true + - connectionCheckedInEvent: {} + - connectionClosedEvent: {} + - connectionCheckedOutEvent: {} + - connectionCheckedInEvent: {} + + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - description: Error returned from connection pool clear with interruptInUseConnections=true is retryable for write + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - poolClearedEvent + - connectionClosedEvent + - commandStartedEvent + - commandFailedEvent + - commandSucceededEvent + - connectionCheckedOutEvent + - connectionCheckedInEvent + uriOptions: + connectTimeoutMS: 500 + heartbeatFrequencyMS: 500 + appname: interruptInUseRetryableWrite + retryWrites: true + minPoolSize: 0 + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + - thread: + id: &thread1 thread1 + # ensure the primary is discovered + - name: insertOne + object: *collection + arguments: + document: { _id: 1 } + # simulate a long-running query + - name: runOnThread + object: testRunner + arguments: + thread: *thread1 + operation: + name: updateOne + object: *collection + arguments: + filter: + $where: sleep(2000) || true + update: + "$set": { "a": "bar" } + # Configure the monitor check to fail with a timeout. + # Use "times: 4" to increase the probability that the Monitor check triggers + # the failpoint, since the RTT hello may trigger this failpoint one or many + # times as well. + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 4 + data: + failCommands: + - hello + - isMaster + blockConnection: true + blockTimeMS: 1500 + appName: interruptInUseRetryableWrite + - name: waitForThread + object: testRunner + arguments: + thread: *thread1 + + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + commandName: insert + - commandSucceededEvent: + commandName: insert + - commandStartedEvent: + commandName: update + - commandFailedEvent: + commandName: update + - commandStartedEvent: + commandName: update + - commandSucceededEvent: + commandName: update + - client: *client + eventType: cmap + events: + - connectionCheckedOutEvent: {} + - connectionCheckedInEvent: {} + - connectionCheckedOutEvent: {} + - poolClearedEvent: + interruptInUseConnections: true + - connectionCheckedInEvent: {} + - connectionClosedEvent: {} + - connectionCheckedOutEvent: {} + - connectionCheckedInEvent: {} + + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - { _id: 1, a : bar } + diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.json b/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.json new file mode 100644 index 0000000000..45440d2557 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.json @@ -0,0 +1,150 @@ +{ + "description": "loadbalanced-logging", + "schemaVersion": "1.16", + "runOnRequirements": [ + { + "topologies": [ + "load-balanced" + ], + "minServerVersion": "4.4" + } + ], + "tests": [ + { + "description": "Topology lifecycle", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "topologyDescriptionChangedEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "topologyDescriptionChangedEvent": {} + }, + "count": 2 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring", + "topologyId": { + "$$exists": true + } + } + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.yml b/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.yml new file mode 100644 index 0000000000..3f6058270f --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-loadbalanced.yml @@ -0,0 +1,74 @@ +description: "loadbalanced-logging" + +schemaVersion: "1.16" + +runOnRequirements: + - topologies: + - load-balanced + minServerVersion: "4.4" # awaitable hello + +tests: + - description: "Topology lifecycle" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeLogMessages: + topology: debug + observeEvents: + - topologyDescriptionChangedEvent + # ensure the topology has been fully discovered before closing the client. + # expected events are initial server discovery and server connect event. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + topologyDescriptionChangedEvent: {} + count: 2 + - name: close + object: *client + expectLogMessages: + - client: *client + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: { $$exists: true } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # unknown topology + newDescription: { $$exists: true } # unknown topology, disconnected server + - level: debug + component: topology + data: + message: "Starting server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # loadBalanced topology + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Stopped topology monitoring" + topologyId: { $$exists: true } \ No newline at end of file diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json new file mode 100644 index 0000000000..e6738225cd --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json @@ -0,0 +1,606 @@ +{ + "description": "replicaset-logging", + "schemaVersion": "1.16", + "runOnRequirements": [ + { + "topologies": [ + "replicaset" + ], + "minServerVersion": "4.4" + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient" + } + } + ], + "tests": [ + { + "description": "Topology lifecycle", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "topologyDescriptionChangedEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "topologyDescriptionChangedEvent": {} + }, + "count": 4 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring", + "topologyId": { + "$$exists": true + } + } + } + ] + } + ] + }, + { + "description": "Successful heartbeat", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "serverHeartbeatSucceededEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatSucceededEvent": {} + }, + "count": 3 + } + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreExtraMessages": true, + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "serverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "reply": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "ok": 1 + } + } + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "serverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "reply": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "ok": 1 + } + } + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "serverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "reply": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "ok": 1 + } + } + } + } + } + ] + } + ] + }, + { + "description": "Failing heartbeat", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "serverHeartbeatFailedEvent" + ], + "uriOptions": { + "appname": "failingHeartbeatLoggingTest" + } + } + } + ] + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "failPoint": { + "configureFailPoint": "failCommand", + "mode": "alwaysOn", + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "failingHeartbeatLoggingTest", + "closeConnection": true + } + }, + "client": "setupClient" + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatFailedEvent": {} + }, + "count": 1 + } + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreExtraMessages": true, + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "failure": { + "$$exists": true + } + } + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml new file mode 100644 index 0000000000..a0b856ec72 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml @@ -0,0 +1,289 @@ +description: "replicaset-logging" + +schemaVersion: "1.16" + +runOnRequirements: + - topologies: + - replicaset + minServerVersion: "4.4" # awaitable hello + +createEntities: + - client: + id: &setupClient setupClient + +tests: + - description: "Topology lifecycle" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeLogMessages: + topology: debug + observeEvents: + - topologyDescriptionChangedEvent + # ensure the topology has been fully discovered before closing the client. + # expected events are initial cluster type change from unknown to ReplicaSet, and connect events for each of 3 servers. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + topologyDescriptionChangedEvent: {} + count: 4 + - name: close + object: *client + expectLogMessages: + - client: *client + ignoreMessages: + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + - level: debug + component: topology + data: + message: "Server heartbeat failed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: { $$exists: true } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # unknown topology + newDescription: { $$exists: true } # ReplicaSet topology + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # server connected + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # server connected + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # server connected + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # ReplicaSet topology + newDescription: { $$exists: true } # unknown topology + - level: debug + component: topology + data: + message: "Stopped topology monitoring" + topologyId: { $$exists: true } + - description: Successful heartbeat + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: *client + observeLogMessages: + topology: debug + observeEvents: + - serverHeartbeatSucceededEvent + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverHeartbeatSucceededEvent: {} + count: 3 + expectLogMessages: + - client: *client + ignoreExtraMessages: true + ignoreMessages: + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Stopped server monitoring" + - level: debug + component: topology + data: + message: "Topology description changed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: { $$exists: true } + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + reply: + $$matchAsDocument: + "$$matchAsRoot": + ok: 1 + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + reply: + $$matchAsDocument: + "$$matchAsRoot": + ok: 1 + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + reply: + $$matchAsDocument: + "$$matchAsRoot": + ok: 1 + - description: Failing heartbeat + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: *client + observeLogMessages: + topology: debug + observeEvents: + - serverHeartbeatFailedEvent + uriOptions: + appname: failingHeartbeatLoggingTest + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: "alwaysOn" + data: + failCommands: + - hello + - isMaster + appName: failingHeartbeatLoggingTest + closeConnection: true + client: *setupClient + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverHeartbeatFailedEvent: {} + count: 1 + expectLogMessages: + - client: *client + ignoreExtraMessages: true + ignoreMessages: + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Stopped server monitoring" + - level: debug + component: topology + data: + message: "Topology description changed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: + "$$exists": true + - level: debug + component: topology + data: + message: "Server heartbeat failed" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + failure: { $$exists: true } \ No newline at end of file diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json new file mode 100644 index 0000000000..61b27f5be0 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json @@ -0,0 +1,492 @@ +{ + "description": "sharded-logging", + "schemaVersion": "1.16", + "runOnRequirements": [ + { + "topologies": [ + "sharded" + ], + "minServerVersion": "4.4" + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "tests": [ + { + "description": "Topology lifecycle", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "topologyDescriptionChangedEvent" + ], + "useMultipleMongoses": true + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "topologyDescriptionChangedEvent": {} + }, + "count": 3 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring", + "topologyId": { + "$$exists": true + } + } + } + ] + } + ] + }, + { + "description": "Successful heartbeat", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "serverHeartbeatSucceededEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatSucceededEvent": {} + }, + "count": 1 + } + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreExtraMessages": true, + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "serverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "reply": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "ok": 1 + } + } + } + } + } + ] + } + ] + }, + { + "description": "Failing heartbeat", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "serverHeartbeatStartedEvent", + "serverHeartbeatFailedEvent" + ], + "uriOptions": { + "appname": "failingHeartbeatLoggingTest" + } + } + } + ] + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "failPoint": { + "configureFailPoint": "failCommand", + "mode": "alwaysOn", + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "failingHeartbeatLoggingTest", + "closeConnection": true + } + }, + "client": "setupClient" + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatFailedEvent": {} + }, + "count": 1 + } + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreExtraMessages": true, + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "failure": { + "$$exists": true + } + } + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml new file mode 100644 index 0000000000..19870878b9 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml @@ -0,0 +1,248 @@ +description: "sharded-logging" + +schemaVersion: "1.16" + +runOnRequirements: + - topologies: + - sharded + minServerVersion: "4.4" # awaitable hello + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +tests: + - description: "Topology lifecycle" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeLogMessages: + topology: debug + observeEvents: + - topologyDescriptionChangedEvent + useMultipleMongoses: true + # ensure the topology has been fully discovered before closing the client. + # expected events are initial cluster type change from unknown to sharded, and connect events for each of 2 servers. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + topologyDescriptionChangedEvent: {} + count: 3 + - name: close + object: *client + expectLogMessages: + - client: *client + ignoreMessages: + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + - level: debug + component: topology + data: + message: "Server heartbeat failed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: { $$exists: true } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # unknown topology + newDescription: { $$exists: true } # Sharded topology + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # shard router connected + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # shard router connected + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # Sharded topology + newDescription: { $$exists: true } # unknown topology + - level: debug + component: topology + data: + message: "Stopped topology monitoring" + topologyId: { $$exists: true } + - description: Successful heartbeat + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: *client + observeLogMessages: + topology: debug + observeEvents: + - serverHeartbeatSucceededEvent + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverHeartbeatSucceededEvent: {} + count: 1 + expectLogMessages: + - client: *client + ignoreExtraMessages: true + ignoreMessages: + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Stopped server monitoring" + - level: debug + component: topology + data: + message: "Topology description changed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: { $$exists: true } + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + reply: + $$matchAsDocument: + "$$matchAsRoot": + ok: 1 + - description: Failing heartbeat + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: *client + observeLogMessages: + topology: debug + observeEvents: + - serverHeartbeatStartedEvent + - serverHeartbeatFailedEvent + uriOptions: + appname: failingHeartbeatLoggingTest + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: "alwaysOn" + data: + failCommands: + - hello + - isMaster + appName: failingHeartbeatLoggingTest + closeConnection: true + client: *setupClient + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverHeartbeatFailedEvent: {} + count: 1 + expectLogMessages: + - client: *client + ignoreExtraMessages: true + ignoreMessages: + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Stopped server monitoring" + - level: debug + component: topology + data: + message: "Topology description changed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: + "$$exists": true + - level: debug + component: topology + data: + message: "Server heartbeat failed" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + failure: { $$exists: true } \ No newline at end of file diff --git a/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.json b/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.json new file mode 100644 index 0000000000..7e294baf66 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.json @@ -0,0 +1,177 @@ +{ + "description": "minPoolSize-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.9", + "serverless": "forbid", + "topologies": [ + "single" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "sdam-minPoolSize-error", + "databaseName": "sdam-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "Network error on minPoolSize background creation", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "skip": 3 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "SDAMminPoolSizeError", + "closeConnection": true + } + } + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "serverDescriptionChangedEvent", + "poolClearedEvent", + "poolReadyEvent" + ], + "uriOptions": { + "heartbeatFrequencyMS": 10000, + "appname": "SDAMminPoolSizeError", + "minPoolSize": 10, + "serverSelectionTimeoutMS": 1000 + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "sdam-minPoolSize-error" + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolReadyEvent": {} + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "runCommand", + "object": "database", + "arguments": { + "command": { + "ping": {} + }, + "commandName": "ping" + }, + "expectError": { + "isError": true + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "failPoint": { + "configureFailPoint": "failCommand", + "mode": "off" + }, + "client": "setupClient" + } + }, + { + "name": "runCommand", + "object": "database", + "arguments": { + "command": { + "ping": 1 + }, + "commandName": "ping" + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolReadyEvent": {} + }, + "count": 2 + } + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.yml b/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.yml new file mode 100644 index 0000000000..7d76174694 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/minPoolSize-error.yml @@ -0,0 +1,125 @@ +--- +description: minPoolSize-error + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.9" + serverless: forbid + topologies: + - single + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName sdam-minPoolSize-error + databaseName: &databaseName sdam-tests + documents: [] + +tests: + - description: Network error on minPoolSize background creation + operations: + # Configure the initial monitor handshake to succeed but the + # first or second background minPoolSize establishments to fail. + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + skip: 3 + data: + failCommands: + - hello + - isMaster + appName: SDAMminPoolSizeError + closeConnection: true + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - serverDescriptionChangedEvent + - poolClearedEvent + - poolReadyEvent + uriOptions: + heartbeatFrequencyMS: 10000 + appname: SDAMminPoolSizeError + minPoolSize: 10 + serverSelectionTimeoutMS: 1000 + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Wait for monitor to succeed handshake and mark the pool as ready. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolReadyEvent: {} + count: 1 + # Background connection establishment ensuring minPoolSize should fail, + # causing the pool to be cleared. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # The server should be marked as Unknown as part of this. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + # Executing a command should fail server selection due to not being able + # to find the primary. + - name: runCommand + object: *database + arguments: + command: + ping: {} + commandName: ping + expectError: + isError: true + # Disable the failpoint, allowing the monitor to discover the primary again. + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: "off" + client: *setupClient + # Perform an operation to ensure the node is discovered. + - name: runCommand + object: *database + arguments: + command: + ping: 1 + commandName: ping + # Assert that the monitor discovered the primary and mark the pool as ready again. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolReadyEvent: {} + count: 2 diff --git a/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.json b/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.json new file mode 100644 index 0000000000..b7f6924f2b --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.json @@ -0,0 +1,373 @@ +{ + "description": "pool-cleared-error", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.9", + "serverless": "forbid", + "topologies": [ + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "pool-cleared-error", + "databaseName": "sdam-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "PoolClearedError does not mark server unknown", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": true, + "maxPoolSize": 1, + "appname": "poolClearedErrorTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "pool-cleared-error" + } + } + ] + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 1 + } + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "insert" + ], + "blockConnection": true, + "blockTimeMS": 100, + "closeConnection": true, + "appName": "poolClearedErrorTest" + } + }, + "client": "setupClient" + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "thread": { + "id": "thread0" + } + }, + { + "thread": { + "id": "thread1" + } + }, + { + "thread": { + "id": "thread2" + } + }, + { + "thread": { + "id": "thread3" + } + }, + { + "thread": { + "id": "thread4" + } + }, + { + "thread": { + "id": "thread5" + } + } + ] + } + }, + { + "name": "runOnThread", + "object": "testRunner", + "arguments": { + "thread": "thread0", + "operation": { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 2 + } + } + } + } + }, + { + "name": "runOnThread", + "object": "testRunner", + "arguments": { + "thread": "thread1", + "operation": { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 3 + } + } + } + } + }, + { + "name": "runOnThread", + "object": "testRunner", + "arguments": { + "thread": "thread2", + "operation": { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 4 + } + } + } + } + }, + { + "name": "runOnThread", + "object": "testRunner", + "arguments": { + "thread": "thread3", + "operation": { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 5 + } + } + } + } + }, + { + "name": "runOnThread", + "object": "testRunner", + "arguments": { + "thread": "thread4", + "operation": { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 6 + } + } + } + } + }, + { + "name": "runOnThread", + "object": "testRunner", + "arguments": { + "thread": "thread5", + "operation": { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 7 + } + } + } + } + }, + { + "name": "waitForThread", + "object": "testRunner", + "arguments": { + "thread": "thread0" + } + }, + { + "name": "waitForThread", + "object": "testRunner", + "arguments": { + "thread": "thread1" + } + }, + { + "name": "waitForThread", + "object": "testRunner", + "arguments": { + "thread": "thread2" + } + }, + { + "name": "waitForThread", + "object": "testRunner", + "arguments": { + "thread": "thread3" + } + }, + { + "name": "waitForThread", + "object": "testRunner", + "arguments": { + "thread": "thread4" + } + }, + { + "name": "waitForThread", + "object": "testRunner", + "arguments": { + "thread": "thread5" + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 8 + } + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": { + "newDescription": { + "type": "Unknown" + } + } + }, + "count": 1 + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 1 + } + } + ], + "outcome": [ + { + "collectionName": "pool-cleared-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + }, + { + "_id": 5 + }, + { + "_id": 6 + }, + { + "_id": 7 + }, + { + "_id": 8 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.yml b/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.yml new file mode 100644 index 0000000000..7a98e2b324 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/pool-cleared-error.yml @@ -0,0 +1,239 @@ +--- +description: pool-cleared-error + +schemaVersion: "1.4" + +runOnRequirements: + # This test requires retryable writes, failCommand appName, and + # failCommand blockConnection with closeConnection:true (SERVER-53512). + - minServerVersion: "4.9" + serverless: forbid + topologies: + - replicaset + - sharded + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName pool-cleared-error + databaseName: &databaseName sdam-tests + documents: [] + +tests: + - description: PoolClearedError does not mark server unknown + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: true + maxPoolSize: 1 + appname: poolClearedErrorTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Perform an operation to ensure the node is discovered. + - name: insertOne + object: *collection + arguments: + document: + _id: 1 + # Configure the next insert to fail with a network error which will + # clear the pool leaving it paused until the server is rediscovered. + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: + times: 1 + data: + failCommands: + - insert + blockConnection: true + blockTimeMS: 100 + closeConnection: true + appName: poolClearedErrorTest + client: *setupClient + # Start threads. + - name: createEntities + object: testRunner + arguments: + entities: + - thread: + id: &thread0 thread0 + - thread: + id: &thread1 thread1 + - thread: + id: &thread2 thread2 + - thread: + id: &thread3 thread3 + - thread: + id: &thread4 thread4 + - thread: + id: &thread5 thread5 + # Perform concurrent insert operations. The first one to execute will + # fail with a network error, mark the server Unknown, clear the pool, + # and retry. + # The other operations will either: + # - Notice the pool is paused, fail with a PoolClearedError, and retry. + # - Or block waiting in server selection until the server is + # rediscovered. + # + # Note that this test does not guarantee that a PoolClearedError will be + # raised but it is likely since the initial insert is delayed. + - name: runOnThread + object: testRunner + arguments: + thread: *thread0 + operation: + name: insertOne + object: *collection + arguments: + document: + _id: 2 + - name: runOnThread + object: testRunner + arguments: + thread: *thread1 + operation: + name: insertOne + object: *collection + arguments: + document: + _id: 3 + - name: runOnThread + object: testRunner + arguments: + thread: *thread2 + operation: + name: insertOne + object: *collection + arguments: + document: + _id: 4 + - name: runOnThread + object: testRunner + arguments: + thread: *thread3 + operation: + name: insertOne + object: *collection + arguments: + document: + _id: 5 + - name: runOnThread + object: testRunner + arguments: + thread: *thread4 + operation: + name: insertOne + object: *collection + arguments: + document: + _id: 6 + - name: runOnThread + object: testRunner + arguments: + thread: *thread5 + operation: + name: insertOne + object: *collection + arguments: + document: + _id: 7 + # Stop threads. + - name: waitForThread + object: testRunner + arguments: + thread: *thread0 + - name: waitForThread + object: testRunner + arguments: + thread: *thread1 + - name: waitForThread + object: testRunner + arguments: + thread: *thread2 + - name: waitForThread + object: testRunner + arguments: + thread: *thread3 + - name: waitForThread + object: testRunner + arguments: + thread: *thread4 + - name: waitForThread + object: testRunner + arguments: + thread: *thread5 + # The first shutdown error should mark the server Unknown and then clear + # the pool. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform an operation to ensure the node still useable. + - name: insertOne + object: *collection + arguments: + document: + _id: 8 + # Assert the server was marked Unknown and pool was cleared exactly once. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + + # Order of operations is non-deterministic so we cannot check events. + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 3 + - _id: 4 + - _id: 5 + - _id: 6 + - _id: 7 + - _id: 8 diff --git a/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json b/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json new file mode 100644 index 0000000000..3147a07a1e --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json @@ -0,0 +1,242 @@ +{ + "description": "rediscover-quickly-after-step-down", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "serverless": "forbid", + "topologies": [ + "replicaset" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient" + } + }, + { + "database": { + "id": "adminDatabase", + "client": "setupClient", + "databaseName": "admin" + } + } + ], + "initialData": [ + { + "collectionName": "test-replSetStepDown", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "Rediscover quickly after replSetStepDown", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeEvents": [ + "poolClearedEvent", + "commandStartedEvent" + ], + "uriOptions": { + "appname": "replSetStepDownTest", + "heartbeatFrequencyMS": 60000, + "serverSelectionTimeoutMS": 5000, + "w": "majority" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "test-replSetStepDown" + } + } + ] + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + }, + { + "name": "recordTopologyDescription", + "object": "testRunner", + "arguments": { + "client": "client", + "id": "topologyDescription" + } + }, + { + "name": "assertTopologyType", + "object": "testRunner", + "arguments": { + "topologyDescription": "topologyDescription", + "topologyType": "ReplicaSetWithPrimary" + } + }, + { + "name": "runCommand", + "object": "adminDatabase", + "arguments": { + "command": { + "replSetFreeze": 0 + }, + "readPreference": { + "mode": "secondary" + }, + "commandName": "replSetFreeze" + } + }, + { + "name": "runCommand", + "object": "adminDatabase", + "arguments": { + "command": { + "replSetStepDown": 30, + "secondaryCatchUpPeriodSecs": 30, + "force": false + }, + "commandName": "replSetStepDown" + } + }, + { + "name": "waitForPrimaryChange", + "object": "testRunner", + "arguments": { + "client": "client", + "priorTopologyDescription": "topologyDescription", + "timeoutMS": 15000 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 0 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test-replSetStepDown", + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test-replSetStepDown", + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test-replSetStepDown", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + }, + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml b/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml new file mode 100644 index 0000000000..f3e7509160 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml @@ -0,0 +1,144 @@ +--- +description: rediscover-quickly-after-step-down + +schemaVersion: "1.4" + +runOnRequirements: + # 4.4 is required for streaming. + # A replica set is required for replSetStepDown. + - minServerVersion: "4.4" + serverless: forbid + topologies: + - replicaset + +createEntities: + - client: + id: &setupClient setupClient + - database: + id: &adminDatabase adminDatabase + client: *setupClient + databaseName: admin + +initialData: &initialData + - collectionName: &collectionName test-replSetStepDown + databaseName: &databaseName sdam-tests + documents: + - _id: 1 + - _id: 2 + +tests: + - description: Rediscover quickly after replSetStepDown + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeEvents: + - poolClearedEvent + - commandStartedEvent + uriOptions: + appname: replSetStepDownTest + # Configure a large heartbeatFrequencyMS + heartbeatFrequencyMS: 60000 + # Configure a much smaller server selection timeout so that the test + # will error when it cannot discover the new primary soon. + serverSelectionTimeoutMS: 5000 + w: majority + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Discover the primary. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + - name: recordTopologyDescription + object: testRunner + arguments: + client: *client + id: &topologyDescription topologyDescription + - name: assertTopologyType + object: testRunner + arguments: + topologyDescription: *topologyDescription + topologyType: ReplicaSetWithPrimary + # Unfreeze a secondary with replSetFreeze:0 to ensure a speedy election. + - name: runCommand + object: *adminDatabase + arguments: + command: + replSetFreeze: 0 + readPreference: + mode: secondary + commandName: replSetFreeze + # Run replSetStepDown on the meta client. + - name: runCommand + object: *adminDatabase + arguments: + command: + replSetStepDown: 30 + secondaryCatchUpPeriodSecs: 30 + force: false + commandName: replSetStepDown + - name: waitForPrimaryChange + object: testRunner + arguments: + client: *client + priorTopologyDescription: *topologyDescription + # We use a relatively large timeout here to workaround slow + # elections on Windows, possibly caused by SERVER-48154. + timeoutMS: 15000 + # Rediscover the new primary. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 5 + - _id: 6 + # Assert that no pools were cleared. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 0 + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: test-replSetStepDown + documents: + - _id: 3 + - _id: 4 + commandName: insert + databaseName: *databaseName + - commandStartedEvent: + command: + insert: test-replSetStepDown + documents: + - _id: 5 + - _id: 6 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 3 + - _id: 4 + - _id: 5 + - _id: 6 diff --git a/test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.json b/test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.json new file mode 100644 index 0000000000..7d681b4f9e --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.json @@ -0,0 +1,449 @@ +{ + "description": "serverMonitoringMode", + "schemaVersion": "1.17", + "runOnRequirements": [ + { + "topologies": [ + "single", + "sharded", + "sharded-replicaset" + ], + "serverless": "forbid" + } + ], + "tests": [ + { + "description": "connect with serverMonitoringMode=auto >=4.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4.0" + } + ], + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "uriOptions": { + "serverMonitoringMode": "auto" + }, + "useMultipleMongoses": false, + "observeEvents": [ + "serverHeartbeatStartedEvent", + "serverHeartbeatSucceededEvent", + "serverHeartbeatFailedEvent" + ] + } + }, + { + "database": { + "id": "db", + "client": "client", + "databaseName": "sdam-tests" + } + } + ] + } + }, + { + "name": "runCommand", + "object": "db", + "arguments": { + "commandName": "ping", + "command": { + "ping": 1 + } + }, + "expectResult": { + "ok": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatStartedEvent": {} + }, + "count": 2 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "sdam", + "ignoreExtraEvents": true, + "events": [ + { + "serverHeartbeatStartedEvent": { + "awaited": false + } + }, + { + "serverHeartbeatSucceededEvent": { + "awaited": false + } + }, + { + "serverHeartbeatStartedEvent": { + "awaited": true + } + } + ] + } + ] + }, + { + "description": "connect with serverMonitoringMode=auto <4.4", + "runOnRequirements": [ + { + "maxServerVersion": "4.2.99" + } + ], + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "uriOptions": { + "serverMonitoringMode": "auto", + "heartbeatFrequencyMS": 500 + }, + "useMultipleMongoses": false, + "observeEvents": [ + "serverHeartbeatStartedEvent", + "serverHeartbeatSucceededEvent", + "serverHeartbeatFailedEvent" + ] + } + }, + { + "database": { + "id": "db", + "client": "client", + "databaseName": "sdam-tests" + } + } + ] + } + }, + { + "name": "runCommand", + "object": "db", + "arguments": { + "commandName": "ping", + "command": { + "ping": 1 + } + }, + "expectResult": { + "ok": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatStartedEvent": {} + }, + "count": 2 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "sdam", + "ignoreExtraEvents": true, + "events": [ + { + "serverHeartbeatStartedEvent": { + "awaited": false + } + }, + { + "serverHeartbeatSucceededEvent": { + "awaited": false + } + }, + { + "serverHeartbeatStartedEvent": { + "awaited": false + } + } + ] + } + ] + }, + { + "description": "connect with serverMonitoringMode=stream >=4.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4.0" + } + ], + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "uriOptions": { + "serverMonitoringMode": "stream" + }, + "useMultipleMongoses": false, + "observeEvents": [ + "serverHeartbeatStartedEvent", + "serverHeartbeatSucceededEvent", + "serverHeartbeatFailedEvent" + ] + } + }, + { + "database": { + "id": "db", + "client": "client", + "databaseName": "sdam-tests" + } + } + ] + } + }, + { + "name": "runCommand", + "object": "db", + "arguments": { + "commandName": "ping", + "command": { + "ping": 1 + } + }, + "expectResult": { + "ok": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatStartedEvent": {} + }, + "count": 2 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "sdam", + "ignoreExtraEvents": true, + "events": [ + { + "serverHeartbeatStartedEvent": { + "awaited": false + } + }, + { + "serverHeartbeatSucceededEvent": { + "awaited": false + } + }, + { + "serverHeartbeatStartedEvent": { + "awaited": true + } + } + ] + } + ] + }, + { + "description": "connect with serverMonitoringMode=stream <4.4", + "runOnRequirements": [ + { + "maxServerVersion": "4.2.99" + } + ], + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "uriOptions": { + "serverMonitoringMode": "stream", + "heartbeatFrequencyMS": 500 + }, + "useMultipleMongoses": false, + "observeEvents": [ + "serverHeartbeatStartedEvent", + "serverHeartbeatSucceededEvent", + "serverHeartbeatFailedEvent" + ] + } + }, + { + "database": { + "id": "db", + "client": "client", + "databaseName": "sdam-tests" + } + } + ] + } + }, + { + "name": "runCommand", + "object": "db", + "arguments": { + "commandName": "ping", + "command": { + "ping": 1 + } + }, + "expectResult": { + "ok": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatStartedEvent": {} + }, + "count": 2 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "sdam", + "ignoreExtraEvents": true, + "events": [ + { + "serverHeartbeatStartedEvent": { + "awaited": false + } + }, + { + "serverHeartbeatSucceededEvent": { + "awaited": false + } + }, + { + "serverHeartbeatStartedEvent": { + "awaited": false + } + } + ] + } + ] + }, + { + "description": "connect with serverMonitoringMode=poll", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "uriOptions": { + "serverMonitoringMode": "poll", + "heartbeatFrequencyMS": 500 + }, + "useMultipleMongoses": false, + "observeEvents": [ + "serverHeartbeatStartedEvent", + "serverHeartbeatSucceededEvent", + "serverHeartbeatFailedEvent" + ] + } + }, + { + "database": { + "id": "db", + "client": "client", + "databaseName": "sdam-tests" + } + } + ] + } + }, + { + "name": "runCommand", + "object": "db", + "arguments": { + "commandName": "ping", + "command": { + "ping": 1 + } + }, + "expectResult": { + "ok": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatStartedEvent": {} + }, + "count": 2 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "sdam", + "ignoreExtraEvents": true, + "events": [ + { + "serverHeartbeatStartedEvent": { + "awaited": false + } + }, + { + "serverHeartbeatSucceededEvent": { + "awaited": false + } + }, + { + "serverHeartbeatStartedEvent": { + "awaited": false + } + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.yml b/test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.yml new file mode 100644 index 0000000000..28c7853d04 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified/serverMonitoringMode.yml @@ -0,0 +1,173 @@ +description: serverMonitoringMode + +schemaVersion: "1.17" +# These tests cannot run on replica sets because the order of the expected +# SDAM events are non-deterministic when monitoring multiple servers. +# They also cannot run on Serverless or load balanced clusters where SDAM is disabled. +runOnRequirements: + - topologies: [single, sharded, sharded-replicaset] + serverless: forbid +tests: + - description: "connect with serverMonitoringMode=auto >=4.4" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: client + uriOptions: + serverMonitoringMode: "auto" + useMultipleMongoses: false + observeEvents: + - serverHeartbeatStartedEvent + - serverHeartbeatSucceededEvent + - serverHeartbeatFailedEvent + - database: + id: db + client: client + databaseName: sdam-tests + - &ping + name: runCommand + object: db + arguments: + commandName: ping + command: { ping: 1 } + expectResult: { ok: 1 } + # Wait for the second serverHeartbeatStartedEvent to ensure we start streaming. + - &waitForSecondHeartbeatStarted + name: waitForEvent + object: testRunner + arguments: + client: client + event: + serverHeartbeatStartedEvent: {} + count: 2 + expectEvents: &streamingStartedEvents + - client: client + eventType: sdam + ignoreExtraEvents: true + events: + - serverHeartbeatStartedEvent: + awaited: False + - serverHeartbeatSucceededEvent: + awaited: False + - serverHeartbeatStartedEvent: + awaited: True + + - description: "connect with serverMonitoringMode=auto <4.4" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: client + uriOptions: + serverMonitoringMode: "auto" + heartbeatFrequencyMS: 500 + useMultipleMongoses: false + observeEvents: + - serverHeartbeatStartedEvent + - serverHeartbeatSucceededEvent + - serverHeartbeatFailedEvent + - database: + id: db + client: client + databaseName: sdam-tests + - *ping + # Wait for the second serverHeartbeatStartedEvent to ensure we do not stream. + - *waitForSecondHeartbeatStarted + expectEvents: &pollingStartedEvents + - client: client + eventType: sdam + ignoreExtraEvents: true + events: + - serverHeartbeatStartedEvent: + awaited: False + - serverHeartbeatSucceededEvent: + awaited: False + - serverHeartbeatStartedEvent: + awaited: False + + - description: "connect with serverMonitoringMode=stream >=4.4" + runOnRequirements: + - minServerVersion: "4.4.0" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: client + uriOptions: + serverMonitoringMode: "stream" + useMultipleMongoses: false + observeEvents: + - serverHeartbeatStartedEvent + - serverHeartbeatSucceededEvent + - serverHeartbeatFailedEvent + - database: + id: db + client: client + databaseName: sdam-tests + - *ping + # Wait for the second serverHeartbeatStartedEvent to ensure we start streaming. + - *waitForSecondHeartbeatStarted + expectEvents: *streamingStartedEvents + + - description: "connect with serverMonitoringMode=stream <4.4" + runOnRequirements: + - maxServerVersion: "4.2.99" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: client + uriOptions: + serverMonitoringMode: "stream" + heartbeatFrequencyMS: 500 + useMultipleMongoses: false + observeEvents: + - serverHeartbeatStartedEvent + - serverHeartbeatSucceededEvent + - serverHeartbeatFailedEvent + - database: + id: db + client: client + databaseName: sdam-tests + - *ping + # Wait for the second serverHeartbeatStartedEvent to ensure we do not stream. + - *waitForSecondHeartbeatStarted + expectEvents: *pollingStartedEvents + + - description: "connect with serverMonitoringMode=poll" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: client + uriOptions: + serverMonitoringMode: "poll" + heartbeatFrequencyMS: 500 + useMultipleMongoses: false + observeEvents: + - serverHeartbeatStartedEvent + - serverHeartbeatSucceededEvent + - serverHeartbeatFailedEvent + - database: + id: db + client: client + databaseName: sdam-tests + - *ping + # Wait for the second serverHeartbeatStartedEvent to ensure we do not stream. + - *waitForSecondHeartbeatStarted + expectEvents: *pollingStartedEvents From 72a99bacf4c268520a86518e91060455731e42c5 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Tue, 5 Dec 2023 11:53:49 -0500 Subject: [PATCH 06/22] for evergreen patch --- ...rver_discovery_and_monitoring.spec.test.ts | 4 +- .../logging-standalone.json | 517 ++++++++++++++++++ .../logging-standalone.yml | 258 +++++++++ test/tools/unified-spec-runner/match.ts | 2 + 4 files changed, 780 insertions(+), 1 deletion(-) create mode 100644 test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.json create mode 100644 test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.yml diff --git a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts index 312d6cbba7..6f21c80fa1 100644 --- a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts +++ b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts @@ -4,5 +4,7 @@ import { loadSpecTests } from '../../spec'; import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; describe.only('SDAM Unified Tests', function () { - runUnifiedSuite(loadSpecTests(path.join('server-discovery-and-monitoring', 'unified'))); + runUnifiedSuite( + loadSpecTests(path.join('server-discovery-and-monitoring', 'unified-standalone-logging-only')) + ); }); diff --git a/test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.json b/test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.json new file mode 100644 index 0000000000..1ee6dbe899 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.json @@ -0,0 +1,517 @@ +{ + "description": "standalone-logging", + "schemaVersion": "1.16", + "runOnRequirements": [ + { + "topologies": [ + "single" + ], + "minServerVersion": "4.4" + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient" + } + } + ], + "tests": [ + { + "description": "Topology lifecycle", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "topologyDescriptionChangedEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "topologyDescriptionChangedEvent": {} + }, + "count": 2 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring", + "topologyId": { + "$$exists": true + } + } + } + ] + } + ] + }, + { + "description": "Successful heartbeat", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "serverHeartbeatSucceededEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatSucceededEvent": {} + }, + "count": 1 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreExtraMessages": true, + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "serverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "reply": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "ok": 1 + } + } + } + } + } + ] + } + ] + }, + { + "description": "Failing heartbeat", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "serverHeartbeatFailedEvent" + ], + "uriOptions": { + "appname": "failingHeartbeatLoggingTest" + } + } + } + ] + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": "alwaysOn", + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "failingHeartbeatLoggingTest", + "closeConnection": true + } + } + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatFailedEvent": {} + }, + "count": 1 + } + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreExtraMessages": true, + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed", + "awaited": { + "$$exists": true + }, + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "driverConnectionId": { + "$$exists": true + }, + "durationMS": { + "$$type": [ + "int", + "long" + ] + }, + "failure": { + "$$exists": true + } + } + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.yml b/test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.yml new file mode 100644 index 0000000000..80cf98a20e --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.yml @@ -0,0 +1,258 @@ +description: "standalone-logging" + +schemaVersion: "1.16" + +runOnRequirements: + - topologies: + - single + minServerVersion: "4.4" # awaitable hello + +createEntities: + - client: + id: &setupClient setupClient + +tests: + - description: "Topology lifecycle" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeLogMessages: + topology: debug + observeEvents: + - topologyDescriptionChangedEvent + # ensure the topology has been fully discovered before closing the client. + # expected events are initial server discovery and server connect event. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + topologyDescriptionChangedEvent: {} + count: 2 + - name: close + object: *client + expectLogMessages: + - client: *client + ignoreMessages: + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + - level: debug + component: topology + data: + message: "Server heartbeat failed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: { $$exists: true } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # unknown topology + newDescription: { $$exists: true } # unknown topology, disconnected server + - level: debug + component: topology + data: + message: "Starting server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # standalone topology + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # standalone topology + newDescription: { $$exists: true } # unknown topology + - level: debug + component: topology + data: + message: "Stopped topology monitoring" + topologyId: { $$exists: true } + - description: Successful heartbeat + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeLogMessages: + topology: debug + observeEvents: + - serverHeartbeatSucceededEvent + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverHeartbeatSucceededEvent: {} + count: 1 + - name: close + object: *client + expectLogMessages: + - client: *client + ignoreExtraMessages: true + ignoreMessages: + - level: debug + component: topology + data: + message: "Topology description changed" + - level: debug + component: topology + data: + message: "Stopped topology monitoring" + - level: debug + component: topology + data: + message: "Stopped server monitoring" + - level: debug + component: topology + data: + message: "Topology description changed" + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Starting topology monitoring" + - level: debug + component: topology + data: + message: "Server heartbeat failed" + messages: + - level: debug + component: topology + data: + message: "Server heartbeat started" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + reply: + $$matchAsDocument: + "$$matchAsRoot": + ok: 1 + - description: Failing heartbeat + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeLogMessages: + topology: debug + observeEvents: + - serverHeartbeatFailedEvent + uriOptions: + appname: failingHeartbeatLoggingTest + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: "alwaysOn" + data: + failCommands: + - hello + - isMaster + appName: failingHeartbeatLoggingTest + closeConnection: true + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverHeartbeatFailedEvent: {} + count: 1 + expectLogMessages: + - client: *client + ignoreExtraMessages: true + ignoreMessages: + - level: debug + component: topology + data: + message: "Topology description changed" + - level: debug + component: topology + data: + message: "Stopped topology monitoring" + - level: debug + component: topology + data: + message: "Stopped server monitoring" + - level: debug + component: topology + data: + message: "Topology description changed" + - level: debug + component: topology + data: + message: "Starting server monitoring" + - level: debug + component: topology + data: + message: "Starting topology monitoring" + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + messages: + - level: debug + component: topology + data: + message: "Server heartbeat failed" + awaited: { $$exists: true } + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + driverConnectionId: { $$exists: true } + durationMS: { $$type: [int, long] } + failure: { $$exists: true } \ No newline at end of file diff --git a/test/tools/unified-spec-runner/match.ts b/test/tools/unified-spec-runner/match.ts index 70bb8a3593..8bfc135c9f 100644 --- a/test/tools/unified-spec-runner/match.ts +++ b/test/tools/unified-spec-runner/match.ts @@ -636,6 +636,8 @@ export function compareLogs( actual: ExpectedLogMessage[], entities: EntitiesMap ): void { + console.log('ACTUAL LOGS', actual); + console.log('EXPECTED LOGS', expected); expect(actual).to.have.lengthOf(expected.length); for (const [index, actualLog] of actual.entries()) { From 2b2fcb53ba1faaf4357ed5f98bb94ca6e98cfb03 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Wed, 6 Dec 2023 17:39:26 -0500 Subject: [PATCH 07/22] Filtering done! ready for PR --- src/cmap/command_monitoring_events.ts | 2 +- src/mongo_logger.ts | 29 +- src/sdam/events.ts | 6 +- src/sdam/monitor.ts | 9 +- src/sdam/server.ts | 2 +- ...rver_discovery_and_monitoring.spec.test.ts | 6 +- .../logging-standalone.json | 517 ------------------ .../logging-standalone.yml | 258 --------- .../unified/logging-standalone.json | 18 +- .../unified/logging-standalone.yml | 8 - test/tools/unified-spec-runner/match.ts | 30 +- test/tools/unified-spec-runner/runner.ts | 7 +- test/tools/unified-spec-runner/schema.ts | 2 + 13 files changed, 68 insertions(+), 826 deletions(-) delete mode 100644 test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.yml diff --git a/src/cmap/command_monitoring_events.ts b/src/cmap/command_monitoring_events.ts index b08ce723eb..e1c26954b3 100644 --- a/src/cmap/command_monitoring_events.ts +++ b/src/cmap/command_monitoring_events.ts @@ -302,7 +302,7 @@ function extractReply(command: WriteProtocolMessageType, reply?: Document) { return deepCopy(reply.result ? reply.result : reply); } -function extractConnectionDetails(connection: Connection) { +export function extractConnectionDetails(connection: Connection) { let connectionId; if ('id' in connection) { connectionId = connection.id; diff --git a/src/mongo_logger.ts b/src/mongo_logger.ts index 66e82268f1..d73e61dadd 100644 --- a/src/mongo_logger.ts +++ b/src/mongo_logger.ts @@ -358,9 +358,9 @@ function attachCommandFields( function attachConnectionFields( log: Record, - connectionPoolEvent: ConnectionPoolMonitoringEvent | ServerOpeningEvent | ServerClosedEvent + connectionOrSDAMEvent: ConnectionPoolMonitoringEvent | ServerOpeningEvent | ServerClosedEvent ) { - const { host, port } = HostAddress.fromString(connectionPoolEvent.address).toHostPort(); + const { host, port } = HostAddress.fromString(connectionOrSDAMEvent.address).toHostPort(); log.serverHost = host; log.serverPort = port; @@ -381,7 +381,10 @@ function attachServerHeartbeatFields( ) { const { awaited, connectionId } = serverHeartbeatEvent; log.awaited = awaited; - log.driverConnectionId = connectionId; + log.driverConnectionId = 1; + const { host, port } = HostAddress.fromString(connectionId).toHostPort(); + log.serverHost = host; + log.serverPort = port; return log; } @@ -513,7 +516,7 @@ function defaultLogTransform( case SERVER_OPENING: log = attachSDAMFields(log, logObject); log = attachConnectionFields(log, logObject); - log.message = 'Started server monitoring'; + log.message = 'Starting server monitoring'; return log; case SERVER_CLOSED: log = attachSDAMFields(log, logObject); @@ -530,18 +533,18 @@ function defaultLogTransform( log = attachServerHeartbeatFields(log, logObject); log.message = 'Server heartbeat succeeded'; log.durationMS = logObject.duration; - log.reply = logObject.reply.toString(); + log.reply = stringifyWithMaxLen(logObject.reply, maxDocumentLength); return log; case SERVER_HEARTBEAT_FAILED: log = attachSDAMFields(log, logObject); log = attachServerHeartbeatFields(log, logObject); - log.message = 'Server hearbeat failed'; + log.message = 'Server heartbeat failed'; log.durationMS = logObject.duration; - log.failure = logObject.failure; + log.failure = logObject.failure.message; return log; case TOPOLOGY_OPENING: log = attachSDAMFields(log, logObject); - log.message = 'Started topology monitoring'; + log.message = 'Starting topology monitoring'; return log; case TOPOLOGY_CLOSED: log = attachSDAMFields(log, logObject); @@ -550,8 +553,14 @@ function defaultLogTransform( case TOPOLOGY_DESCRIPTION_CHANGED: log = attachSDAMFields(log, logObject); log.message = 'Topology description changed'; - log.previousDescription = logObject.previousDescription.toString(); - log.newDescription = logObject.newDescription.toString(); + log.previousDescription = log.reply = stringifyWithMaxLen( + logObject.previousDescription, + maxDocumentLength + ); + log.newDescription = log.reply = stringifyWithMaxLen( + logObject.newDescription, + maxDocumentLength + ); return log; default: for (const [key, value] of Object.entries(logObject)) { diff --git a/src/sdam/events.ts b/src/sdam/events.ts index f73776f234..5bb85b66bf 100644 --- a/src/sdam/events.ts +++ b/src/sdam/events.ts @@ -169,7 +169,7 @@ export class TopologyClosedEvent extends ServerDiscoveryAndMonitoringEvent { export class ServerHeartbeatStartedEvent extends ServerDiscoveryAndMonitoringEvent { /** The connection id for the command */ connectionId: string; - /** Is true when using the streaming protocol. */ + /** Is true when using the streaming protocol */ awaited: boolean; /** @internal */ name = SERVER_HEARTBEAT_STARTED; @@ -194,7 +194,7 @@ export class ServerHeartbeatSucceededEvent extends ServerDiscoveryAndMonitoringE duration: number; /** The command reply */ reply: Document; - /** Is true when using the streaming protocol. */ + /** Is true when using the streaming protocol */ awaited: boolean; /** @internal */ name = SERVER_HEARTBEAT_SUCCEEDED; @@ -227,7 +227,7 @@ export class ServerHeartbeatFailedEvent extends ServerDiscoveryAndMonitoringEven duration: number; /** The command failure */ failure: Error; - /** Is true when using the streaming protocol. */ + /** Is true when using the streaming protocol */ awaited: boolean; /** @internal */ name = SERVER_HEARTBEAT_FAILED; diff --git a/src/sdam/monitor.ts b/src/sdam/monitor.ts index 890347d49e..bf37c6bc09 100644 --- a/src/sdam/monitor.ts +++ b/src/sdam/monitor.ts @@ -6,6 +6,7 @@ import { Connection, type ConnectionOptions } from '../cmap/connection'; import { getFAASEnv } from '../cmap/handshake/client_metadata'; import { LEGACY_HELLO_COMMAND } from '../constants'; import { MongoError, MongoErrorLabel, MongoNetworkTimeoutError } from '../error'; +import { MongoLoggableComponent, type MongoLogger } from '../mongo_logger'; import { CancellationToken, TypedEventEmitter } from '../mongo_types'; import type { Callback, EventEmitterWithState } from '../utils'; import { calculateDurationInMs, makeStateMachine, now, ns } from '../utils'; @@ -17,7 +18,6 @@ import { } from './events'; import { Server } from './server'; import type { TopologyVersion } from './server_description'; -import { MongoLogger } from '../mongo_logger'; /** @internal */ const kServer = Symbol('server'); @@ -98,6 +98,10 @@ export class Monitor extends TypedEventEmitter { /** @internal */ [kMonitorId]?: MonitorInterval; rttPinger?: RTTPinger; + /** @internal */ + override mongoLogger: MongoLogger; + /** @internal */ + override component = MongoLoggableComponent.TOPOLOGY; get connection(): Connection | undefined { return this[kConnection]; @@ -150,7 +154,6 @@ export class Monitor extends TypedEventEmitter { this.connectOptions = Object.freeze(connectOptions); this.mongoLogger = mongoLogger; - this.component = 'topology'; } connect(): void { @@ -264,6 +267,8 @@ function checkServer(monitor: Monitor, callback: Callback) { monitor[kServer].topology.s.id ) ); + monitor[kConnection]?.destroy({ force: true }); + monitor[kConnection] = undefined; const error = !(err instanceof MongoError) ? new MongoError(MongoError.buildErrorMessage(err), { cause: err }) diff --git a/src/sdam/server.ts b/src/sdam/server.ts index 412ed294d4..46b2131a87 100644 --- a/src/sdam/server.ts +++ b/src/sdam/server.ts @@ -178,7 +178,7 @@ export class Server extends TypedEventEmitter { } // create the monitor - this.monitor = new Monitor(this, this.s.options, this.topology.mongoLogger); + this.monitor = new Monitor(this, this.s.options, this.topology.client.mongoLogger); for (const event of HEARTBEAT_EVENTS) { this.monitor.on(event, (e: any) => this.emit(event, e)); diff --git a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts index 6f21c80fa1..74fc67efc6 100644 --- a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts +++ b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts @@ -3,8 +3,6 @@ import * as path from 'path'; import { loadSpecTests } from '../../spec'; import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; -describe.only('SDAM Unified Tests', function () { - runUnifiedSuite( - loadSpecTests(path.join('server-discovery-and-monitoring', 'unified-standalone-logging-only')) - ); +describe('SDAM Unified Tests', function () { + runUnifiedSuite(loadSpecTests(path.join('server-discovery-and-monitoring', 'unified'))); }); diff --git a/test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.json b/test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.json deleted file mode 100644 index 1ee6dbe899..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.json +++ /dev/null @@ -1,517 +0,0 @@ -{ - "description": "standalone-logging", - "schemaVersion": "1.16", - "runOnRequirements": [ - { - "topologies": [ - "single" - ], - "minServerVersion": "4.4" - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient" - } - } - ], - "tests": [ - { - "description": "Topology lifecycle", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeLogMessages": { - "topology": "debug" - }, - "observeEvents": [ - "topologyDescriptionChangedEvent" - ] - } - } - ] - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "topologyDescriptionChangedEvent": {} - }, - "count": 2 - } - }, - { - "name": "close", - "object": "client" - } - ], - "expectLogMessages": [ - { - "client": "client", - "ignoreMessages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat started" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat succeeded" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat failed" - } - } - ], - "messages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting topology monitoring", - "topologyId": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting server monitoring", - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring", - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped topology monitoring", - "topologyId": { - "$$exists": true - } - } - } - ] - } - ] - }, - { - "description": "Successful heartbeat", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeLogMessages": { - "topology": "debug" - }, - "observeEvents": [ - "serverHeartbeatSucceededEvent" - ] - } - } - ] - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverHeartbeatSucceededEvent": {} - }, - "count": 1 - } - }, - { - "name": "close", - "object": "client" - } - ], - "expectLogMessages": [ - { - "client": "client", - "ignoreExtraMessages": true, - "ignoreMessages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped topology monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting topology monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat failed" - } - } - ], - "messages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat started", - "awaited": { - "$$exists": true - }, - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - }, - "driverConnectionId": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat succeeded", - "awaited": { - "$$exists": true - }, - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - }, - "driverConnectionId": { - "$$exists": true - }, - "serverConnectionId": { - "$$exists": true - }, - "durationMS": { - "$$type": [ - "int", - "long" - ] - }, - "reply": { - "$$matchAsDocument": { - "$$matchAsRoot": { - "ok": 1 - } - } - } - } - } - ] - } - ] - }, - { - "description": "Failing heartbeat", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeLogMessages": { - "topology": "debug" - }, - "observeEvents": [ - "serverHeartbeatFailedEvent" - ], - "uriOptions": { - "appname": "failingHeartbeatLoggingTest" - } - } - } - ] - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": "alwaysOn", - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "failingHeartbeatLoggingTest", - "closeConnection": true - } - } - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "serverHeartbeatFailedEvent": {} - }, - "count": 1 - } - } - ], - "expectLogMessages": [ - { - "client": "client", - "ignoreExtraMessages": true, - "ignoreMessages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped topology monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting server monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting topology monitoring" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat started" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat succeeded" - } - } - ], - "messages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat failed", - "awaited": { - "$$exists": true - }, - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - }, - "driverConnectionId": { - "$$exists": true - }, - "durationMS": { - "$$type": [ - "int", - "long" - ] - }, - "failure": { - "$$exists": true - } - } - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.yml b/test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.yml deleted file mode 100644 index 80cf98a20e..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified-standalone-logging-only/logging-standalone.yml +++ /dev/null @@ -1,258 +0,0 @@ -description: "standalone-logging" - -schemaVersion: "1.16" - -runOnRequirements: - - topologies: - - single - minServerVersion: "4.4" # awaitable hello - -createEntities: - - client: - id: &setupClient setupClient - -tests: - - description: "Topology lifecycle" - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - observeLogMessages: - topology: debug - observeEvents: - - topologyDescriptionChangedEvent - # ensure the topology has been fully discovered before closing the client. - # expected events are initial server discovery and server connect event. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - topologyDescriptionChangedEvent: {} - count: 2 - - name: close - object: *client - expectLogMessages: - - client: *client - ignoreMessages: - - level: debug - component: topology - data: - message: "Server heartbeat started" - - level: debug - component: topology - data: - message: "Server heartbeat succeeded" - - level: debug - component: topology - data: - message: "Server heartbeat failed" - messages: - - level: debug - component: topology - data: - message: "Starting topology monitoring" - topologyId: { $$exists: true } - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } # unknown topology - newDescription: { $$exists: true } # unknown topology, disconnected server - - level: debug - component: topology - data: - message: "Starting server monitoring" - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } - newDescription: { $$exists: true } # standalone topology - - level: debug - component: topology - data: - message: "Stopped server monitoring" - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } # standalone topology - newDescription: { $$exists: true } # unknown topology - - level: debug - component: topology - data: - message: "Stopped topology monitoring" - topologyId: { $$exists: true } - - description: Successful heartbeat - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - observeLogMessages: - topology: debug - observeEvents: - - serverHeartbeatSucceededEvent - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverHeartbeatSucceededEvent: {} - count: 1 - - name: close - object: *client - expectLogMessages: - - client: *client - ignoreExtraMessages: true - ignoreMessages: - - level: debug - component: topology - data: - message: "Topology description changed" - - level: debug - component: topology - data: - message: "Stopped topology monitoring" - - level: debug - component: topology - data: - message: "Stopped server monitoring" - - level: debug - component: topology - data: - message: "Topology description changed" - - level: debug - component: topology - data: - message: "Starting server monitoring" - - level: debug - component: topology - data: - message: "Starting topology monitoring" - - level: debug - component: topology - data: - message: "Server heartbeat failed" - messages: - - level: debug - component: topology - data: - message: "Server heartbeat started" - awaited: { $$exists: true } - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - driverConnectionId: { $$exists: true } - - level: debug - component: topology - data: - message: "Server heartbeat succeeded" - awaited: { $$exists: true } - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - driverConnectionId: { $$exists: true } - serverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } - reply: - $$matchAsDocument: - "$$matchAsRoot": - ok: 1 - - description: Failing heartbeat - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - observeLogMessages: - topology: debug - observeEvents: - - serverHeartbeatFailedEvent - uriOptions: - appname: failingHeartbeatLoggingTest - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: "alwaysOn" - data: - failCommands: - - hello - - isMaster - appName: failingHeartbeatLoggingTest - closeConnection: true - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - serverHeartbeatFailedEvent: {} - count: 1 - expectLogMessages: - - client: *client - ignoreExtraMessages: true - ignoreMessages: - - level: debug - component: topology - data: - message: "Topology description changed" - - level: debug - component: topology - data: - message: "Stopped topology monitoring" - - level: debug - component: topology - data: - message: "Stopped server monitoring" - - level: debug - component: topology - data: - message: "Topology description changed" - - level: debug - component: topology - data: - message: "Starting server monitoring" - - level: debug - component: topology - data: - message: "Starting topology monitoring" - - level: debug - component: topology - data: - message: "Server heartbeat started" - - level: debug - component: topology - data: - message: "Server heartbeat succeeded" - messages: - - level: debug - component: topology - data: - message: "Server heartbeat failed" - awaited: { $$exists: true } - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - driverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } - failure: { $$exists: true } \ No newline at end of file diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json index 1ee6dbe899..1b19cd781f 100644 --- a/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json +++ b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json @@ -162,22 +162,6 @@ } } }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, { "level": "debug", "component": "topology", @@ -335,7 +319,7 @@ "$$exists": true }, "serverConnectionId": { - "$$exists": true + "$$exists": false }, "durationMS": { "$$type": [ diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-standalone.yml b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.yml index 80cf98a20e..a7453c2d3b 100644 --- a/test/spec/server-discovery-and-monitoring/unified/logging-standalone.yml +++ b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.yml @@ -84,13 +84,6 @@ tests: topologyId: { $$exists: true } serverHost: { $$type: string } serverPort: { $$type: [int, long] } - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } # standalone topology - newDescription: { $$exists: true } # unknown topology - level: debug component: topology data: @@ -168,7 +161,6 @@ tests: serverHost: { $$type: string } serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } - serverConnectionId: { $$exists: true } durationMS: { $$type: [int, long] } reply: $$matchAsDocument: diff --git a/test/tools/unified-spec-runner/match.ts b/test/tools/unified-spec-runner/match.ts index 8bfc135c9f..838804de7d 100644 --- a/test/tools/unified-spec-runner/match.ts +++ b/test/tools/unified-spec-runner/match.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ -import { EJSON } from 'bson'; +import { EJSON, Int32 } from 'bson'; import { expect } from 'chai'; import { inspect } from 'util'; @@ -289,6 +289,8 @@ export function resultCheck( ) { // case to handle +0 and -0 expect(Object.is(expected, actual)).to.be.true; + } else if (actual instanceof Int32 && typeof expected === 'number') { + expect(actual.value).to.equal(expected); } else { expect(actual).to.equal(expected); } @@ -631,13 +633,35 @@ export function matchesEvents( } } +export function filterLogs( + logsToIgnore: ExpectedLogMessage[], + actual: ExpectedLogMessage[], + entities: EntitiesMap +): ExpectedLogMessage[] { + function isLogRelevant(log: ExpectedLogMessage) { + for (const logToIgnore of logsToIgnore) { + if (log.level === logToIgnore.level && log.component === logToIgnore.component) { + try { + // see if log matches a log to ignore, it is not relevant + resultCheck(log.data, logToIgnore.data, entities, undefined, false); + return false; + } catch { + continue; + } + } + } + // if log does not match any logs to ignore, it is relevant + return true; + } + const filteredMessages: ExpectedLogMessage[] = actual.filter(isLogRelevant); + return filteredMessages; +} + export function compareLogs( expected: ExpectedLogMessage[], actual: ExpectedLogMessage[], entities: EntitiesMap ): void { - console.log('ACTUAL LOGS', actual); - console.log('EXPECTED LOGS', expected); expect(actual).to.have.lengthOf(expected.length); for (const [index, actualLog] of actual.entries()) { diff --git a/test/tools/unified-spec-runner/runner.ts b/test/tools/unified-spec-runner/runner.ts index a2c02213c6..050d7a2e87 100644 --- a/test/tools/unified-spec-runner/runner.ts +++ b/test/tools/unified-spec-runner/runner.ts @@ -7,7 +7,7 @@ import { MONGODB_ERROR_CODES, ns, ReadPreference, TopologyType } from '../../mon import { ejson } from '../utils'; import { AstrolabeResultsWriter } from './astrolabe_results_writer'; import { EntitiesMap, type UnifiedMongoClient } from './entities'; -import { compareLogs, matchesEvents } from './match'; +import { compareLogs, filterLogs, matchesEvents } from './match'; import { executeOperationAndCheck } from './operations'; import * as uni from './schema'; import { isAnyRequirementSatisfied, patchVersion, zip } from './unified-utils'; @@ -232,7 +232,10 @@ async function runUnifiedTest( const testClient = clientList.get(clientId); expect(testClient, `No client entity found with id ${clientId}`).to.exist; - compareLogs(expectedLogsForClient.messages, testClient!.collectedLogs, entities); + const filteredTestClientLogs = expectedLogsForClient.ignoreMessages + ? filterLogs(expectedLogsForClient.ignoreMessages, testClient!.collectedLogs, entities) + : testClient!.collectedLogs; + compareLogs(expectedLogsForClient.messages, filteredTestClientLogs, entities); } } diff --git a/test/tools/unified-spec-runner/schema.ts b/test/tools/unified-spec-runner/schema.ts index cefec5c560..1420b9f272 100644 --- a/test/tools/unified-spec-runner/schema.ts +++ b/test/tools/unified-spec-runner/schema.ts @@ -273,6 +273,8 @@ export type ExpectedEvent = ExpectedCommandEvent | ExpectedCmapEvent | ExpectedS export interface ExpectedLogMessagesForClient { client: string; messages: ExpectedLogMessage[]; + ignoreMessages: ExpectedLogMessage[]; + ignoreExtraMessages: boolean; } export interface ExpectedCommandEvent { From b71f1eb02a816a1f058cf5704fab819e0dccda99 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Thu, 7 Dec 2023 13:18:25 -0500 Subject: [PATCH 08/22] Fixed failing unit test --- src/cmap/command_monitoring_events.ts | 2 +- test/unit/index.test.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmap/command_monitoring_events.ts b/src/cmap/command_monitoring_events.ts index e1c26954b3..b08ce723eb 100644 --- a/src/cmap/command_monitoring_events.ts +++ b/src/cmap/command_monitoring_events.ts @@ -302,7 +302,7 @@ function extractReply(command: WriteProtocolMessageType, reply?: Document) { return deepCopy(reply.result ? reply.result : reply); } -export function extractConnectionDetails(connection: Connection) { +function extractConnectionDetails(connection: Connection) { let connectionId; if ('id' in connection) { connectionId = connection.id; diff --git a/test/unit/index.test.ts b/test/unit/index.test.ts index d826dbc52d..0cc38a0941 100644 --- a/test/unit/index.test.ts +++ b/test/unit/index.test.ts @@ -116,6 +116,7 @@ const EXPECTED_EXPORTS = [ 'ServerApiVersion', 'ServerClosedEvent', 'ServerDescriptionChangedEvent', + 'ServerDiscoveryAndMonitoringEvent', 'ServerHeartbeatFailedEvent', 'ServerHeartbeatStartedEvent', 'ServerHeartbeatSucceededEvent', From be7aee9266f74ebe3608d0277c78c2a69d8077c8 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Thu, 7 Dec 2023 14:30:00 -0500 Subject: [PATCH 09/22] PR requested changes --- src/mongo_logger.ts | 6 +++--- src/mongo_types.ts | 2 +- src/sdam/events.ts | 10 +++++----- src/sdam/monitor.ts | 13 +++++-------- src/sdam/server.ts | 2 +- .../unified/logging-replicaset.json | 9 --------- .../unified/logging-replicaset.yml | 3 --- .../unified/logging-sharded.json | 3 --- .../unified/logging-sharded.yml | 1 - .../unified/logging-standalone.json | 3 --- test/unit/sdam/monitor.test.ts | 4 +++- 11 files changed, 18 insertions(+), 38 deletions(-) diff --git a/src/mongo_logger.ts b/src/mongo_logger.ts index d73e61dadd..2aada1c8ef 100644 --- a/src/mongo_logger.ts +++ b/src/mongo_logger.ts @@ -358,9 +358,9 @@ function attachCommandFields( function attachConnectionFields( log: Record, - connectionOrSDAMEvent: ConnectionPoolMonitoringEvent | ServerOpeningEvent | ServerClosedEvent + event: ConnectionPoolMonitoringEvent | ServerOpeningEvent | ServerClosedEvent ) { - const { host, port } = HostAddress.fromString(connectionOrSDAMEvent.address).toHostPort(); + const { host, port } = HostAddress.fromString(event.address).toHostPort(); log.serverHost = host; log.serverPort = port; @@ -381,7 +381,7 @@ function attachServerHeartbeatFields( ) { const { awaited, connectionId } = serverHeartbeatEvent; log.awaited = awaited; - log.driverConnectionId = 1; + log.driverConnectionId = serverHeartbeatEvent.connectionId; const { host, port } = HostAddress.fromString(connectionId).toHostPort(); log.serverHost = host; log.serverPort = port; diff --git a/src/mongo_types.ts b/src/mongo_types.ts index c149101b5e..ce814dd67b 100644 --- a/src/mongo_types.ts +++ b/src/mongo_types.ts @@ -410,7 +410,7 @@ export class TypedEventEmitter extends EventEm ...args: Parameters ): void { this.emit(event, ...args); - if (this.component) this.mongoLogger?.debug(this.component, args[0]); + if (this.component) this.mongoLogger?.debug?.(this.component, args[0]); } } diff --git a/src/sdam/events.ts b/src/sdam/events.ts index 5bb85b66bf..ab950c5ff7 100644 --- a/src/sdam/events.ts +++ b/src/sdam/events.ts @@ -175,7 +175,7 @@ export class ServerHeartbeatStartedEvent extends ServerDiscoveryAndMonitoringEve name = SERVER_HEARTBEAT_STARTED; /** @internal */ - constructor(connectionId: string, awaited: boolean, topologyId: number) { + constructor(topologyId: number, connectionId: string, awaited: boolean) { super(topologyId); this.connectionId = connectionId; this.awaited = awaited; @@ -201,11 +201,11 @@ export class ServerHeartbeatSucceededEvent extends ServerDiscoveryAndMonitoringE /** @internal */ constructor( + topologyId: number, connectionId: string, duration: number, reply: Document | null, - awaited: boolean, - topologyId: number + awaited: boolean ) { super(topologyId); this.connectionId = connectionId; @@ -234,11 +234,11 @@ export class ServerHeartbeatFailedEvent extends ServerDiscoveryAndMonitoringEven /** @internal */ constructor( + topologyId: number, connectionId: string, duration: number, failure: Error, - awaited: boolean, - topologyId: number + awaited: boolean ) { super(topologyId); this.connectionId = connectionId; diff --git a/src/sdam/monitor.ts b/src/sdam/monitor.ts index bf37c6bc09..9f6f079260 100644 --- a/src/sdam/monitor.ts +++ b/src/sdam/monitor.ts @@ -99,8 +99,6 @@ export class Monitor extends TypedEventEmitter { [kMonitorId]?: MonitorInterval; rttPinger?: RTTPinger; /** @internal */ - override mongoLogger: MongoLogger; - /** @internal */ override component = MongoLoggableComponent.TOPOLOGY; get connection(): Connection | undefined { @@ -126,6 +124,7 @@ export class Monitor extends TypedEventEmitter { serverMonitoringMode: options.serverMonitoringMode }); this.isRunningInFaasEnv = getFAASEnv() != null; + this.mongoLogger = this[kServer].topology.client.mongoLogger; const cancellationToken = this[kCancellationToken]; // TODO: refactor this to pull it directly from the pool, requires new ConnectionPool integration @@ -152,8 +151,6 @@ export class Monitor extends TypedEventEmitter { } this.connectOptions = Object.freeze(connectOptions); - - this.mongoLogger = mongoLogger; } connect(): void { @@ -250,7 +247,7 @@ function checkServer(monitor: Monitor, callback: Callback) { const isAwaitable = useStreamingProtocol(monitor, topologyVersion); monitor.emitAndLog( Server.SERVER_HEARTBEAT_STARTED, - new ServerHeartbeatStartedEvent(monitor.address, isAwaitable, monitor[kServer].topology.s.id) + new ServerHeartbeatStartedEvent(monitor[kServer].topology.s.id, monitor.address, isAwaitable) ); function onHeartbeatFailed(err: Error) { @@ -260,11 +257,11 @@ function checkServer(monitor: Monitor, callback: Callback) { monitor.emitAndLog( Server.SERVER_HEARTBEAT_FAILED, new ServerHeartbeatFailedEvent( + monitor[kServer].topology.s.id, monitor.address, calculateDurationInMs(start), err, - awaited, - monitor[kServer].topology.s.id + awaited ) ); monitor[kConnection]?.destroy({ force: true }); @@ -384,11 +381,11 @@ function checkServer(monitor: Monitor, callback: Callback) { monitor.emit( Server.SERVER_HEARTBEAT_SUCCEEDED, new ServerHeartbeatSucceededEvent( + monitor[kServer].topology.s.id, monitor.address, calculateDurationInMs(start), conn.hello, useStreamingProtocol(monitor, conn.hello?.topologyVersion), - monitor[kServer].topology.s.id ) ); diff --git a/src/sdam/server.ts b/src/sdam/server.ts index 46b2131a87..04139c991f 100644 --- a/src/sdam/server.ts +++ b/src/sdam/server.ts @@ -178,7 +178,7 @@ export class Server extends TypedEventEmitter { } // create the monitor - this.monitor = new Monitor(this, this.s.options, this.topology.client.mongoLogger); + this.monitor = new Monitor(this, this.s.options); for (const event of HEARTBEAT_EVENTS) { this.monitor.on(event, (e: any) => this.emit(event, e)); diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json index e6738225cd..3cfcc2d880 100644 --- a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json +++ b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json @@ -352,9 +352,6 @@ "driverConnectionId": { "$$exists": true }, - "serverConnectionId": { - "$$exists": true - }, "durationMS": { "$$type": [ "int", @@ -393,9 +390,6 @@ "driverConnectionId": { "$$exists": true }, - "serverConnectionId": { - "$$exists": true - }, "durationMS": { "$$type": [ "int", @@ -434,9 +428,6 @@ "driverConnectionId": { "$$exists": true }, - "serverConnectionId": { - "$$exists": true - }, "durationMS": { "$$type": [ "int", diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml index a0b856ec72..8c32ce4b40 100644 --- a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml +++ b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml @@ -175,7 +175,6 @@ tests: serverHost: { $$type: string } serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } - serverConnectionId: { $$exists: true } durationMS: { $$type: [int, long] } reply: $$matchAsDocument: @@ -190,7 +189,6 @@ tests: serverHost: { $$type: string } serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } - serverConnectionId: { $$exists: true } durationMS: { $$type: [int, long] } reply: $$matchAsDocument: @@ -205,7 +203,6 @@ tests: serverHost: { $$type: string } serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } - serverConnectionId: { $$exists: true } durationMS: { $$type: [int, long] } reply: $$matchAsDocument: diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json index 61b27f5be0..57eb31b950 100644 --- a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json +++ b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json @@ -319,9 +319,6 @@ "driverConnectionId": { "$$exists": true }, - "serverConnectionId": { - "$$exists": true - }, "durationMS": { "$$type": [ "int", diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml index 19870878b9..556e71e8d2 100644 --- a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml +++ b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml @@ -163,7 +163,6 @@ tests: serverHost: { $$type: string } serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } - serverConnectionId: { $$exists: true } durationMS: { $$type: [int, long] } reply: $$matchAsDocument: diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json index 1b19cd781f..4c6eef3d11 100644 --- a/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json +++ b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json @@ -318,9 +318,6 @@ "driverConnectionId": { "$$exists": true }, - "serverConnectionId": { - "$$exists": false - }, "durationMS": { "$$type": [ "int", diff --git a/test/unit/sdam/monitor.test.ts b/test/unit/sdam/monitor.test.ts index 611b5206f1..270b87aa5f 100644 --- a/test/unit/sdam/monitor.test.ts +++ b/test/unit/sdam/monitor.test.ts @@ -20,10 +20,12 @@ import { createTimerSandbox } from '../timer_sandbox'; class MockServer { pool: any; description: ServerDescription; + topology: any; constructor(options) { this.pool = { generation: 1 }; this.description = new ServerDescription(`${options.host}:${options.port}`); this.description.type = ServerType.Unknown; + this.topology = { s: { topologyId: 1 }, client: { mongoLogger: {} } }; } } @@ -123,7 +125,7 @@ describe('monitoring', function () { }); }).skipReason = 'TODO(NODE-3600): Unskip flaky tests'; - describe('Monitor', function () { + describe.only('Monitor', function () { let monitor; beforeEach(() => { From 4cab947b93c86c704bdd47e92b464a0c794e7501 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Thu, 7 Dec 2023 14:40:37 -0500 Subject: [PATCH 10/22] lint fix --- src/sdam/monitor.ts | 4 ++-- test/unit/sdam/monitor.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdam/monitor.ts b/src/sdam/monitor.ts index 9f6f079260..b711484240 100644 --- a/src/sdam/monitor.ts +++ b/src/sdam/monitor.ts @@ -6,7 +6,7 @@ import { Connection, type ConnectionOptions } from '../cmap/connection'; import { getFAASEnv } from '../cmap/handshake/client_metadata'; import { LEGACY_HELLO_COMMAND } from '../constants'; import { MongoError, MongoErrorLabel, MongoNetworkTimeoutError } from '../error'; -import { MongoLoggableComponent, type MongoLogger } from '../mongo_logger'; +import { MongoLoggableComponent } from '../mongo_logger'; import { CancellationToken, TypedEventEmitter } from '../mongo_types'; import type { Callback, EventEmitterWithState } from '../utils'; import { calculateDurationInMs, makeStateMachine, now, ns } from '../utils'; @@ -385,7 +385,7 @@ function checkServer(monitor: Monitor, callback: Callback) { monitor.address, calculateDurationInMs(start), conn.hello, - useStreamingProtocol(monitor, conn.hello?.topologyVersion), + useStreamingProtocol(monitor, conn.hello?.topologyVersion) ) ); diff --git a/test/unit/sdam/monitor.test.ts b/test/unit/sdam/monitor.test.ts index 270b87aa5f..a1c203ad7a 100644 --- a/test/unit/sdam/monitor.test.ts +++ b/test/unit/sdam/monitor.test.ts @@ -125,7 +125,7 @@ describe('monitoring', function () { }); }).skipReason = 'TODO(NODE-3600): Unskip flaky tests'; - describe.only('Monitor', function () { + describe('Monitor', function () { let monitor; beforeEach(() => { From b1e2d425fc5231458ebbdd2172466735c4ff3713 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Thu, 7 Dec 2023 17:09:23 -0500 Subject: [PATCH 11/22] fixed unit tests --- src/mongo_types.ts | 2 +- test/unit/sdam/monitor.test.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mongo_types.ts b/src/mongo_types.ts index ce814dd67b..c149101b5e 100644 --- a/src/mongo_types.ts +++ b/src/mongo_types.ts @@ -410,7 +410,7 @@ export class TypedEventEmitter extends EventEm ...args: Parameters ): void { this.emit(event, ...args); - if (this.component) this.mongoLogger?.debug?.(this.component, args[0]); + if (this.component) this.mongoLogger?.debug(this.component, args[0]); } } diff --git a/test/unit/sdam/monitor.test.ts b/test/unit/sdam/monitor.test.ts index a1c203ad7a..a652601274 100644 --- a/test/unit/sdam/monitor.test.ts +++ b/test/unit/sdam/monitor.test.ts @@ -25,7 +25,16 @@ class MockServer { this.pool = { generation: 1 }; this.description = new ServerDescription(`${options.host}:${options.port}`); this.description.type = ServerType.Unknown; - this.topology = { s: { topologyId: 1 }, client: { mongoLogger: {} } }; + this.topology = { + s: { topologyId: 1 }, + client: { + mongoLogger: { + debug: function (_v: any, _x: any) { + return; + } + } + } + }; } } From 61baff7484691fda00ed6c8f22c15215440b6356 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Fri, 8 Dec 2023 13:28:28 -0500 Subject: [PATCH 12/22] rebase --- src/sdam/monitor.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/sdam/monitor.ts b/src/sdam/monitor.ts index b711484240..e93fba19d6 100644 --- a/src/sdam/monitor.ts +++ b/src/sdam/monitor.ts @@ -101,10 +101,6 @@ export class Monitor extends TypedEventEmitter { /** @internal */ override component = MongoLoggableComponent.TOPOLOGY; - get connection(): Connection | undefined { - return this[kConnection]; - } - constructor(server: Server, options: MonitorOptions) { super(); @@ -264,8 +260,6 @@ function checkServer(monitor: Monitor, callback: Callback) { awaited ) ); - monitor[kConnection]?.destroy({ force: true }); - monitor[kConnection] = undefined; const error = !(err instanceof MongoError) ? new MongoError(MongoError.buildErrorMessage(err), { cause: err }) @@ -290,17 +284,23 @@ function checkServer(monitor: Monitor, callback: Callback) { ? monitor.rttPinger.roundTripTime : calculateDurationInMs(start); - monitor.emit( + monitor.emitAndLog( Server.SERVER_HEARTBEAT_SUCCEEDED, - new ServerHeartbeatSucceededEvent(monitor.address, duration, hello, isAwaitable) + new ServerHeartbeatSucceededEvent( + monitor[kServer].topology.s.id, + monitor.address, + duration, + hello, + isAwaitable + ) ); // If we are using the streaming protocol then we immediately issue another 'started' // event, otherwise the "check" is complete and return to the main monitor loop. if (isAwaitable) { - monitor.emit( + monitor.emitAndLog( Server.SERVER_HEARTBEAT_STARTED, - new ServerHeartbeatStartedEvent(monitor.address, true) + new ServerHeartbeatStartedEvent(monitor[kServer].topology.s.id, monitor.address, true) ); start = now(); } else { @@ -378,7 +378,7 @@ function checkServer(monitor: Monitor, callback: Callback) { } monitor.connection = conn; - monitor.emit( + monitor.emitAndLog( Server.SERVER_HEARTBEAT_SUCCEEDED, new ServerHeartbeatSucceededEvent( monitor[kServer].topology.s.id, From a240724ca7d450d50320130358b9e495a98816de Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Fri, 8 Dec 2023 16:25:38 -0500 Subject: [PATCH 13/22] Added driverConnectionId and emitAndLogHeartbeat() function --- src/index.ts | 4 +- src/mongo_logger.ts | 62 ++++-- src/mongo_types.ts | 13 ++ src/sdam/events.ts | 88 +++----- src/sdam/monitor.ts | 41 ++-- ...rver_discovery_and_monitoring.spec.test.ts | 4 +- .../unified-logging/logging-standalone.json | 196 ++++++++++++++++++ .../unified-logging/logging-standalone.yml | 98 +++++++++ .../unified/logging-replicaset.json | 9 + .../unified/logging-replicaset.yml | 3 + .../unified/logging-sharded.json | 3 + .../unified/logging-sharded.yml | 1 + .../unified/logging-standalone.json | 19 ++ .../unified/logging-standalone.yml | 8 + 14 files changed, 451 insertions(+), 98 deletions(-) create mode 100644 test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.json create mode 100644 test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.yml diff --git a/src/index.ts b/src/index.ts index 1b1566d9f4..06ccc1bee2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -139,7 +139,6 @@ export { export { ServerClosedEvent, ServerDescriptionChangedEvent, - ServerDiscoveryAndMonitoringEvent, ServerHeartbeatFailedEvent, ServerHeartbeatStartedEvent, ServerHeartbeatSucceededEvent, @@ -367,6 +366,9 @@ export type { LogConvertible, Loggable, LoggableEvent, + LoggableServerHeartbeatFailedEvent, + LoggableServerHeartbeatStartedEvent, + LoggableServerHeartbeatSucceededEvent, MongoDBLogWritable, MongoLoggableComponent, MongoLogger, diff --git a/src/mongo_logger.ts b/src/mongo_logger.ts index 2aada1c8ef..c155e4e2f6 100644 --- a/src/mongo_logger.ts +++ b/src/mongo_logger.ts @@ -1,4 +1,4 @@ -import { EJSON } from 'bson'; +import { type Document, EJSON } from 'bson'; import type { Writable } from 'stream'; import { inspect } from 'util'; @@ -47,11 +47,6 @@ import { } from './constants'; import type { ServerClosedEvent, - ServerDescriptionChangedEvent, - ServerDiscoveryAndMonitoringEvent, - ServerHeartbeatFailedEvent, - ServerHeartbeatStartedEvent, - ServerHeartbeatSucceededEvent, ServerOpeningEvent, TopologyClosedEvent, TopologyDescriptionChangedEvent, @@ -290,6 +285,45 @@ function compareSeverity(s0: SeverityLevel, s1: SeverityLevel): 1 | 0 | -1 { return s0Num < s1Num ? -1 : s0Num > s1Num ? 1 : 0; } +/** @internal */ +export type LoggableServerHeartbeatStartedEvent = { + topologyId: number; + awaited: boolean; + connectionId: string; + name: typeof SERVER_HEARTBEAT_STARTED; +}; + +/** @internal */ +export type LoggableServerHeartbeatSucceededEvent = { + topologyId: number; + awaited: boolean; + connectionId: string; + reply: Document; + serverConnectionId: number | ''; + duration: number; + name: typeof SERVER_HEARTBEAT_SUCCEEDED; +}; + +/** @internal */ +export type LoggableServerHeartbeatFailedEvent = { + topologyId: number; + awaited: boolean; + connectionId: string; + failure: Error; + duration: number; + name: typeof SERVER_HEARTBEAT_FAILED; +}; + +type SDAMLoggableEvent = + | ServerClosedEvent + | LoggableServerHeartbeatFailedEvent + | LoggableServerHeartbeatStartedEvent + | LoggableServerHeartbeatSucceededEvent + | ServerOpeningEvent + | TopologyClosedEvent + | TopologyDescriptionChangedEvent + | TopologyOpeningEvent; + /** @internal */ export type LoggableEvent = | CommandStartedEvent @@ -307,10 +341,9 @@ export type LoggableEvent = | ConnectionCheckOutStartedEvent | ConnectionCheckOutFailedEvent | ServerClosedEvent - | ServerDescriptionChangedEvent - | ServerHeartbeatFailedEvent - | ServerHeartbeatStartedEvent - | ServerHeartbeatSucceededEvent + | LoggableServerHeartbeatFailedEvent + | LoggableServerHeartbeatStartedEvent + | LoggableServerHeartbeatSucceededEvent | ServerOpeningEvent | TopologyClosedEvent | TopologyDescriptionChangedEvent @@ -367,7 +400,7 @@ function attachConnectionFields( return log; } -function attachSDAMFields(log: Record, sdamEvent: ServerDiscoveryAndMonitoringEvent) { +function attachSDAMFields(log: Record, sdamEvent: SDAMLoggableEvent) { log.topologyId = sdamEvent.topologyId; return log; } @@ -375,9 +408,9 @@ function attachSDAMFields(log: Record, sdamEvent: ServerDiscoveryAn function attachServerHeartbeatFields( log: Record, serverHeartbeatEvent: - | ServerHeartbeatFailedEvent - | ServerHeartbeatStartedEvent - | ServerHeartbeatSucceededEvent + | LoggableServerHeartbeatFailedEvent + | LoggableServerHeartbeatStartedEvent + | LoggableServerHeartbeatSucceededEvent ) { const { awaited, connectionId } = serverHeartbeatEvent; log.awaited = awaited; @@ -533,6 +566,7 @@ function defaultLogTransform( log = attachServerHeartbeatFields(log, logObject); log.message = 'Server heartbeat succeeded'; log.durationMS = logObject.duration; + log.serverConnectionId = logObject.serverConnectionId; log.reply = stringifyWithMaxLen(logObject.reply, maxDocumentLength); return log; case SERVER_HEARTBEAT_FAILED: diff --git a/src/mongo_types.ts b/src/mongo_types.ts index c149101b5e..1e732a789f 100644 --- a/src/mongo_types.ts +++ b/src/mongo_types.ts @@ -412,6 +412,19 @@ export class TypedEventEmitter extends EventEm this.emit(event, ...args); if (this.component) this.mongoLogger?.debug(this.component, args[0]); } + emitAndLogHeartbeat( + event: EventKey | symbol, + topologyId: number, + serverConnectionId?: number | '', + ...args: Parameters + ): void { + this.emit(event, ...args); + if (this.component) { + args[0].topologyId = topologyId; + args[0].serverConnectionId = serverConnectionId ?? null; + this.mongoLogger?.debug(this.component, args[0]); + } + } } /** @public */ diff --git a/src/sdam/events.ts b/src/sdam/events.ts index ab950c5ff7..7c4a63b3a9 100644 --- a/src/sdam/events.ts +++ b/src/sdam/events.ts @@ -14,38 +14,13 @@ import type { ServerDescription } from './server_description'; import type { TopologyDescription } from './topology_description'; /** - * The base export class for all monitoring events published from server discovery and monitoring. + * Emitted when server description changes, but does NOT include changes to the RTT. * @public * @category Event */ -export abstract class ServerDiscoveryAndMonitoringEvent { +export class ServerDescriptionChangedEvent { /** A unique identifier for the topology */ topologyId: number; - - /** @internal */ - abstract name: - | typeof TOPOLOGY_CLOSED - | typeof TOPOLOGY_DESCRIPTION_CHANGED - | typeof TOPOLOGY_OPENING - | typeof SERVER_OPENING - | typeof SERVER_CLOSED - | typeof SERVER_DESCRIPTION_CHANGED - | typeof SERVER_HEARTBEAT_FAILED - | typeof SERVER_HEARTBEAT_STARTED - | typeof SERVER_HEARTBEAT_SUCCEEDED; - - /** @internal */ - constructor(topologyId: number) { - this.topologyId = topologyId; - } -} - -/** - * Emitted when server description changes, but does NOT include changes to the RTT. - * @public - * @category Event - */ -export class ServerDescriptionChangedEvent extends ServerDiscoveryAndMonitoringEvent { /** The address (host/port pair) of the server */ address: string; /** The previous server description */ @@ -61,7 +36,7 @@ export class ServerDescriptionChangedEvent extends ServerDiscoveryAndMonitoringE previousDescription: ServerDescription, newDescription: ServerDescription ) { - super(topologyId); + this.topologyId = topologyId; this.address = address; this.previousDescription = previousDescription; this.newDescription = newDescription; @@ -73,7 +48,9 @@ export class ServerDescriptionChangedEvent extends ServerDiscoveryAndMonitoringE * @public * @category Event */ -export class ServerOpeningEvent extends ServerDiscoveryAndMonitoringEvent { +export class ServerOpeningEvent { + /** A unique identifier for the topology */ + topologyId: number; /** The address (host/port pair) of the server */ address: string; /** @internal */ @@ -81,7 +58,7 @@ export class ServerOpeningEvent extends ServerDiscoveryAndMonitoringEvent { /** @internal */ constructor(topologyId: number, address: string) { - super(topologyId); + this.topologyId = topologyId; this.address = address; } } @@ -91,7 +68,9 @@ export class ServerOpeningEvent extends ServerDiscoveryAndMonitoringEvent { * @public * @category Event */ -export class ServerClosedEvent extends ServerDiscoveryAndMonitoringEvent { +export class ServerClosedEvent { + /** A unique identifier for the topology */ + topologyId: number; /** The address (host/port pair) of the server */ address: string; /** @internal */ @@ -99,7 +78,7 @@ export class ServerClosedEvent extends ServerDiscoveryAndMonitoringEvent { /** @internal */ constructor(topologyId: number, address: string) { - super(topologyId); + this.topologyId = topologyId; this.address = address; } } @@ -109,7 +88,9 @@ export class ServerClosedEvent extends ServerDiscoveryAndMonitoringEvent { * @public * @category Event */ -export class TopologyDescriptionChangedEvent extends ServerDiscoveryAndMonitoringEvent { +export class TopologyDescriptionChangedEvent { + /** A unique identifier for the topology */ + topologyId: number; /** The old topology description */ previousDescription: TopologyDescription; /** The new topology description */ @@ -123,7 +104,7 @@ export class TopologyDescriptionChangedEvent extends ServerDiscoveryAndMonitorin previousDescription: TopologyDescription, newDescription: TopologyDescription ) { - super(topologyId); + this.topologyId = topologyId; this.previousDescription = previousDescription; this.newDescription = newDescription; } @@ -134,13 +115,15 @@ export class TopologyDescriptionChangedEvent extends ServerDiscoveryAndMonitorin * @public * @category Event */ -export class TopologyOpeningEvent extends ServerDiscoveryAndMonitoringEvent { +export class TopologyOpeningEvent { + /** A unique identifier for the topology */ + topologyId: number; /** @internal */ name = TOPOLOGY_OPENING; /** @internal */ constructor(topologyId: number) { - super(topologyId); + this.topologyId = topologyId; } } @@ -149,13 +132,15 @@ export class TopologyOpeningEvent extends ServerDiscoveryAndMonitoringEvent { * @public * @category Event */ -export class TopologyClosedEvent extends ServerDiscoveryAndMonitoringEvent { +export class TopologyClosedEvent { + /** A unique identifier for the topology */ + topologyId: number; /** @internal */ name = TOPOLOGY_CLOSED; /** @internal */ constructor(topologyId: number) { - super(topologyId); + this.topologyId = topologyId; } } @@ -166,7 +151,7 @@ export class TopologyClosedEvent extends ServerDiscoveryAndMonitoringEvent { * @public * @category Event */ -export class ServerHeartbeatStartedEvent extends ServerDiscoveryAndMonitoringEvent { +export class ServerHeartbeatStartedEvent { /** The connection id for the command */ connectionId: string; /** Is true when using the streaming protocol */ @@ -175,8 +160,7 @@ export class ServerHeartbeatStartedEvent extends ServerDiscoveryAndMonitoringEve name = SERVER_HEARTBEAT_STARTED; /** @internal */ - constructor(topologyId: number, connectionId: string, awaited: boolean) { - super(topologyId); + constructor(connectionId: string, awaited: boolean) { this.connectionId = connectionId; this.awaited = awaited; } @@ -187,7 +171,7 @@ export class ServerHeartbeatStartedEvent extends ServerDiscoveryAndMonitoringEve * @public * @category Event */ -export class ServerHeartbeatSucceededEvent extends ServerDiscoveryAndMonitoringEvent { +export class ServerHeartbeatSucceededEvent { /** The connection id for the command */ connectionId: string; /** The execution time of the event in ms */ @@ -200,14 +184,7 @@ export class ServerHeartbeatSucceededEvent extends ServerDiscoveryAndMonitoringE name = SERVER_HEARTBEAT_SUCCEEDED; /** @internal */ - constructor( - topologyId: number, - connectionId: string, - duration: number, - reply: Document | null, - awaited: boolean - ) { - super(topologyId); + constructor(connectionId: string, duration: number, reply: Document | null, awaited: boolean) { this.connectionId = connectionId; this.duration = duration; this.reply = reply ?? {}; @@ -220,7 +197,7 @@ export class ServerHeartbeatSucceededEvent extends ServerDiscoveryAndMonitoringE * @public * @category Event */ -export class ServerHeartbeatFailedEvent extends ServerDiscoveryAndMonitoringEvent { +export class ServerHeartbeatFailedEvent { /** The connection id for the command */ connectionId: string; /** The execution time of the event in ms */ @@ -233,14 +210,7 @@ export class ServerHeartbeatFailedEvent extends ServerDiscoveryAndMonitoringEven name = SERVER_HEARTBEAT_FAILED; /** @internal */ - constructor( - topologyId: number, - connectionId: string, - duration: number, - failure: Error, - awaited: boolean - ) { - super(topologyId); + constructor(connectionId: string, duration: number, failure: Error, awaited: boolean) { this.connectionId = connectionId; this.duration = duration; this.failure = failure; diff --git a/src/sdam/monitor.ts b/src/sdam/monitor.ts index e93fba19d6..d433ac03e6 100644 --- a/src/sdam/monitor.ts +++ b/src/sdam/monitor.ts @@ -241,24 +241,22 @@ function checkServer(monitor: Monitor, callback: Callback) { let awaited: boolean; const topologyVersion = monitor[kServer].description.topologyVersion; const isAwaitable = useStreamingProtocol(monitor, topologyVersion); - monitor.emitAndLog( + monitor.emitAndLogHeartbeat( Server.SERVER_HEARTBEAT_STARTED, - new ServerHeartbeatStartedEvent(monitor[kServer].topology.s.id, monitor.address, isAwaitable) + monitor[kServer].topology.s.id, + undefined, + new ServerHeartbeatStartedEvent(monitor.address, isAwaitable) ); function onHeartbeatFailed(err: Error) { monitor.connection?.destroy({ force: true }); monitor.connection = null; - monitor.emitAndLog( + monitor.emitAndLogHeartbeat( Server.SERVER_HEARTBEAT_FAILED, - new ServerHeartbeatFailedEvent( - monitor[kServer].topology.s.id, - monitor.address, - calculateDurationInMs(start), - err, - awaited - ) + monitor[kServer].topology.s.id, + undefined, + new ServerHeartbeatFailedEvent(monitor.address, calculateDurationInMs(start), err, awaited) ); const error = !(err instanceof MongoError) @@ -284,23 +282,21 @@ function checkServer(monitor: Monitor, callback: Callback) { ? monitor.rttPinger.roundTripTime : calculateDurationInMs(start); - monitor.emitAndLog( + monitor.emitAndLogHeartbeat( Server.SERVER_HEARTBEAT_SUCCEEDED, - new ServerHeartbeatSucceededEvent( - monitor[kServer].topology.s.id, - monitor.address, - duration, - hello, - isAwaitable - ) + monitor[kServer].topology.s.id, + hello.connectionId, + new ServerHeartbeatSucceededEvent(monitor.address, duration, hello, isAwaitable) ); // If we are using the streaming protocol then we immediately issue another 'started' // event, otherwise the "check" is complete and return to the main monitor loop. if (isAwaitable) { - monitor.emitAndLog( + monitor.emitAndLogHeartbeat( Server.SERVER_HEARTBEAT_STARTED, - new ServerHeartbeatStartedEvent(monitor[kServer].topology.s.id, monitor.address, true) + monitor[kServer].topology.s.id, + undefined, + new ServerHeartbeatStartedEvent(monitor.address, true) ); start = now(); } else { @@ -378,10 +374,11 @@ function checkServer(monitor: Monitor, callback: Callback) { } monitor.connection = conn; - monitor.emitAndLog( + monitor.emitAndLogHeartbeat( Server.SERVER_HEARTBEAT_SUCCEEDED, + monitor[kServer].topology.s.id, + conn.id, new ServerHeartbeatSucceededEvent( - monitor[kServer].topology.s.id, monitor.address, calculateDurationInMs(start), conn.hello, diff --git a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts index 74fc67efc6..b522a59503 100644 --- a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts +++ b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts @@ -3,6 +3,6 @@ import * as path from 'path'; import { loadSpecTests } from '../../spec'; import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; -describe('SDAM Unified Tests', function () { - runUnifiedSuite(loadSpecTests(path.join('server-discovery-and-monitoring', 'unified'))); +describe.only('SDAM Unified Tests', function () { + runUnifiedSuite(loadSpecTests(path.join('server-discovery-and-monitoring', 'unified-logging'))); }); diff --git a/test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.json b/test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.json new file mode 100644 index 0000000000..b118dfc580 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.json @@ -0,0 +1,196 @@ +{ + "description": "standalone-logging", + "schemaVersion": "1.16", + "runOnRequirements": [ + { + "topologies": [ + "single" + ], + "minServerVersion": "4.4" + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient" + } + } + ], + "tests": [ + { + "description": "Topology lifecycle", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "topologyDescriptionChangedEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "topologyDescriptionChangedEvent": {} + }, + "count": 2 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring", + "topologyId": { + "$$exists": true + } + } + } + ] + } + ] + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.yml b/test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.yml new file mode 100644 index 0000000000..ac469cde06 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.yml @@ -0,0 +1,98 @@ +description: "standalone-logging" + +schemaVersion: "1.16" + +runOnRequirements: + - topologies: + - single + minServerVersion: "4.4" # awaitable hello + +createEntities: + - client: + id: &setupClient setupClient + +tests: + - description: "Topology lifecycle" + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeLogMessages: + topology: debug + observeEvents: + - topologyDescriptionChangedEvent + # ensure the topology has been fully discovered before closing the client. + # expected events are initial server discovery and server connect event. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + topologyDescriptionChangedEvent: {} + count: 2 + - name: close + object: *client + expectLogMessages: + - client: *client + ignoreMessages: + - level: debug + component: topology + data: + message: "Server heartbeat started" + - level: debug + component: topology + data: + message: "Server heartbeat succeeded" + - level: debug + component: topology + data: + message: "Server heartbeat failed" + messages: + - level: debug + component: topology + data: + message: "Starting topology monitoring" + topologyId: { $$exists: true } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # unknown topology + newDescription: { $$exists: true } # unknown topology, disconnected server + - level: debug + component: topology + data: + message: "Starting server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } + newDescription: { $$exists: true } # standalone topology + - level: debug + component: topology + data: + message: "Stopped server monitoring" + topologyId: { $$exists: true } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # standalone topology + newDescription: { $$exists: true } # unknown topology + - level: debug + component: topology + data: + message: "Stopped topology monitoring" + topologyId: { $$exists: true } \ No newline at end of file diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json index 3cfcc2d880..e6738225cd 100644 --- a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json +++ b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.json @@ -352,6 +352,9 @@ "driverConnectionId": { "$$exists": true }, + "serverConnectionId": { + "$$exists": true + }, "durationMS": { "$$type": [ "int", @@ -390,6 +393,9 @@ "driverConnectionId": { "$$exists": true }, + "serverConnectionId": { + "$$exists": true + }, "durationMS": { "$$type": [ "int", @@ -428,6 +434,9 @@ "driverConnectionId": { "$$exists": true }, + "serverConnectionId": { + "$$exists": true + }, "durationMS": { "$$type": [ "int", diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml index 8c32ce4b40..a0b856ec72 100644 --- a/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml +++ b/test/spec/server-discovery-and-monitoring/unified/logging-replicaset.yml @@ -175,6 +175,7 @@ tests: serverHost: { $$type: string } serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } durationMS: { $$type: [int, long] } reply: $$matchAsDocument: @@ -189,6 +190,7 @@ tests: serverHost: { $$type: string } serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } durationMS: { $$type: [int, long] } reply: $$matchAsDocument: @@ -203,6 +205,7 @@ tests: serverHost: { $$type: string } serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } durationMS: { $$type: [int, long] } reply: $$matchAsDocument: diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json index 57eb31b950..61b27f5be0 100644 --- a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json +++ b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.json @@ -319,6 +319,9 @@ "driverConnectionId": { "$$exists": true }, + "serverConnectionId": { + "$$exists": true + }, "durationMS": { "$$type": [ "int", diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml index 556e71e8d2..19870878b9 100644 --- a/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml +++ b/test/spec/server-discovery-and-monitoring/unified/logging-sharded.yml @@ -163,6 +163,7 @@ tests: serverHost: { $$type: string } serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } durationMS: { $$type: [int, long] } reply: $$matchAsDocument: diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json index 4c6eef3d11..1ee6dbe899 100644 --- a/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json +++ b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.json @@ -162,6 +162,22 @@ } } }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, { "level": "debug", "component": "topology", @@ -318,6 +334,9 @@ "driverConnectionId": { "$$exists": true }, + "serverConnectionId": { + "$$exists": true + }, "durationMS": { "$$type": [ "int", diff --git a/test/spec/server-discovery-and-monitoring/unified/logging-standalone.yml b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.yml index a7453c2d3b..80cf98a20e 100644 --- a/test/spec/server-discovery-and-monitoring/unified/logging-standalone.yml +++ b/test/spec/server-discovery-and-monitoring/unified/logging-standalone.yml @@ -84,6 +84,13 @@ tests: topologyId: { $$exists: true } serverHost: { $$type: string } serverPort: { $$type: [int, long] } + - level: debug + component: topology + data: + message: "Topology description changed" + topologyId: { $$exists: true } + previousDescription: { $$exists: true } # standalone topology + newDescription: { $$exists: true } # unknown topology - level: debug component: topology data: @@ -161,6 +168,7 @@ tests: serverHost: { $$type: string } serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } + serverConnectionId: { $$exists: true } durationMS: { $$type: [int, long] } reply: $$matchAsDocument: From 00ab2959e6569e5f155dab74a17645fc1754955c Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Fri, 8 Dec 2023 16:54:11 -0500 Subject: [PATCH 14/22] Lint fixes --- ...rver_discovery_and_monitoring.spec.test.ts | 4 +- .../unified-logging/logging-standalone.json | 196 ------------------ .../unified-logging/logging-standalone.yml | 98 --------- 3 files changed, 2 insertions(+), 296 deletions(-) delete mode 100644 test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.json delete mode 100644 test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.yml diff --git a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts index b522a59503..74fc67efc6 100644 --- a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts +++ b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts @@ -3,6 +3,6 @@ import * as path from 'path'; import { loadSpecTests } from '../../spec'; import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; -describe.only('SDAM Unified Tests', function () { - runUnifiedSuite(loadSpecTests(path.join('server-discovery-and-monitoring', 'unified-logging'))); +describe('SDAM Unified Tests', function () { + runUnifiedSuite(loadSpecTests(path.join('server-discovery-and-monitoring', 'unified'))); }); diff --git a/test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.json b/test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.json deleted file mode 100644 index b118dfc580..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.json +++ /dev/null @@ -1,196 +0,0 @@ -{ - "description": "standalone-logging", - "schemaVersion": "1.16", - "runOnRequirements": [ - { - "topologies": [ - "single" - ], - "minServerVersion": "4.4" - } - ], - "createEntities": [ - { - "client": { - "id": "setupClient" - } - } - ], - "tests": [ - { - "description": "Topology lifecycle", - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "observeLogMessages": { - "topology": "debug" - }, - "observeEvents": [ - "topologyDescriptionChangedEvent" - ] - } - } - ] - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "topologyDescriptionChangedEvent": {} - }, - "count": 2 - } - }, - { - "name": "close", - "object": "client" - } - ], - "expectLogMessages": [ - { - "client": "client", - "ignoreMessages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat started" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat succeeded" - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Server heartbeat failed" - } - } - ], - "messages": [ - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting topology monitoring", - "topologyId": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Starting server monitoring", - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped server monitoring", - "topologyId": { - "$$exists": true - }, - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Topology description changed", - "topologyId": { - "$$exists": true - }, - "previousDescription": { - "$$exists": true - }, - "newDescription": { - "$$exists": true - } - } - }, - { - "level": "debug", - "component": "topology", - "data": { - "message": "Stopped topology monitoring", - "topologyId": { - "$$exists": true - } - } - } - ] - } - ] - } - ] -} diff --git a/test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.yml b/test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.yml deleted file mode 100644 index ac469cde06..0000000000 --- a/test/spec/server-discovery-and-monitoring/unified-logging/logging-standalone.yml +++ /dev/null @@ -1,98 +0,0 @@ -description: "standalone-logging" - -schemaVersion: "1.16" - -runOnRequirements: - - topologies: - - single - minServerVersion: "4.4" # awaitable hello - -createEntities: - - client: - id: &setupClient setupClient - -tests: - - description: "Topology lifecycle" - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - observeLogMessages: - topology: debug - observeEvents: - - topologyDescriptionChangedEvent - # ensure the topology has been fully discovered before closing the client. - # expected events are initial server discovery and server connect event. - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - topologyDescriptionChangedEvent: {} - count: 2 - - name: close - object: *client - expectLogMessages: - - client: *client - ignoreMessages: - - level: debug - component: topology - data: - message: "Server heartbeat started" - - level: debug - component: topology - data: - message: "Server heartbeat succeeded" - - level: debug - component: topology - data: - message: "Server heartbeat failed" - messages: - - level: debug - component: topology - data: - message: "Starting topology monitoring" - topologyId: { $$exists: true } - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } # unknown topology - newDescription: { $$exists: true } # unknown topology, disconnected server - - level: debug - component: topology - data: - message: "Starting server monitoring" - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } - newDescription: { $$exists: true } # standalone topology - - level: debug - component: topology - data: - message: "Stopped server monitoring" - topologyId: { $$exists: true } - serverHost: { $$type: string } - serverPort: { $$type: [int, long] } - - level: debug - component: topology - data: - message: "Topology description changed" - topologyId: { $$exists: true } - previousDescription: { $$exists: true } # standalone topology - newDescription: { $$exists: true } # unknown topology - - level: debug - component: topology - data: - message: "Stopped topology monitoring" - topologyId: { $$exists: true } \ No newline at end of file From c0e915988454d72d62283dfbfcd855b9de1545f1 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Mon, 11 Dec 2023 10:32:55 -0500 Subject: [PATCH 15/22] Lint fix --- test/unit/index.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit/index.test.ts b/test/unit/index.test.ts index 0cc38a0941..d826dbc52d 100644 --- a/test/unit/index.test.ts +++ b/test/unit/index.test.ts @@ -116,7 +116,6 @@ const EXPECTED_EXPORTS = [ 'ServerApiVersion', 'ServerClosedEvent', 'ServerDescriptionChangedEvent', - 'ServerDiscoveryAndMonitoringEvent', 'ServerHeartbeatFailedEvent', 'ServerHeartbeatStartedEvent', 'ServerHeartbeatSucceededEvent', From 69c05b1f5b80164fa320ed9b88235d4d13679cb4 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Mon, 11 Dec 2023 12:21:27 -0500 Subject: [PATCH 16/22] PR requested changes --- src/mongo_logger.ts | 15 +- src/mongo_types.ts | 19 +- src/sdam/events.ts | 12 +- src/sdam/monitor.ts | 2 +- .../server_discover_and_monitoring.test.ts | 10 + ...rver_discovery_and_monitoring.spec.test.ts | 10 +- .../logging-loadbalanced.json | 150 +++++++++++ .../logging-replicaset.json | 238 ++++++++++++++++++ .../logging-sharded.json | 206 +++++++++++++++ .../logging-standalone.json | 180 +++++++++++++ 10 files changed, 826 insertions(+), 16 deletions(-) create mode 100644 test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts create mode 100644 test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-loadbalanced.json create mode 100644 test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-replicaset.json create mode 100644 test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-sharded.json create mode 100644 test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-standalone.json diff --git a/src/mongo_logger.ts b/src/mongo_logger.ts index c155e4e2f6..1708c2b516 100644 --- a/src/mongo_logger.ts +++ b/src/mongo_logger.ts @@ -285,7 +285,10 @@ function compareSeverity(s0: SeverityLevel, s1: SeverityLevel): 1 | 0 | -1 { return s0Num < s1Num ? -1 : s0Num > s1Num ? 1 : 0; } -/** @internal */ +/** + * @internal + * Must be separate from Events API due to differences in spec requirements for logging server heartbeat beginning + */ export type LoggableServerHeartbeatStartedEvent = { topologyId: number; awaited: boolean; @@ -293,7 +296,10 @@ export type LoggableServerHeartbeatStartedEvent = { name: typeof SERVER_HEARTBEAT_STARTED; }; -/** @internal */ +/** + * @internal + * Must be separate from Events API due to differences in spec requirements for logging server heartbeat success + */ export type LoggableServerHeartbeatSucceededEvent = { topologyId: number; awaited: boolean; @@ -304,7 +310,10 @@ export type LoggableServerHeartbeatSucceededEvent = { name: typeof SERVER_HEARTBEAT_SUCCEEDED; }; -/** @internal */ +/** + * @internal + * Must be separate from Events API due to differences in spec requirements for logging server heartbeat failure + */ export type LoggableServerHeartbeatFailedEvent = { topologyId: number; awaited: boolean; diff --git a/src/mongo_types.ts b/src/mongo_types.ts index 1e732a789f..d4c00205fa 100644 --- a/src/mongo_types.ts +++ b/src/mongo_types.ts @@ -12,7 +12,13 @@ import type { ObjectId, Timestamp } from './bson'; -import type { MongoLoggableComponent, MongoLogger } from './mongo_logger'; +import type { + LoggableServerHeartbeatFailedEvent, + LoggableServerHeartbeatStartedEvent, + LoggableServerHeartbeatSucceededEvent, + MongoLoggableComponent, + MongoLogger +} from './mongo_logger'; import type { Sort } from './sort'; /** @internal */ @@ -420,9 +426,14 @@ export class TypedEventEmitter extends EventEm ): void { this.emit(event, ...args); if (this.component) { - args[0].topologyId = topologyId; - args[0].serverConnectionId = serverConnectionId ?? null; - this.mongoLogger?.debug(this.component, args[0]); + const loggableHeartbeatEvent: + | LoggableServerHeartbeatFailedEvent + | LoggableServerHeartbeatSucceededEvent + | LoggableServerHeartbeatStartedEvent = Object.assign( + { topologyId: topologyId, serverConnectionId: serverConnectionId ?? null }, + args[0] + ); + this.mongoLogger?.debug(this.component, loggableHeartbeatEvent); } } } diff --git a/src/sdam/events.ts b/src/sdam/events.ts index 7c4a63b3a9..64cb6ffb37 100644 --- a/src/sdam/events.ts +++ b/src/sdam/events.ts @@ -19,7 +19,7 @@ import type { TopologyDescription } from './topology_description'; * @category Event */ export class ServerDescriptionChangedEvent { - /** A unique identifier for the topology */ + /** A unique identifier for the topology */ topologyId: number; /** The address (host/port pair) of the server */ address: string; @@ -49,7 +49,7 @@ export class ServerDescriptionChangedEvent { * @category Event */ export class ServerOpeningEvent { - /** A unique identifier for the topology */ + /** A unique identifier for the topology */ topologyId: number; /** The address (host/port pair) of the server */ address: string; @@ -69,7 +69,7 @@ export class ServerOpeningEvent { * @category Event */ export class ServerClosedEvent { - /** A unique identifier for the topology */ + /** A unique identifier for the topology */ topologyId: number; /** The address (host/port pair) of the server */ address: string; @@ -89,7 +89,7 @@ export class ServerClosedEvent { * @category Event */ export class TopologyDescriptionChangedEvent { - /** A unique identifier for the topology */ + /** A unique identifier for the topology */ topologyId: number; /** The old topology description */ previousDescription: TopologyDescription; @@ -116,7 +116,7 @@ export class TopologyDescriptionChangedEvent { * @category Event */ export class TopologyOpeningEvent { - /** A unique identifier for the topology */ + /** A unique identifier for the topology */ topologyId: number; /** @internal */ name = TOPOLOGY_OPENING; @@ -133,7 +133,7 @@ export class TopologyOpeningEvent { * @category Event */ export class TopologyClosedEvent { - /** A unique identifier for the topology */ + /** A unique identifier for the topology */ topologyId: number; /** @internal */ name = TOPOLOGY_CLOSED; diff --git a/src/sdam/monitor.ts b/src/sdam/monitor.ts index d433ac03e6..555ffe5b56 100644 --- a/src/sdam/monitor.ts +++ b/src/sdam/monitor.ts @@ -377,7 +377,7 @@ function checkServer(monitor: Monitor, callback: Callback) { monitor.emitAndLogHeartbeat( Server.SERVER_HEARTBEAT_SUCCEEDED, monitor[kServer].topology.s.id, - conn.id, + conn.hello?.connectionId, new ServerHeartbeatSucceededEvent( monitor.address, calculateDurationInMs(start), diff --git a/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts b/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts new file mode 100644 index 0000000000..d0b3fc9944 --- /dev/null +++ b/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts @@ -0,0 +1,10 @@ +import { loadSpecTests } from '../../spec'; +import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; + +describe('SDAM Unified Tests (Node Driver)', function () { + // TODO(NODE-5723): Remove this once the actual unified tests (test/spec/server-disovery-and-monitoring/logging) are passing + const clonedAndAlteredSpecTests = loadSpecTests( + '../integration/server-discovery-and-monitoring/unified-sdam-node-specs' + ); + runUnifiedSuite(clonedAndAlteredSpecTests); +}); diff --git a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts index 74fc67efc6..085899a6b8 100644 --- a/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts +++ b/test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts @@ -3,6 +3,12 @@ import * as path from 'path'; import { loadSpecTests } from '../../spec'; import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; -describe('SDAM Unified Tests', function () { - runUnifiedSuite(loadSpecTests(path.join('server-discovery-and-monitoring', 'unified'))); +describe('SDAM Unified Tests (Spec)', function () { + const specTests = loadSpecTests(path.join('server-discovery-and-monitoring', 'unified')); + runUnifiedSuite(specTests, test => { + if (['Topology lifecycle'].includes(test.description)) { + return 'see NODE-5723'; + } + return false; + }); }); diff --git a/test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-loadbalanced.json b/test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-loadbalanced.json new file mode 100644 index 0000000000..7f4431072d --- /dev/null +++ b/test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-loadbalanced.json @@ -0,0 +1,150 @@ +{ + "description": "loadbalanced-logging-node-driver", + "schemaVersion": "1.16", + "runOnRequirements": [ + { + "topologies": [ + "load-balanced" + ], + "minServerVersion": "4.4" + } + ], + "tests": [ + { + "description": "Topology lifecycle", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "topologyDescriptionChangedEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "topologyDescriptionChangedEvent": {} + }, + "count": 2 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring", + "topologyId": { + "$$exists": true + } + } + } + ] + } + ] + } + ] +} diff --git a/test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-replicaset.json b/test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-replicaset.json new file mode 100644 index 0000000000..189d3d6866 --- /dev/null +++ b/test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-replicaset.json @@ -0,0 +1,238 @@ +{ + "description": "replicaset-logging-node-driver", + "schemaVersion": "1.16", + "runOnRequirements": [ + { + "topologies": [ + "replicaset" + ], + "minServerVersion": "4.4" + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient" + } + } + ], + "tests": [ + { + "description": "Topology lifecycle", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "topologyDescriptionChangedEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "topologyDescriptionChangedEvent": {} + }, + "count": 4 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring", + "topologyId": { + "$$exists": true + } + } + } + ] + } + ] + } + ] +} diff --git a/test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-sharded.json b/test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-sharded.json new file mode 100644 index 0000000000..4edbd5425f --- /dev/null +++ b/test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-sharded.json @@ -0,0 +1,206 @@ +{ + "description": "sharded-logging-node-driver", + "schemaVersion": "1.16", + "runOnRequirements": [ + { + "topologies": [ + "sharded" + ], + "minServerVersion": "4.4" + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "tests": [ + { + "description": "Topology lifecycle", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "topologyDescriptionChangedEvent" + ], + "useMultipleMongoses": true + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "topologyDescriptionChangedEvent": {} + }, + "count": 3 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring", + "topologyId": { + "$$exists": true + } + } + } + ] + } + ] + } + ] +} + diff --git a/test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-standalone.json b/test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-standalone.json new file mode 100644 index 0000000000..b1139d2e74 --- /dev/null +++ b/test/integration/server-discovery-and-monitoring/unified-sdam-node-specs/logging-standalone.json @@ -0,0 +1,180 @@ +{ + "description": "standalone-logging-node-driver", + "schemaVersion": "1.16", + "runOnRequirements": [ + { + "topologies": [ + "single" + ], + "minServerVersion": "4.4" + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient" + } + } + ], + "tests": [ + { + "description": "Topology lifecycle", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeLogMessages": { + "topology": "debug" + }, + "observeEvents": [ + "topologyDescriptionChangedEvent" + ] + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "topologyDescriptionChangedEvent": {} + }, + "count": 2 + } + }, + { + "name": "close", + "object": "client" + } + ], + "expectLogMessages": [ + { + "client": "client", + "ignoreMessages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat started" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat succeeded" + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Server heartbeat failed" + } + } + ], + "messages": [ + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting topology monitoring", + "topologyId": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Starting server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped server monitoring", + "topologyId": { + "$$exists": true + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Stopped topology monitoring", + "topologyId": { + "$$exists": true + } + } + } + ] + } + ] + } + ] +} From 3f0ac27ec88f3d4bd1c0bb5331551f394d23819c Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Mon, 11 Dec 2023 15:52:18 -0500 Subject: [PATCH 17/22] passing all spec tests and integration tests --- src/mongo_logger.ts | 2 +- src/mongo_types.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mongo_logger.ts b/src/mongo_logger.ts index 1708c2b516..14912ea6e7 100644 --- a/src/mongo_logger.ts +++ b/src/mongo_logger.ts @@ -576,7 +576,7 @@ function defaultLogTransform( log.message = 'Server heartbeat succeeded'; log.durationMS = logObject.duration; log.serverConnectionId = logObject.serverConnectionId; - log.reply = stringifyWithMaxLen(logObject.reply, maxDocumentLength); + log.reply = EJSON.stringify(logObject.reply, { relaxed: true }); return log; case SERVER_HEARTBEAT_FAILED: log = attachSDAMFields(log, logObject); diff --git a/src/mongo_types.ts b/src/mongo_types.ts index d4c00205fa..5029ad621f 100644 --- a/src/mongo_types.ts +++ b/src/mongo_types.ts @@ -429,10 +429,11 @@ export class TypedEventEmitter extends EventEm const loggableHeartbeatEvent: | LoggableServerHeartbeatFailedEvent | LoggableServerHeartbeatSucceededEvent - | LoggableServerHeartbeatStartedEvent = Object.assign( - { topologyId: topologyId, serverConnectionId: serverConnectionId ?? null }, - args[0] - ); + | LoggableServerHeartbeatStartedEvent = { + topologyId: topologyId, + serverConnectionId: serverConnectionId ?? null, + ...args[0] + }; this.mongoLogger?.debug(this.component, loggableHeartbeatEvent); } } From 6cd5830a5752a4317c06d12d9d2c50fca65733bb Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Mon, 11 Dec 2023 17:14:51 -0500 Subject: [PATCH 18/22] PR requested changes 2 --- src/mongo_logger.ts | 12 ++++++++---- test/tools/unified-spec-runner/entities.ts | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/mongo_logger.ts b/src/mongo_logger.ts index 14912ea6e7..affb320720 100644 --- a/src/mongo_logger.ts +++ b/src/mongo_logger.ts @@ -1,4 +1,4 @@ -import { type Document, EJSON } from 'bson'; +import { type Document, EJSON, type EJSONOptions } from 'bson'; import type { Writable } from 'stream'; import { inspect } from 'util'; @@ -364,8 +364,12 @@ export interface LogConvertible extends Record { } /** @internal */ -export function stringifyWithMaxLen(value: any, maxDocumentLength: number): string { - const ejson = EJSON.stringify(value); +export function stringifyWithMaxLen( + value: any, + maxDocumentLength: number, + options: EJSONOptions = {} +): string { + const ejson = EJSON.stringify(value, options); return maxDocumentLength !== 0 && ejson.length > maxDocumentLength ? `${ejson.slice(0, maxDocumentLength)}...` @@ -576,7 +580,7 @@ function defaultLogTransform( log.message = 'Server heartbeat succeeded'; log.durationMS = logObject.duration; log.serverConnectionId = logObject.serverConnectionId; - log.reply = EJSON.stringify(logObject.reply, { relaxed: true }); + log.reply = stringifyWithMaxLen(logObject.reply, maxDocumentLength, { relaxed: true }); return log; case SERVER_HEARTBEAT_FAILED: log = attachSDAMFields(log, logObject); diff --git a/test/tools/unified-spec-runner/entities.ts b/test/tools/unified-spec-runner/entities.ts index 5890f6a286..0b973f321c 100644 --- a/test/tools/unified-spec-runner/entities.ts +++ b/test/tools/unified-spec-runner/entities.ts @@ -226,7 +226,8 @@ export class UnifiedMongoClient extends MongoClient { [Symbol.for('@@mdb.internalLoggerConfig')]: componentSeverities, ...getEnvironmentalOptions(), ...(description.serverApi ? { serverApi: description.serverApi } : {}), - mongodbLogPath: logCollector + mongodbLogPath: logCollector, + mongodbLogMaxDocumentLength: 1250 } as any); this.logCollector = logCollector; From f778cd024b18ec4eb2e0384223a29cc35fa03c1d Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Mon, 11 Dec 2023 17:27:58 -0500 Subject: [PATCH 19/22] Added comment ' --- test/tools/unified-spec-runner/entities.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/tools/unified-spec-runner/entities.ts b/test/tools/unified-spec-runner/entities.ts index 0b973f321c..7ef0afcfbe 100644 --- a/test/tools/unified-spec-runner/entities.ts +++ b/test/tools/unified-spec-runner/entities.ts @@ -227,6 +227,7 @@ export class UnifiedMongoClient extends MongoClient { ...getEnvironmentalOptions(), ...(description.serverApi ? { serverApi: description.serverApi } : {}), mongodbLogPath: logCollector, + // TODO(NODE-5785): We need to increase the truncation length because signature.hash is a Buffer making hellos too long mongodbLogMaxDocumentLength: 1250 } as any); this.logCollector = logCollector; From add542140d40a44eb607feac304f69b9cd92b5ba Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Tue, 12 Dec 2023 15:27:25 -0500 Subject: [PATCH 20/22] PR requested chanes part 3 --- test/tools/unified-spec-runner/match.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/test/tools/unified-spec-runner/match.ts b/test/tools/unified-spec-runner/match.ts index 838804de7d..cf8657d527 100644 --- a/test/tools/unified-spec-runner/match.ts +++ b/test/tools/unified-spec-runner/match.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ -import { EJSON, Int32 } from 'bson'; +import { EJSON } from 'bson'; import { expect } from 'chai'; import { inspect } from 'util'; @@ -289,7 +289,7 @@ export function resultCheck( ) { // case to handle +0 and -0 expect(Object.is(expected, actual)).to.be.true; - } else if (actual instanceof Int32 && typeof expected === 'number') { + } else if (actual._bsontype === 'Int32' && typeof expected === 'number') { expect(actual.value).to.equal(expected); } else { expect(actual).to.equal(expected); @@ -640,14 +640,12 @@ export function filterLogs( ): ExpectedLogMessage[] { function isLogRelevant(log: ExpectedLogMessage) { for (const logToIgnore of logsToIgnore) { - if (log.level === logToIgnore.level && log.component === logToIgnore.component) { - try { - // see if log matches a log to ignore, it is not relevant - resultCheck(log.data, logToIgnore.data, entities, undefined, false); - return false; - } catch { - continue; - } + try { + // see if log matches a log to ignore, it is not relevant + resultCheck(log.data, logToIgnore.data, entities, undefined, false); + return false; + } catch { + continue; } } // if log does not match any logs to ignore, it is relevant From 3576be707f51f52eb19a3d333b009570df265b4c Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Tue, 12 Dec 2023 16:28:14 -0500 Subject: [PATCH 21/22] evergreen failure fixes --- test/tools/unified-spec-runner/match.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tools/unified-spec-runner/match.ts b/test/tools/unified-spec-runner/match.ts index cf8657d527..add9a03de4 100644 --- a/test/tools/unified-spec-runner/match.ts +++ b/test/tools/unified-spec-runner/match.ts @@ -289,7 +289,7 @@ export function resultCheck( ) { // case to handle +0 and -0 expect(Object.is(expected, actual)).to.be.true; - } else if (actual._bsontype === 'Int32' && typeof expected === 'number') { + } else if (actual && actual._bsontype === 'Int32' && typeof expected === 'number') { expect(actual.value).to.equal(expected); } else { expect(actual).to.equal(expected); From 1d6e8373a4c3baeef0ed8dbdaa5daad875d46f67 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Tue, 12 Dec 2023 17:45:41 -0500 Subject: [PATCH 22/22] emitAndLogHeartbeat is marked as internal now --- src/mongo_types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mongo_types.ts b/src/mongo_types.ts index 5029ad621f..5682ecf878 100644 --- a/src/mongo_types.ts +++ b/src/mongo_types.ts @@ -418,6 +418,7 @@ export class TypedEventEmitter extends EventEm this.emit(event, ...args); if (this.component) this.mongoLogger?.debug(this.component, args[0]); } + /** @internal */ emitAndLogHeartbeat( event: EventKey | symbol, topologyId: number,