Skip to content

Update InitialDnsSeedlistDiscoveryTest #1009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ replica set name ``repl0``.

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

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

Expand Down Expand Up @@ -56,7 +57,9 @@ these tests::
_mongodb._tcp.test19.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
_mongodb._tcp.test20.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
_mongodb._tcp.test21.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
_customname._tcp.test22.test.build.10gen.cc 86400 IN SRV 27017 localhost.test.build.10gen.cc
_customname._tcp.test22.test.build.10gen.cc 86400 IN SRV 27017 localhost.test.build.10gen.cc.
_mongodb._tcp.test23.test.build.10gen.cc. 86400 IN SRV 8000 localhost.test.build.10gen.cc.
_mongodb._tcp.test24.test.build.10gen.cc. 86400 IN SRV 8000 localhost.test.build.10gen.cc.

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

Note that ``test4`` is omitted deliberately to test what happens with no SRV
record. ``test9`` is missing because it was deleted during the development of
the tests. The missing ``test.`` sub-domain in the SRV record target for
``test12`` is deliberate. ``test22`` is used to test a custom service name
(``customname``).
Notes:

- ``test4`` is omitted deliberately to test what happens with no SRV record.
- ``test9`` is missing because it was deleted during the development of the
tests.
- The missing ``test.`` sub-domain in the SRV record target for ``test12`` is
deliberate.
- ``test22`` is used to test a custom service name (``customname``).
- ``test23`` and ``test24`` point to port 8000 (HAProxy) and are used for
load-balanced tests.

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

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

For each file, create a MongoClient initialized with the ``mongodb+srv``
connection string.

If ``seeds`` is specified, drivers SHOULD verify that the set of hosts in the
client's initial seedlist matches the list in ``seeds``. If ``numSeeds`` is
specified, drivers SHOULD verify that the size of that set matches ``numSeeds``.

If ``hosts`` is specified, drivers MUST verify that the set of
ServerDescriptions in the client's TopologyDescription eventually matches the
list in ``hosts``. If ``numHosts`` is specified, drivers MUST verify that the
size of that set matches ``numHosts``.

If ``options`` is specified, drivers MUST verify each of the values under
``options`` match the MongoClient's parsed value for that option. There may be
other options parsed by the MongoClient as well, which a test does not verify.

If ``parsed_options`` is specified, drivers MUST verify that each of the values
under ``parsed_options`` match the MongoClient's parsed value for that option.
Supported values include, but are not limited to, ``user`` and ``password``
(parsed from ``UserInfo``) and ``auth_database`` (parsed from
``Auth database``).

If ``error`` is specified and ``true``, drivers MUST verify that an error has
been thrown.
For each YAML file:

- Create a MongoClient initialized with the ``mongodb+srv``
connection string.
- Run a "ping" operation unless ``ping`` is false or ``error`` is true.

Assertions:

- If ``seeds`` is specified, drivers SHOULD verify that the set of hosts in the
client's initial seedlist matches the list in ``seeds``. If ``numSeeds`` is
specified, drivers SHOULD verify that the size of that set matches
``numSeeds``.

- If ``hosts`` is specified, drivers MUST verify that the set of
ServerDescriptions in the client's TopologyDescription eventually matches the
list in ``hosts``. If ``numHosts`` is specified, drivers MUST verify that the
size of that set matches ``numHosts``.

- If ``options`` is specified, drivers MUST verify each of the values under
``options`` match the MongoClient's parsed value for that option. There may be
other options parsed by the MongoClient as well, which a test does not verify.

- If ``parsed_options`` is specified, drivers MUST verify that each of the
values under ``parsed_options`` match the MongoClient's parsed value for that
option. Supported values include, but are not limited to, ``user`` and
``password`` (parsed from ``UserInfo``) and ``auth_database`` (parsed from
``Auth database``).

- If ``error`` is specified and ``true``, drivers MUST verify that initializing
the MongoClient throws an error. If ``error`` is not specified or is
``false``, both initializing the MongoClient and running a ping operation must
succeed without throwing any errors.

- If ``ping`` is not specified or ``true``, drivers MUST verify that running a
"ping" operation using the initialized MongoClient succeeds. If ``ping`` is
``false``, drivers MUST NOT run a "ping" operation.

