From 4f55e37cef141149b4ea6112a429e6f4f9f9f081 Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Tue, 29 Oct 2024 16:43:28 -0400 Subject: [PATCH] Sync up load balancer specs --- .../load-balancers/README.md | 49 +++++++++++++++ .../load-balancers/cursors.json | 62 ++++++++++++++----- .../non-lb-connection-establishment.json | 1 - .../load-balancers/sdam-error-handling.json | 2 +- .../load-balancers/transactions.json | 2 +- 5 files changed, 96 insertions(+), 20 deletions(-) diff --git a/driver-core/src/test/resources/unified-test-format/load-balancers/README.md b/driver-core/src/test/resources/unified-test-format/load-balancers/README.md index e69de29bb2d..45f185caa61 100644 --- a/driver-core/src/test/resources/unified-test-format/load-balancers/README.md +++ b/driver-core/src/test/resources/unified-test-format/load-balancers/README.md @@ -0,0 +1,49 @@ +# Load Balancer Support Tests + +______________________________________________________________________ + +## Introduction + +This document describes how drivers should create load balanced clusters for testing and how tests should be executed +for such clusters. + +## Testing Requirements + +For each server version that supports load balanced clusters, drivers MUST add two Evergreen tasks: one with a sharded +cluster with both authentication and TLS enabled and one with a sharded cluster with authentication and TLS disabled. In +each task, the sharded cluster MUST be configured with two mongos nodes running on localhost ports 27017 and 27018. The +shard and config servers may run on any free ports. Each task MUST also start up two TCP load balancers operating in +round-robin mode: one fronting both mongos servers and one fronting a single mongos. + +### Load Balancer Configuration + +Drivers MUST use the `run-load-balancer.sh` script in `drivers-evergreen-tools` to start the TCP load balancers for +Evergreen tasks. This script MUST be run after the backing sharded cluster has already been started. The script writes +the URIs of the load balancers to a YAML expansions file, which can be read by drivers via the `expansions.update` +Evergreen command. This will store the URIs into the `SINGLE_MONGOS_LB_URI` and `MULTI_MONGOS_LB_URI` environment +variables. + +### Test Runner Configuration + +If the backing sharded cluster is configured with TLS enabled, drivers MUST add the relevant TLS options to both +`SINGLE_MONGOS_LB_URI` and `MULTI_MONGOS_LB_URI` to ensure that test clients can connect to the cluster. Drivers MUST +use the final URI stored in `SINGLE_MONGOS_LB_URI` (with additional TLS options if required) to configure internal +clients for test runners (e.g. the internal MongoClient described by the +[Unified Test Format spec](../../unified-test-format/unified-test-format.md)). + +In addition to modifying load balancer URIs, drivers MUST also mock server support for returning a `serviceId` field in +`hello` or legacy `hello` command responses when running tests against a load-balanced cluster. This can be done by +using the value of `topologyVersion.processId` to set `serviceId`. This MUST be done for all connections established by +the test runner, including those made by any internal clients. + +## Tests + +The YAML and JSON files in this directory contain platform-independent tests written in the +[Unified Test Format](../../unified-test-format/unified-test-format.md). Drivers MUST run the following test suites +against a load balanced cluster: + +1. All test suites written in the Unified Test Format +2. Retryable Reads +3. Retryable Writes +4. Change Streams +5. Initial DNS Seedlist Discovery diff --git a/driver-core/src/test/resources/unified-test-format/load-balancers/cursors.json b/driver-core/src/test/resources/unified-test-format/load-balancers/cursors.json index 7da08c94d6c..b11bf2c6fae 100644 --- a/driver-core/src/test/resources/unified-test-format/load-balancers/cursors.json +++ b/driver-core/src/test/resources/unified-test-format/load-balancers/cursors.json @@ -1,6 +1,6 @@ { "description": "cursors are correctly pinned to connections for load-balanced clusters", - "schemaVersion": "1.3", + "schemaVersion": "1.4", "runOnRequirements": [ { "topologies": [ @@ -222,7 +222,10 @@ "reply": { "cursor": { "id": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "firstBatch": { "$$type": "array" @@ -239,7 +242,10 @@ "commandStartedEvent": { "command": { "getMore": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "collection": "coll0" }, @@ -333,7 +339,10 @@ "reply": { "cursor": { "id": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "firstBatch": { "$$type": "array" @@ -475,7 +484,10 @@ "reply": { "cursor": { "id": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "firstBatch": { "$$type": "array" @@ -492,7 +504,10 @@ "commandStartedEvent": { "command": { "getMore": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "collection": "coll0" }, @@ -605,7 +620,10 @@ "reply": { "cursor": { "id": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "firstBatch": { "$$type": "array" @@ -750,7 +768,10 @@ "reply": { "cursor": { "id": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "firstBatch": { "$$type": "array" @@ -767,7 +788,10 @@ "commandStartedEvent": { "command": { "getMore": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "collection": "coll0" }, @@ -858,7 +882,10 @@ "commandStartedEvent": { "command": { "getMore": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "collection": "coll0" }, @@ -950,7 +977,10 @@ "commandStartedEvent": { "command": { "getMore": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "collection": { "$$type": "string" @@ -996,11 +1026,6 @@ }, { "description": "listIndexes pins the cursor to a connection", - "runOnRequirements": [ - { - "serverless": "forbid" - } - ], "operations": [ { "name": "createIndex", @@ -1105,7 +1130,10 @@ "commandStartedEvent": { "command": { "getMore": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "collection": "coll0" }, diff --git a/driver-core/src/test/resources/unified-test-format/load-balancers/non-lb-connection-establishment.json b/driver-core/src/test/resources/unified-test-format/load-balancers/non-lb-connection-establishment.json index d2d26856d97..6aaa7bdf98b 100644 --- a/driver-core/src/test/resources/unified-test-format/load-balancers/non-lb-connection-establishment.json +++ b/driver-core/src/test/resources/unified-test-format/load-balancers/non-lb-connection-establishment.json @@ -3,7 +3,6 @@ "schemaVersion": "1.3", "runOnRequirements": [ { - "minServerVersion": "3.6", "topologies": [ "single", "sharded" diff --git a/driver-core/src/test/resources/unified-test-format/load-balancers/sdam-error-handling.json b/driver-core/src/test/resources/unified-test-format/load-balancers/sdam-error-handling.json index e7282dc85a0..47323fae4f3 100644 --- a/driver-core/src/test/resources/unified-test-format/load-balancers/sdam-error-handling.json +++ b/driver-core/src/test/resources/unified-test-format/load-balancers/sdam-error-handling.json @@ -1,6 +1,6 @@ { "description": "state change errors are correctly handled", - "schemaVersion": "1.3", + "schemaVersion": "1.4", "runOnRequirements": [ { "topologies": [ diff --git a/driver-core/src/test/resources/unified-test-format/load-balancers/transactions.json b/driver-core/src/test/resources/unified-test-format/load-balancers/transactions.json index 8cf24f4ca4f..0dd04ee8540 100644 --- a/driver-core/src/test/resources/unified-test-format/load-balancers/transactions.json +++ b/driver-core/src/test/resources/unified-test-format/load-balancers/transactions.json @@ -1,6 +1,6 @@ { "description": "transactions are correctly pinned to connections for load-balanced clusters", - "schemaVersion": "1.3", + "schemaVersion": "1.4", "runOnRequirements": [ { "topologies": [