...
1description: connection establishment if loadBalanced is specified for non-load balanced clusters
2
3schemaVersion: '1.3'
4
5runOnRequirements:
6 # Don't run on replica sets because the URI used to configure the clients will contain multiple hosts and the
7 # replicaSet option, which will cause an error when constructing the lbTrueClient entity.
8 - topologies: [ single, sharded ]
9
10createEntities:
11 - client:
12 id: &lbTrueClient lbTrueClient
13 # Restrict to a single mongos to ensure there are not multiple hosts in the URI, which would conflict with
14 # loadBalanced=true.
15 useMultipleMongoses: false
16 uriOptions:
17 loadBalanced: true
18 - database:
19 id: &lbTrueDatabase lbTrueDatabase
20 client: *lbTrueClient
21 databaseName: &lbTrueDatabaseName lbTrueDb
22 - client:
23 id: &lbFalseClient lbFalseClient
24 uriOptions:
25 loadBalanced: false
26 - database:
27 id: &lbFalseDatabase lbFalseDatabase
28 client: *lbFalseClient
29 databaseName: &lbFalseDatabaseName lbFalseDb
30
31_yamlAnchors:
32 runCommandArguments:
33 - &pingArguments
34 arguments:
35 commandName: ping
36 command: { ping: 1 }
37
38tests:
39 # These tests assert that drivers behave correctly if loadBalanced=true/false for non-load balanced clusters. Existing
40 # spec tests should cover the case where loadBalanced is unset.
41
42 # If the server is not configured to be behind a load balancer and the URI contains loadBalanced=true, the driver
43 # should error during the connection handshake because the server's hello response does not contain a serviceId field.
44 - description: operations against non-load balanced clusters fail if URI contains loadBalanced=true
45 operations:
46 - name: runCommand
47 object: *lbTrueDatabase
48 <<: *pingArguments
49 expectError:
50 errorContains: Driver attempted to initialize in load balancing mode, but the server does not support this mode
51
52 - description: operations against non-load balanced clusters succeed if URI contains loadBalanced=false
53 operations:
54 - name: runCommand
55 object: *lbFalseDatabase
56 <<: *pingArguments
View as plain text