**Note:** These tests are expected to be run against MongoDB databases with
and without authentication enabled. The "ping" operation does not require
authentication so should succeed with URIs that contain no userinfo (i.e.
no username and password). Tests with URIs that contain userinfo always set
``ping`` to ``false`` because some drivers will fail handshake on a
connection if userinfo is provided but incorrect.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"uri": "mongodb+srv://test20.test.build.10gen.cc/?directConnection=false",
"seeds": [
"localhost.test.build.10gen.cc:27017"
"uri" : "mongodb+srv://test24.test.build.10gen.cc/?directConnection=false",
"seeds" : [
"localhost.test.build.10gen.cc:8000"
],
"hosts": [
"localhost.test.build.10gen.cc:27017"
"hosts" : [
"localhost.test.build.10gen.cc:8000"
],
"options": {
"loadBalanced": true,
"ssl": true,
"directConnection": false
}
"options" : {
"loadBalanced" : true,
"ssl" : true,
"directConnection" : false
},
"ping" : true
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"uri": "mongodb+srv://test20.test.build.10gen.cc/?replicaSet=replset",
"seeds": [],
"hosts": [],
"error": true,
"comment": "Should fail because loadBalanced=true is incompatible with replicaSet"
"uri" : "mongodb+srv://test24.test.build.10gen.cc/?replicaSet=replset",
"seeds" : [],
"hosts" : [],
"error" : true,
"comment" : "Should fail because loadBalanced=true is incompatible with replicaSet"
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"uri": "mongodb+srv://test20.test.build.10gen.cc/",
"seeds": [
"localhost.test.build.10gen.cc:27017"
"uri" : "mongodb+srv://test24.test.build.10gen.cc/",
"seeds" : [
"localhost.test.build.10gen.cc:8000"
],
"hosts": [
"localhost.test.build.10gen.cc:27017"
"hosts" : [
"localhost.test.build.10gen.cc:8000"
],
"options": {
"loadBalanced": true,
"ssl": true
}
"options" : {
"loadBalanced" : true,
"ssl" : true
},
"ping" : true
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"uri": "mongodb+srv://test20.test.build.10gen.cc/?srvMaxHosts=1",
"seeds": [],
"hosts": [],
"error": true,
"comment": "Should fail because positive integer for srvMaxHosts conflicts with loadBalanced=true (TXT)"
"uri" : "mongodb+srv://test24.test.build.10gen.cc/?srvMaxHosts=1",
"seeds" : [],
"hosts" : [],
"error" : true,
"comment" : "Should fail because positive integer for srvMaxHosts conflicts with loadBalanced=true (TXT)"
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"uri": "mongodb+srv://test20.test.build.10gen.cc/?srvMaxHosts=0",
"seeds": [
"localhost.test.build.10gen.cc:27017"
"uri" : "mongodb+srv://test24.test.build.10gen.cc/?srvMaxHosts=0",
"seeds" : [
"localhost.test.build.10gen.cc:8000"
],
"hosts": [
"localhost.test.build.10gen.cc:27017"
"hosts" : [
"localhost.test.build.10gen.cc:8000"
],
"options": {
"loadBalanced": true,
"srvMaxHosts": 0,
"ssl": true
}
"options" : {
"loadBalanced" : true,
"srvMaxHosts" : 0,
"ssl" : true
},
"ping" : true
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"uri": "mongodb+srv://test3.test.build.10gen.cc/?loadBalanced=true&srvMaxHosts=0",
"seeds": [
"localhost.test.build.10gen.cc:27017"
"uri" : "mongodb+srv://test23.test.build.10gen.cc/?loadBalanced=true&srvMaxHosts=0",
"seeds" : [
"localhost.test.build.10gen.cc:8000"
],
"hosts": [
"localhost.test.build.10gen.cc:27017"
"hosts" : [
"localhost.test.build.10gen.cc:8000"
],
"options": {
"loadBalanced": true,
"srvMaxHosts": 0,
"ssl": true
}
"options" : {
"loadBalanced" : true,
"srvMaxHosts" : 0,
"ssl" : true
},
"ping" : true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"seeds": [
"localhost.test.build.10gen.cc:27017"
],
"hosts": [
"hosts" : [
"localhost:27017",
"localhost:27018",
"localhost:27019"
],
"options": {
"ssl": true,
"directConnection": false
}
"options" : {
"ssl" : true,
"directConnection" : false
},
"ping" : true
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
"localhost:27018",
"localhost:27019"
],
"options": {
"replicaSet": "repl0",
"ssl": true
"options" : {
"replicaSet" : "repl0",
"ssl" : true
},
"parsed_options": {
"user": "b*b@f3tt=",
"password": "$4to@L8=MC",
"db": "mydb?"
"parsed_options" : {
"user" : "b*b@f3tt=",
"password" : "$4to@L8=MC",
"db" : "mydb?"
},
"comment": "Encoded user, pass, and DB parse correctly"
"ping" : false,
"comment" : "Encoded user, pass, and DB parse correctly"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"seeds": [
"localhost.test.build.10gen.cc:27017"
],
"hosts": [
"hosts" : [
"localhost:27017",
"localhost:27018",
"localhost:27019"
],
"options": {
"loadBalanced": false,
"ssl": true
}
"options" : {
"loadBalanced" : false,
"ssl" : true
},
"ping" : true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"seeds": [
"localhost.sub.test.build.10gen.cc:27017"
],
"hosts": [
"hosts" : [
"localhost:27017",
"localhost:27018",
"localhost:27019"
],
"options": {
"replicaSet": "repl0",
"ssl": true
"options" : {
"replicaSet" : "repl0",
"ssl" : true
},
"comment": "Is correct, as returned host name shared the URI root \"test.build.10gen.cc\"."
"ping" : true,
"comment" : "Is correct, as returned host name shared the URI root \"test.build.10gen.cc\"."
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"seeds": [
"localhost.test.build.10gen.cc:27017"
],
"hosts": [
"hosts" : [
"localhost:27017",
"localhost:27018",
"localhost:27019"
],
"options": {
"replicaSet": "repl0",
"ssl": true
}
"options" : {
"replicaSet" : "repl0",
"ssl" : true
},
"ping" : true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"seeds": [
"localhost.test.build.10gen.cc:27017"
],
"hosts": [
"hosts" : [
"localhost:27017",
"localhost:27018",
"localhost:27019"
],
"options": {
"replicaSet": "repl0",
"ssl": true
}
"options" : {
"replicaSet" : "repl0",
"ssl" : true
},
"ping" : true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"seeds": [
"localhost.test.build.10gen.cc:27017"
],
"hosts": [
"hosts" : [
"localhost:27017",
"localhost:27018",
"localhost:27019"
],
"options": {
"replicaSet": "repl0",
"authSource": "thisDB",
"ssl": true
}
"options" : {
"replicaSet" : "repl0",
"authSource" : "thisDB",
"ssl" : true
},
"ping" : true
}
Loading