Skip to content

Commit dc0d5a1

Browse files
authored
Update InitialDnsSeedlistDiscoveryTest (#1009)
JAVA-4532
1 parent d22f4b3 commit dc0d5a1

33 files changed

+421
-332
lines changed

driver-core/src/test/resources/initial-dns-seedlist-discovery/README.rst

Lines changed: 61 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ replica set name ``repl0``.
1414

1515
The tests in the ``load-balanced`` directory MUST be executed against a
1616
load-balanced sharded cluster with the mongos servers running on localhost ports
17-
27017 and 27018 (corresponding to the script in `drivers-evergreen-tools`_). The
18-
load balancers, shard servers, and config servers may run on any open ports.
17+
27017 and 27018 and ``--loadBalancerPort`` 27050 and 27051, respectively
18+
(corresponding to the script in `drivers-evergreen-tools`_). The load balancers,
19+
shard servers, and config servers may run on any open ports.
1920

2021
.. _`drivers-evergreen-tools`: https://github.com/mongodb-labs/drivers-evergreen-tools/blob/master/.evergreen/run-load-balancer.sh
2122

@@ -56,7 +57,9 @@ these tests::
5657
_mongodb._tcp.test19.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
5758
_mongodb._tcp.test20.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
5859
_mongodb._tcp.test21.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
59-
_customname._tcp.test22.test.build.10gen.cc 86400 IN SRV 27017 localhost.test.build.10gen.cc
60+
_customname._tcp.test22.test.build.10gen.cc 86400 IN SRV 27017 localhost.test.build.10gen.cc.
61+
_mongodb._tcp.test23.test.build.10gen.cc. 86400 IN SRV 8000 localhost.test.build.10gen.cc.
62+
_mongodb._tcp.test24.test.build.10gen.cc. 86400 IN SRV 8000 localhost.test.build.10gen.cc.
6063

6164
Record TTL Class Text
6265
test5.test.build.10gen.cc. 86400 IN TXT "replicaSet=repl0&authSource=thisDB"
@@ -68,12 +71,18 @@ these tests::
6871
test11.test.build.10gen.cc. 86400 IN TXT "replicaS" "et=rep" "l0"
6972
test20.test.build.10gen.cc. 86400 IN TXT "loadBalanced=true"
7073
test21.test.build.10gen.cc. 86400 IN TXT "loadBalanced=false"
74+
test24.test.build.10gen.cc. 86400 IN TXT "loadBalanced=true"
7175

72-
Note that ``test4`` is omitted deliberately to test what happens with no SRV
73-
record. ``test9`` is missing because it was deleted during the development of
74-
the tests. The missing ``test.`` sub-domain in the SRV record target for
75-
``test12`` is deliberate. ``test22`` is used to test a custom service name
76-
(``customname``).
76+
Notes:
77+
78+
- ``test4`` is omitted deliberately to test what happens with no SRV record.
79+
- ``test9`` is missing because it was deleted during the development of the
80+
tests.
81+
- The missing ``test.`` sub-domain in the SRV record target for ``test12`` is
82+
deliberate.
83+
- ``test22`` is used to test a custom service name (``customname``).
84+
- ``test23`` and ``test24`` point to port 8000 (HAProxy) and are used for
85+
load-balanced tests.
7786

7887
In our tests we have used ``localhost.test.build.10gen.cc`` as the domain, and
7988
then configured ``localhost.test.build.10gen.cc`` to resolve to 127.0.0.1.
@@ -105,31 +114,51 @@ These YAML and JSON files contain the following fields:
105114
- ``error``: indicates that the parsing of the URI, or the resolving or
106115
contents of the SRV or TXT records included errors.
107116
- ``comment``: a comment to indicate why a test would fail.
117+
- ``ping``: if false, the test runner should not run a "ping" operation.
108118

109119
.. _`Connection String`: ../../connection-string/connection-string-spec.rst
110120
.. _`URI options`: ../../uri-options/uri-options.rst
111121

112-
For each file, create a MongoClient initialized with the ``mongodb+srv``
113-
connection string.
114-
115-
If ``seeds`` is specified, drivers SHOULD verify that the set of hosts in the
116-
client's initial seedlist matches the list in ``seeds``. If ``numSeeds`` is
117-
specified, drivers SHOULD verify that the size of that set matches ``numSeeds``.
118-
119-
If ``hosts`` is specified, drivers MUST verify that the set of
120-
ServerDescriptions in the client's TopologyDescription eventually matches the
121-
list in ``hosts``. If ``numHosts`` is specified, drivers MUST verify that the
122-
size of that set matches ``numHosts``.
123-
124-
If ``options`` is specified, drivers MUST verify each of the values under
125-
``options`` match the MongoClient's parsed value for that option. There may be
126-
other options parsed by the MongoClient as well, which a test does not verify.
127-
128-
If ``parsed_options`` is specified, drivers MUST verify that each of the values
129-
under ``parsed_options`` match the MongoClient's parsed value for that option.
130-
Supported values include, but are not limited to, ``user`` and ``password``
131-
(parsed from ``UserInfo``) and ``auth_database`` (parsed from
132-
``Auth database``).
133-
134-
If ``error`` is specified and ``true``, drivers MUST verify that an error has
135-
been thrown.
122+
For each YAML file:
123+
124+
- Create a MongoClient initialized with the ``mongodb+srv``
125+
connection string.
126+
- Run a "ping" operation unless ``ping`` is false or ``error`` is true.
127+
128+
Assertions:
129+
130+
- If ``seeds`` is specified, drivers SHOULD verify that the set of hosts in the
131+
client's initial seedlist matches the list in ``seeds``. If ``numSeeds`` is
132+
specified, drivers SHOULD verify that the size of that set matches
133+
``numSeeds``.
134+
135+
- If ``hosts`` is specified, drivers MUST verify that the set of
136+
ServerDescriptions in the client's TopologyDescription eventually matches the
137+
list in ``hosts``. If ``numHosts`` is specified, drivers MUST verify that the
138+
size of that set matches ``numHosts``.
139+
140+
- If ``options`` is specified, drivers MUST verify each of the values under
141+
``options`` match the MongoClient's parsed value for that option. There may be
142+
other options parsed by the MongoClient as well, which a test does not verify.
143+
144+
- If ``parsed_options`` is specified, drivers MUST verify that each of the
145+
values under ``parsed_options`` match the MongoClient's parsed value for that
146+
option. Supported values include, but are not limited to, ``user`` and
147+
``password`` (parsed from ``UserInfo``) and ``auth_database`` (parsed from
148+
``Auth database``).
149+
150+
- If ``error`` is specified and ``true``, drivers MUST verify that initializing
151+
the MongoClient throws an error. If ``error`` is not specified or is
152+
``false``, both initializing the MongoClient and running a ping operation must
153+
succeed without throwing any errors.
154+
155+
- If ``ping`` is not specified or ``true``, drivers MUST verify that running a
156+
"ping" operation using the initialized MongoClient succeeds. If ``ping`` is
157+
``false``, drivers MUST NOT run a "ping" operation.
158+
159+
**Note:** These tests are expected to be run against MongoDB databases with
160+
and without authentication enabled. The "ping" operation does not require
161+
authentication so should succeed with URIs that contain no userinfo (i.e.
162+
no username and password). Tests with URIs that contain userinfo always set
163+
``ping`` to ``false`` because some drivers will fail handshake on a
164+
connection if userinfo is provided but incorrect.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
2-
"uri": "mongodb+srv://test20.test.build.10gen.cc/?directConnection=false",
3-
"seeds": [
4-
"localhost.test.build.10gen.cc:27017"
2+
"uri" : "mongodb+srv://test24.test.build.10gen.cc/?directConnection=false",
3+
"seeds" : [
4+
"localhost.test.build.10gen.cc:8000"
55
],
6-
"hosts": [
7-
"localhost.test.build.10gen.cc:27017"
6+
"hosts" : [
7+
"localhost.test.build.10gen.cc:8000"
88
],
9-
"options": {
10-
"loadBalanced": true,
11-
"ssl": true,
12-
"directConnection": false
13-
}
9+
"options" : {
10+
"loadBalanced" : true,
11+
"ssl" : true,
12+
"directConnection" : false
13+
},
14+
"ping" : true
1415
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"uri": "mongodb+srv://test20.test.build.10gen.cc/?replicaSet=replset",
3-
"seeds": [],
4-
"hosts": [],
5-
"error": true,
6-
"comment": "Should fail because loadBalanced=true is incompatible with replicaSet"
2+
"uri" : "mongodb+srv://test24.test.build.10gen.cc/?replicaSet=replset",
3+
"seeds" : [],
4+
"hosts" : [],
5+
"error" : true,
6+
"comment" : "Should fail because loadBalanced=true is incompatible with replicaSet"
77
}
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
2-
"uri": "mongodb+srv://test20.test.build.10gen.cc/",
3-
"seeds": [
4-
"localhost.test.build.10gen.cc:27017"
2+
"uri" : "mongodb+srv://test24.test.build.10gen.cc/",
3+
"seeds" : [
4+
"localhost.test.build.10gen.cc:8000"
55
],
6-
"hosts": [
7-
"localhost.test.build.10gen.cc:27017"
6+
"hosts" : [
7+
"localhost.test.build.10gen.cc:8000"
88
],
9-
"options": {
10-
"loadBalanced": true,
11-
"ssl": true
12-
}
9+
"options" : {
10+
"loadBalanced" : true,
11+
"ssl" : true
12+
},
13+
"ping" : true
1314
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"uri": "mongodb+srv://test20.test.build.10gen.cc/?srvMaxHosts=1",
3-
"seeds": [],
4-
"hosts": [],
5-
"error": true,
6-
"comment": "Should fail because positive integer for srvMaxHosts conflicts with loadBalanced=true (TXT)"
2+
"uri" : "mongodb+srv://test24.test.build.10gen.cc/?srvMaxHosts=1",
3+
"seeds" : [],
4+
"hosts" : [],
5+
"error" : true,
6+
"comment" : "Should fail because positive integer for srvMaxHosts conflicts with loadBalanced=true (TXT)"
77
}
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
2-
"uri": "mongodb+srv://test20.test.build.10gen.cc/?srvMaxHosts=0",
3-
"seeds": [
4-
"localhost.test.build.10gen.cc:27017"
2+
"uri" : "mongodb+srv://test24.test.build.10gen.cc/?srvMaxHosts=0",
3+
"seeds" : [
4+
"localhost.test.build.10gen.cc:8000"
55
],
6-
"hosts": [
7-
"localhost.test.build.10gen.cc:27017"
6+
"hosts" : [
7+
"localhost.test.build.10gen.cc:8000"
88
],
9-
"options": {
10-
"loadBalanced": true,
11-
"srvMaxHosts": 0,
12-
"ssl": true
13-
}
9+
"options" : {
10+
"loadBalanced" : true,
11+
"srvMaxHosts" : 0,
12+
"ssl" : true
13+
},
14+
"ping" : true
1415
}
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
2-
"uri": "mongodb+srv://test3.test.build.10gen.cc/?loadBalanced=true&srvMaxHosts=0",
3-
"seeds": [
4-
"localhost.test.build.10gen.cc:27017"
2+
"uri" : "mongodb+srv://test23.test.build.10gen.cc/?loadBalanced=true&srvMaxHosts=0",
3+
"seeds" : [
4+
"localhost.test.build.10gen.cc:8000"
55
],
6-
"hosts": [
7-
"localhost.test.build.10gen.cc:27017"
6+
"hosts" : [
7+
"localhost.test.build.10gen.cc:8000"
88
],
9-
"options": {
10-
"loadBalanced": true,
11-
"srvMaxHosts": 0,
12-
"ssl": true
13-
}
9+
"options" : {
10+
"loadBalanced" : true,
11+
"srvMaxHosts" : 0,
12+
"ssl" : true
13+
},
14+
"ping" : true
1415
}

driver-core/src/test/resources/initial-dns-seedlist-discovery/replica-set/direct-connection-false.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
"seeds": [
44
"localhost.test.build.10gen.cc:27017"
55
],
6-
"hosts": [
6+
"hosts" : [
77
"localhost:27017",
88
"localhost:27018",
99
"localhost:27019"
1010
],
11-
"options": {
12-
"ssl": true,
13-
"directConnection": false
14-
}
11+
"options" : {
12+
"ssl" : true,
13+
"directConnection" : false
14+
},
15+
"ping" : true
1516
}

driver-core/src/test/resources/initial-dns-seedlist-discovery/replica-set/encoded-userinfo-and-db.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
"localhost:27018",
99
"localhost:27019"
1010
],
11-
"options": {
12-
"replicaSet": "repl0",
13-
"ssl": true
11+
"options" : {
12+
"replicaSet" : "repl0",
13+
"ssl" : true
1414
},
15-
"parsed_options": {
16-
"user": "b*b@f3tt=",
17-
"password": "$4to@L8=MC",
18-
"db": "mydb?"
15+
"parsed_options" : {
16+
"user" : "b*b@f3tt=",
17+
"password" : "$4to@L8=MC",
18+
"db" : "mydb?"
1919
},
20-
"comment": "Encoded user, pass, and DB parse correctly"
20+
"ping" : false,
21+
"comment" : "Encoded user, pass, and DB parse correctly"
2122
}

driver-core/src/test/resources/initial-dns-seedlist-discovery/replica-set/loadBalanced-false-txt.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
"seeds": [
44
"localhost.test.build.10gen.cc:27017"
55
],
6-
"hosts": [
6+
"hosts" : [
77
"localhost:27017",
88
"localhost:27018",
99
"localhost:27019"
1010
],
11-
"options": {
12-
"loadBalanced": false,
13-
"ssl": true
14-
}
11+
"options" : {
12+
"loadBalanced" : false,
13+
"ssl" : true
14+
},
15+
"ping" : true
1516
}

driver-core/src/test/resources/initial-dns-seedlist-discovery/replica-set/longer-parent-in-return.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
"seeds": [
44
"localhost.sub.test.build.10gen.cc:27017"
55
],
6-
"hosts": [
6+
"hosts" : [
77
"localhost:27017",
88
"localhost:27018",
99
"localhost:27019"
1010
],
11-
"options": {
12-
"replicaSet": "repl0",
13-
"ssl": true
11+
"options" : {
12+
"replicaSet" : "repl0",
13+
"ssl" : true
1414
},
15-
"comment": "Is correct, as returned host name shared the URI root \"test.build.10gen.cc\"."
15+
"ping" : true,
16+
"comment" : "Is correct, as returned host name shared the URI root \"test.build.10gen.cc\"."
1617
}

driver-core/src/test/resources/initial-dns-seedlist-discovery/replica-set/one-result-default-port.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
"seeds": [
44
"localhost.test.build.10gen.cc:27017"
55
],
6-
"hosts": [
6+
"hosts" : [
77
"localhost:27017",
88
"localhost:27018",
99
"localhost:27019"
1010
],
11-
"options": {
12-
"replicaSet": "repl0",
13-
"ssl": true
14-
}
11+
"options" : {
12+
"replicaSet" : "repl0",
13+
"ssl" : true
14+
},
15+
"ping" : true
1516
}

driver-core/src/test/resources/initial-dns-seedlist-discovery/replica-set/one-txt-record-multiple-strings.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
"seeds": [
44
"localhost.test.build.10gen.cc:27017"
55
],
6-
"hosts": [
6+
"hosts" : [
77
"localhost:27017",
88
"localhost:27018",
99
"localhost:27019"
1010
],
11-
"options": {
12-
"replicaSet": "repl0",
13-
"ssl": true
14-
}
11+
"options" : {
12+
"replicaSet" : "repl0",
13+
"ssl" : true
14+
},
15+
"ping" : true
1516
}

driver-core/src/test/resources/initial-dns-seedlist-discovery/replica-set/one-txt-record.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
"seeds": [
44
"localhost.test.build.10gen.cc:27017"
55
],
6-
"hosts": [
6+
"hosts" : [
77
"localhost:27017",
88
"localhost:27018",
99
"localhost:27019"
1010
],
11-
"options": {
12-
"replicaSet": "repl0",
13-
"authSource": "thisDB",
14-
"ssl": true
15-
}
11+
"options" : {
12+
"replicaSet" : "repl0",
13+
"authSource" : "thisDB",
14+
"ssl" : true
15+
},
16+
"ping" : true
1617
}

0 commit comments

Comments
 (0)