Skip to content

Commit fea0fc7

Browse files
RUST-1790 Sync load balancer spec tests (#1423)
1 parent 9081b9d commit fea0fc7

File tree

8 files changed

+164
-88
lines changed

8 files changed

+164
-88
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Load Balancer Support Tests
2+
3+
______________________________________________________________________
4+
5+
## Introduction
6+
7+
This document describes how drivers should create load balanced clusters for testing and how tests should be executed
8+
for such clusters.
9+
10+
## Testing Requirements
11+
12+
For each server version that supports load balanced clusters, drivers MUST add two Evergreen tasks: one with a sharded
13+
cluster with both authentication and TLS enabled and one with a sharded cluster with authentication and TLS disabled. In
14+
each task, the sharded cluster MUST be configured with two mongos nodes running on localhost ports 27017 and 27018. The
15+
shard and config servers may run on any free ports. Each task MUST also start up two TCP load balancers operating in
16+
round-robin mode: one fronting both mongos servers and one fronting a single mongos.
17+
18+
### Load Balancer Configuration
19+
20+
Drivers MUST use the `run-load-balancer.sh` script in `drivers-evergreen-tools` to start the TCP load balancers for
21+
Evergreen tasks. This script MUST be run after the backing sharded cluster has already been started. The script writes
22+
the URIs of the load balancers to a YAML expansions file, which can be read by drivers via the `expansions.update`
23+
Evergreen command. This will store the URIs into the `SINGLE_MONGOS_LB_URI` and `MULTI_MONGOS_LB_URI` environment
24+
variables.
25+
26+
### Test Runner Configuration
27+
28+
If the backing sharded cluster is configured with TLS enabled, drivers MUST add the relevant TLS options to both
29+
`SINGLE_MONGOS_LB_URI` and `MULTI_MONGOS_LB_URI` to ensure that test clients can connect to the cluster. Drivers MUST
30+
use the final URI stored in `SINGLE_MONGOS_LB_URI` (with additional TLS options if required) to configure internal
31+
clients for test runners (e.g. the internal MongoClient described by the
32+
[Unified Test Format spec](../../unified-test-format/unified-test-format.md)).
33+
34+
In addition to modifying load balancer URIs, drivers MUST also mock server support for returning a `serviceId` field in
35+
`hello` or legacy `hello` command responses when running tests against a load-balanced cluster. This can be done by
36+
using the value of `topologyVersion.processId` to set `serviceId`. This MUST be done for all connections established by
37+
the test runner, including those made by any internal clients.
38+
39+
## Tests
40+
41+
The YAML and JSON files in this directory contain platform-independent tests written in the
42+
[Unified Test Format](../../unified-test-format/unified-test-format.md). Drivers MUST run the following test suites
43+
against a load balanced cluster:
44+
45+
1. All test suites written in the Unified Test Format
46+
2. Retryable Reads
47+
3. Retryable Writes
48+
4. Change Streams
49+
5. Initial DNS Seedlist Discovery

src/test/spec/json/load-balancers/README.rst

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/test/spec/json/load-balancers/cursors.json

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "cursors are correctly pinned to connections for load-balanced clusters",
3-
"schemaVersion": "1.3",
3+
"schemaVersion": "1.4",
44
"runOnRequirements": [
55
{
66
"topologies": [
@@ -222,7 +222,10 @@
222222
"reply": {
223223
"cursor": {
224224
"id": {
225-
"$$type": "long"
225+
"$$type": [
226+
"int",
227+
"long"
228+
]
226229
},
227230
"firstBatch": {
228231
"$$type": "array"
@@ -239,7 +242,10 @@
239242
"commandStartedEvent": {
240243
"command": {
241244
"getMore": {
242-
"$$type": "long"
245+
"$$type": [
246+
"int",
247+
"long"
248+
]
243249
},
244250
"collection": "coll0"
245251
},
@@ -333,7 +339,10 @@
333339
"reply": {
334340
"cursor": {
335341
"id": {
336-
"$$type": "long"
342+
"$$type": [
343+
"int",
344+
"long"
345+
]
337346
},
338347
"firstBatch": {
339348
"$$type": "array"
@@ -475,7 +484,10 @@
475484
"reply": {
476485
"cursor": {
477486
"id": {
478-
"$$type": "long"
487+
"$$type": [
488+
"int",
489+
"long"
490+
]
479491
},
480492
"firstBatch": {
481493
"$$type": "array"
@@ -492,7 +504,10 @@
492504
"commandStartedEvent": {
493505
"command": {
494506
"getMore": {
495-
"$$type": "long"
507+
"$$type": [
508+
"int",
509+
"long"
510+
]
496511
},
497512
"collection": "coll0"
498513
},
@@ -605,7 +620,10 @@
605620
"reply": {
606621
"cursor": {
607622
"id": {
608-
"$$type": "long"
623+
"$$type": [
624+
"int",
625+
"long"
626+
]
609627
},
610628
"firstBatch": {
611629
"$$type": "array"
@@ -750,7 +768,10 @@
750768
"reply": {
751769
"cursor": {
752770
"id": {
753-
"$$type": "long"
771+
"$$type": [
772+
"int",
773+
"long"
774+
]
754775
},
755776
"firstBatch": {
756777
"$$type": "array"
@@ -767,7 +788,10 @@
767788
"commandStartedEvent": {
768789
"command": {
769790
"getMore": {
770-
"$$type": "long"
791+
"$$type": [
792+
"int",
793+
"long"
794+
]
771795
},
772796
"collection": "coll0"
773797
},
@@ -858,7 +882,10 @@
858882
"commandStartedEvent": {
859883
"command": {
860884
"getMore": {
861-
"$$type": "long"
885+
"$$type": [
886+
"int",
887+
"long"
888+
]
862889
},
863890
"collection": "coll0"
864891
},
@@ -950,7 +977,10 @@
950977
"commandStartedEvent": {
951978
"command": {
952979
"getMore": {
953-
"$$type": "long"
980+
"$$type": [
981+
"int",
982+
"long"
983+
]
954984
},
955985
"collection": {
956986
"$$type": "string"
@@ -1100,7 +1130,10 @@
11001130
"commandStartedEvent": {
11011131
"command": {
11021132
"getMore": {
1103-
"$$type": "long"
1133+
"$$type": [
1134+
"int",
1135+
"long"
1136+
]
11041137
},
11051138
"collection": "coll0"
11061139
},

src/test/spec/json/load-balancers/cursors.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
description: cursors are correctly pinned to connections for load-balanced clusters
22

3-
schemaVersion: '1.3'
3+
schemaVersion: '1.4'
44

55
runOnRequirements:
66
- topologies: [ load-balanced ]
@@ -126,14 +126,14 @@ tests:
126126
commandSucceededEvent:
127127
reply:
128128
cursor:
129-
id: { $$type: long }
129+
id: { $$type: [ int, long ] }
130130
firstBatch: { $$type: array }
131131
ns: { $$type: string }
132132
commandName: find
133133
- &getMoreStarted
134134
commandStartedEvent:
135135
command:
136-
getMore: { $$type: long }
136+
getMore: { $$type: [ int, long ] }
137137
collection: *collection0Name
138138
commandName: getMore
139139
- &getMoreSucceeded
@@ -386,7 +386,7 @@ tests:
386386
# is not equal to *collection0Name as the command is not executed against a collection.
387387
- commandStartedEvent:
388388
command:
389-
getMore: { $$type: long }
389+
getMore: { $$type: [ int, long ] }
390390
collection: { $$type: string }
391391
commandName: getMore
392392
- *getMoreSucceeded

src/test/spec/json/load-balancers/sdam-error-handling.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,4 +511,4 @@
511511
]
512512
}
513513
]
514-
}
514+
}

src/test/spec/json/load-balancers/sdam-error-handling.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,4 @@ tests:
270270
# getMore should not clear the pool because the connection's
271271
# generation number is stale.
272272
- connectionCheckedInEvent: {}
273-
- connectionClosedEvent: {}
273+
- connectionClosedEvent: {}

src/test/spec/json/load-balancers/transactions.json

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "transactions are correctly pinned to connections for load-balanced clusters",
3-
"schemaVersion": "1.3",
3+
"schemaVersion": "1.4",
44
"runOnRequirements": [
55
{
66
"topologies": [
@@ -1616,6 +1616,50 @@
16161616
]
16171617
}
16181618
]
1619+
},
1620+
{
1621+
"description": "pinned connection is released when session ended",
1622+
"operations": [
1623+
{
1624+
"name": "startTransaction",
1625+
"object": "session0"
1626+
},
1627+
{
1628+
"name": "insertOne",
1629+
"object": "collection0",
1630+
"arguments": {
1631+
"document": {
1632+
"x": 1
1633+
},
1634+
"session": "session0"
1635+
}
1636+
},
1637+
{
1638+
"name": "commitTransaction",
1639+
"object": "session0"
1640+
},
1641+
{
1642+
"name": "endSession",
1643+
"object": "session0"
1644+
}
1645+
],
1646+
"expectEvents": [
1647+
{
1648+
"client": "client0",
1649+
"eventType": "cmap",
1650+
"events": [
1651+
{
1652+
"connectionReadyEvent": {}
1653+
},
1654+
{
1655+
"connectionCheckedOutEvent": {}
1656+
},
1657+
{
1658+
"connectionCheckedInEvent": {}
1659+
}
1660+
]
1661+
}
1662+
]
16191663
}
16201664
]
16211665
}

src/test/spec/json/load-balancers/transactions.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
description: transactions are correctly pinned to connections for load-balanced clusters
22

3-
schemaVersion: '1.3'
3+
schemaVersion: '1.4'
44

55
runOnRequirements:
66
- topologies: [ load-balanced ]
@@ -596,3 +596,21 @@ tests:
596596
- connectionCheckedOutEvent: {}
597597
# Events for abortTransaction.
598598
- connectionCheckedInEvent: {}
599+
600+
- description: pinned connection is released when session ended
601+
operations:
602+
- *startTransaction
603+
- *transactionalInsert
604+
- *commitTransaction
605+
- &endSession
606+
name: endSession
607+
object: *session0
608+
expectEvents:
609+
- client: *client0
610+
eventType: cmap
611+
events:
612+
# Events for the insert and commitTransaction.
613+
- connectionReadyEvent: {}
614+
- connectionCheckedOutEvent: {}
615+
# Events for endSession.
616+
- connectionCheckedInEvent: {}

0 commit comments

Comments
 (0)