diff --git a/source/server-discovery-and-monitoring/tests/unified/serverMonitoringMode.json b/source/server-discovery-and-monitoring/tests/unified/serverMonitoringMode.json index 20bf19155b..7d681b4f9e 100644 --- a/source/server-discovery-and-monitoring/tests/unified/serverMonitoringMode.json +++ b/source/server-discovery-and-monitoring/tests/unified/serverMonitoringMode.json @@ -16,7 +16,7 @@ "description": "connect with serverMonitoringMode=auto >=4.4", "runOnRequirements": [ { - "minServerVersion": "4.4" + "minServerVersion": "4.4.0" } ], "operations": [ @@ -99,11 +99,99 @@ } ] }, + { + "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" + "minServerVersion": "4.4.0" } ], "operations": [ @@ -186,6 +274,94 @@ } ] }, + { + "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": [ diff --git a/source/server-discovery-and-monitoring/tests/unified/serverMonitoringMode.yml b/source/server-discovery-and-monitoring/tests/unified/serverMonitoringMode.yml index eae0a3aeea..28c7853d04 100644 --- a/source/server-discovery-and-monitoring/tests/unified/serverMonitoringMode.yml +++ b/source/server-discovery-and-monitoring/tests/unified/serverMonitoringMode.yml @@ -10,7 +10,7 @@ runOnRequirements: tests: - description: "connect with serverMonitoringMode=auto >=4.4" runOnRequirements: - - minServerVersion: "4.4" + - minServerVersion: "4.4.0" operations: - name: createEntities object: testRunner @@ -57,9 +57,46 @@ tests: - 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" + - minServerVersion: "4.4.0" operations: - name: createEntities object: testRunner @@ -83,6 +120,33 @@ tests: - *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 @@ -106,14 +170,4 @@ 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 + expectEvents: *pollingStartedEvents