diff --git a/test/spec/initial-dns-seedlist-discovery/README.rst b/test/spec/initial-dns-seedlist-discovery/README.rst index 47bb75b4f67..0e6404aa5b5 100644 --- a/test/spec/initial-dns-seedlist-discovery/README.rst +++ b/test/spec/initial-dns-seedlist-discovery/README.rst @@ -10,11 +10,20 @@ Test Setup The tests in the ``replica-set`` directory MUST be executed against a three-node replica set on localhost ports 27017, 27018, and 27019 with -replica set name ``repl0``. The tests in ``load-balanced`` MUST be executed -against a load-balanced sharded cluster with the mongos servers running on -localhost ports 27017 and 27018 and load balancers, shard servers, and config -servers running on any open ports. In both cases, the clusters MUST be -started with SSL enabled. +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. + +.. _`drivers-evergreen-tools`: https://github.com/mongodb-labs/drivers-evergreen-tools/blob/master/.evergreen/run-load-balancer.sh + +The tests in the ``sharded`` directory MUST be executed against a sharded +cluster with the mongos servers running on localhost ports 27017 and 27018. +Shard servers and config servers may run on any open ports. + +In all cases, the clusters MUST be started with SSL enabled. To run the tests that accompany this spec, you need to configure the SRV and TXT records with a real name server. The following records are required for @@ -24,29 +33,30 @@ these tests:: localhost.test.build.10gen.cc. 86400 IN A 127.0.0.1 localhost.sub.test.build.10gen.cc. 86400 IN A 127.0.0.1 - Record TTL Class Port Target - _mongodb._tcp.test1.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. - _mongodb._tcp.test1.test.build.10gen.cc. 86400 IN SRV 27018 localhost.test.build.10gen.cc. - _mongodb._tcp.test2.test.build.10gen.cc. 86400 IN SRV 27018 localhost.test.build.10gen.cc. - _mongodb._tcp.test2.test.build.10gen.cc. 86400 IN SRV 27019 localhost.test.build.10gen.cc. - _mongodb._tcp.test3.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. - _mongodb._tcp.test5.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. - _mongodb._tcp.test6.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. - _mongodb._tcp.test7.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. - _mongodb._tcp.test8.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. - _mongodb._tcp.test10.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. - _mongodb._tcp.test11.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. - _mongodb._tcp.test12.test.build.10gen.cc. 86400 IN SRV 27017 localhost.build.10gen.cc. - _mongodb._tcp.test13.test.build.10gen.cc. 86400 IN SRV 27017 test.build.10gen.cc. - _mongodb._tcp.test14.test.build.10gen.cc. 86400 IN SRV 27017 localhost.not-test.build.10gen.cc. - _mongodb._tcp.test15.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.not-build.10gen.cc. - _mongodb._tcp.test16.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.not-10gen.cc. - _mongodb._tcp.test17.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.not-cc. - _mongodb._tcp.test18.test.build.10gen.cc. 86400 IN SRV 27017 localhost.sub.test.build.10gen.cc. - _mongodb._tcp.test19.test.build.10gen.cc. 86400 IN SRV 27017 localhost.evil.build.10gen.cc. - _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. + Record TTL Class Port Target + _mongodb._tcp.test1.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. + _mongodb._tcp.test1.test.build.10gen.cc. 86400 IN SRV 27018 localhost.test.build.10gen.cc. + _mongodb._tcp.test2.test.build.10gen.cc. 86400 IN SRV 27018 localhost.test.build.10gen.cc. + _mongodb._tcp.test2.test.build.10gen.cc. 86400 IN SRV 27019 localhost.test.build.10gen.cc. + _mongodb._tcp.test3.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. + _mongodb._tcp.test5.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. + _mongodb._tcp.test6.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. + _mongodb._tcp.test7.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. + _mongodb._tcp.test8.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. + _mongodb._tcp.test10.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. + _mongodb._tcp.test11.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc. + _mongodb._tcp.test12.test.build.10gen.cc. 86400 IN SRV 27017 localhost.build.10gen.cc. + _mongodb._tcp.test13.test.build.10gen.cc. 86400 IN SRV 27017 test.build.10gen.cc. + _mongodb._tcp.test14.test.build.10gen.cc. 86400 IN SRV 27017 localhost.not-test.build.10gen.cc. + _mongodb._tcp.test15.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.not-build.10gen.cc. + _mongodb._tcp.test16.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.not-10gen.cc. + _mongodb._tcp.test17.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.not-cc. + _mongodb._tcp.test18.test.build.10gen.cc. 86400 IN SRV 27017 localhost.sub.test.build.10gen.cc. + _mongodb._tcp.test19.test.build.10gen.cc. 86400 IN SRV 27017 localhost.evil.build.10gen.cc. + _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 Record TTL Class Text test5.test.build.10gen.cc. 86400 IN TXT "replicaSet=repl0&authSource=thisDB" @@ -62,7 +72,8 @@ these tests:: 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. +``test12`` is deliberate. ``test22`` is used to test a custom service name +(``customname``). 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. @@ -76,28 +87,49 @@ Test Format and Use These YAML and JSON files contain the following fields: -- ``uri``: a mongodb+srv connection string +- ``uri``: a ``mongodb+srv`` connection string - ``seeds``: the expected set of initial seeds discovered from the SRV record +- ``numSeeds``: the expected number of initial seeds discovered from the SRV + record. This is mainly used to test ``srvMaxHosts``, since randomly selected + hosts cannot be deterministically asserted. - ``hosts``: the discovered topology's list of hosts once SDAM completes a scan -- ``options``: the parsed connection string options as discovered from URI and - TXT records -- ``parsed_options``: additional options present in the `Connection String`_ - URI such as ``Userinfo`` (as ``user`` and ``password``), and ``Auth - database`` (as ``auth_database``). +- ``numHosts``: the expected number of hosts discovered once SDAM completes a + scan. This is mainly used to test ``srvMaxHosts``, since randomly selected + hosts cannot be deterministically asserted. +- ``options``: the parsed `URI options`_ as discovered from the + `Connection String`_'s "Connection Options" component and SRV resolution + (e.g. TXT records, implicit ``tls`` default). +- ``parsed_options``: additional, parsed options from other `Connection String`_ + components. This is mainly used for asserting ``UserInfo`` (as ``user`` and + ``password``) and ``Auth database`` (as ``auth_database``). - ``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. .. _`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``). -For each file, create MongoClient initialized with the mongodb+srv connection -string. You SHOULD verify that the client's initial seed list matches the list of -seeds. You MUST verify that the set of ServerDescriptions in the client's -TopologyDescription eventually matches the list of hosts. You MUST verify that -each of the values of the Connection String Options under ``options`` match the -Client's parsed value for that option. There may be other options parsed by -the Client as well, which a test does not verify. In ``uri-with-auth`` the URI -contains a user/password set and additional options are provided in -``parsed_options`` so that tests can verify authentication is maintained when -evaluating URIs. You MUST verify that an error has been thrown if ``error`` is -present. +If ``error`` is specified and ``true``, drivers MUST verify that an error has +been thrown. diff --git a/test/spec/initial-dns-seedlist-discovery/dbname-with-commas.json b/test/spec/initial-dns-seedlist-discovery/dbname-with-commas.json deleted file mode 100644 index dd3943918d1..00000000000 --- a/test/spec/initial-dns-seedlist-discovery/dbname-with-commas.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "uri": "mongodb+srv://test1.test.build.10gen.cc/some,db?replicaSet=repl0", - "seeds": [ - "test1.test.build.10gen.cc:27017", - "test1.test.build.10gen.cc:27018" - ], - "hosts": [ - "localhost:27017", - "localhost:27018", - "localhost:27019" - ], - "options": { - "replicaSet": "repl0", - "ssl": true - }, - "parsed_options": { - "defaultDatabase": "some,db" - } -} diff --git a/test/spec/initial-dns-seedlist-discovery/dbname-with-commas.yml b/test/spec/initial-dns-seedlist-discovery/dbname-with-commas.yml deleted file mode 100644 index 8e50be60245..00000000000 --- a/test/spec/initial-dns-seedlist-discovery/dbname-with-commas.yml +++ /dev/null @@ -1,13 +0,0 @@ -uri: "mongodb+srv://test1.test.build.10gen.cc/some,db?replicaSet=repl0" -seeds: - - test1.test.build.10gen.cc:27017 - - test1.test.build.10gen.cc:27018 -hosts: - - localhost:27017 - - localhost:27018 - - localhost:27019 -options: - replicaSet: repl0 - ssl: true -parsed_options: - defaultDatabase: some,db diff --git a/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-directConnection.json b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-directConnection.json new file mode 100644 index 00000000000..7f41932bb2f --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-directConnection.json @@ -0,0 +1,14 @@ +{ + "uri": "mongodb+srv://test20.test.build.10gen.cc/?directConnection=false", + "seeds": [ + "localhost.test.build.10gen.cc:27017" + ], + "hosts": [ + "localhost.test.build.10gen.cc:27017" + ], + "options": { + "loadBalanced": true, + "ssl": true, + "directConnection": false + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-directConnection.yml b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-directConnection.yml new file mode 100644 index 00000000000..0c96f352c28 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-directConnection.yml @@ -0,0 +1,13 @@ +# The TXT record for test20.test.build.10gen.cc contains loadBalanced=true. +# DRIVERS-1721 introduced this test as passing. +uri: "mongodb+srv://test20.test.build.10gen.cc/?directConnection=false" +seeds: + - localhost.test.build.10gen.cc:27017 +hosts: + # In LB mode, the driver does not do server discovery, so the hostname does + # not get resolved to localhost:27017. + - localhost.test.build.10gen.cc:27017 +options: + loadBalanced: true + ssl: true + directConnection: false diff --git a/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-no-results.json b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-no-results.json new file mode 100644 index 00000000000..7f49416aa3a --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-no-results.json @@ -0,0 +1,7 @@ +{ + "uri": "mongodb+srv://test4.test.build.10gen.cc/?loadBalanced=true", + "seeds": [], + "hosts": [], + "error": true, + "comment": "Should fail because no SRV records are present for this URI." +} diff --git a/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-no-results.yml b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-no-results.yml new file mode 100644 index 00000000000..ee716e593e2 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-no-results.yml @@ -0,0 +1,5 @@ +uri: "mongodb+srv://test4.test.build.10gen.cc/?loadBalanced=true" +seeds: [] +hosts: [] +error: true +comment: Should fail because no SRV records are present for this URI. diff --git a/test/spec/initial-dns-seedlist-discovery/loadBalanced-replicaSet-errors.json b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-replicaSet-errors.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/loadBalanced-replicaSet-errors.json rename to test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-replicaSet-errors.json diff --git a/test/spec/initial-dns-seedlist-discovery/loadBalanced-replicaSet-errors.yml b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-replicaSet-errors.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/loadBalanced-replicaSet-errors.yml rename to test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-replicaSet-errors.yml diff --git a/test/spec/initial-dns-seedlist-discovery/loadBalanced-true-multiple-hosts.json b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-true-multiple-hosts.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/loadBalanced-true-multiple-hosts.json rename to test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-true-multiple-hosts.json diff --git a/test/spec/initial-dns-seedlist-discovery/loadBalanced-true-multiple-hosts.yml b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-true-multiple-hosts.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/loadBalanced-true-multiple-hosts.yml rename to test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-true-multiple-hosts.yml diff --git a/test/spec/initial-dns-seedlist-discovery/loadBalanced-true-txt.json b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-true-txt.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/loadBalanced-true-txt.json rename to test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-true-txt.json diff --git a/test/spec/initial-dns-seedlist-discovery/loadBalanced-true-txt.yml b/test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-true-txt.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/loadBalanced-true-txt.yml rename to test/spec/initial-dns-seedlist-discovery/load-balanced/loadBalanced-true-txt.yml diff --git a/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true-txt.json b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true-txt.json new file mode 100644 index 00000000000..a7600a8a7b1 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true-txt.json @@ -0,0 +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)" +} diff --git a/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true-txt.yml b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true-txt.yml new file mode 100644 index 00000000000..bf0636039c6 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true-txt.yml @@ -0,0 +1,5 @@ +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) diff --git a/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true.json b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true.json new file mode 100644 index 00000000000..d03a174b1eb --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true.json @@ -0,0 +1,7 @@ +{ + "uri": "mongodb+srv://test3.test.build.10gen.cc/?loadBalanced=true&srvMaxHosts=1", + "seeds": [], + "hosts": [], + "error": true, + "comment": "Should fail because positive integer for srvMaxHosts conflicts with loadBalanced=true" +} diff --git a/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true.yml b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true.yml new file mode 100644 index 00000000000..1175225c7a6 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true.yml @@ -0,0 +1,5 @@ +uri: "mongodb+srv://test3.test.build.10gen.cc/?loadBalanced=true&srvMaxHosts=1" +seeds: [] +hosts: [] +error: true +comment: Should fail because positive integer for srvMaxHosts conflicts with loadBalanced=true diff --git a/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-zero-txt.json b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-zero-txt.json new file mode 100644 index 00000000000..8d48b5bbb93 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-zero-txt.json @@ -0,0 +1,14 @@ +{ + "uri": "mongodb+srv://test20.test.build.10gen.cc/?srvMaxHosts=0", + "seeds": [ + "localhost.test.build.10gen.cc:27017" + ], + "hosts": [ + "localhost.test.build.10gen.cc:27017" + ], + "options": { + "loadBalanced": true, + "srvMaxHosts": 0, + "ssl": true + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-zero-txt.yml b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-zero-txt.yml new file mode 100644 index 00000000000..3ec00b574da --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-zero-txt.yml @@ -0,0 +1,10 @@ +# loadBalanced=true (TXT) is permitted because srvMaxHosts is non-positive +uri: "mongodb+srv://test20.test.build.10gen.cc/?srvMaxHosts=0" +seeds: + - localhost.test.build.10gen.cc:27017 +hosts: + - localhost.test.build.10gen.cc:27017 +options: + loadBalanced: true + srvMaxHosts: 0 + ssl: true diff --git a/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-zero.json b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-zero.json new file mode 100644 index 00000000000..2382fccf852 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-zero.json @@ -0,0 +1,14 @@ +{ + "uri": "mongodb+srv://test3.test.build.10gen.cc/?loadBalanced=true&srvMaxHosts=0", + "seeds": [ + "localhost.test.build.10gen.cc:27017" + ], + "hosts": [ + "localhost.test.build.10gen.cc:27017" + ], + "options": { + "loadBalanced": true, + "srvMaxHosts": 0, + "ssl": true + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-zero.yml b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-zero.yml new file mode 100644 index 00000000000..a8d3a19f36c --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/load-balanced/srvMaxHosts-zero.yml @@ -0,0 +1,10 @@ +# loadBalanced=true is permitted because srvMaxHosts is non-positive +uri: "mongodb+srv://test3.test.build.10gen.cc/?loadBalanced=true&srvMaxHosts=0" +seeds: + - localhost.test.build.10gen.cc:27017 +hosts: + - localhost.test.build.10gen.cc:27017 +options: + loadBalanced: true + srvMaxHosts: 0 + ssl: true diff --git a/test/spec/initial-dns-seedlist-discovery/direct-connection-false.json b/test/spec/initial-dns-seedlist-discovery/replica-set/direct-connection-false.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/direct-connection-false.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/direct-connection-false.json diff --git a/test/spec/initial-dns-seedlist-discovery/direct-connection-false.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/direct-connection-false.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/direct-connection-false.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/direct-connection-false.yml diff --git a/test/spec/initial-dns-seedlist-discovery/direct-connection-true.json b/test/spec/initial-dns-seedlist-discovery/replica-set/direct-connection-true.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/direct-connection-true.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/direct-connection-true.json diff --git a/test/spec/initial-dns-seedlist-discovery/direct-connection-true.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/direct-connection-true.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/direct-connection-true.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/direct-connection-true.yml diff --git a/test/spec/initial-dns-seedlist-discovery/encoded-userinfo-and-db.json b/test/spec/initial-dns-seedlist-discovery/replica-set/encoded-userinfo-and-db.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/encoded-userinfo-and-db.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/encoded-userinfo-and-db.json diff --git a/test/spec/initial-dns-seedlist-discovery/encoded-userinfo-and-db.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/encoded-userinfo-and-db.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/encoded-userinfo-and-db.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/encoded-userinfo-and-db.yml diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/loadBalanced-false-txt.json b/test/spec/initial-dns-seedlist-discovery/replica-set/loadBalanced-false-txt.json new file mode 100644 index 00000000000..fd2e565c7b6 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/loadBalanced-false-txt.json @@ -0,0 +1,15 @@ +{ + "uri": "mongodb+srv://test21.test.build.10gen.cc/", + "seeds": [ + "localhost.test.build.10gen.cc:27017" + ], + "hosts": [ + "localhost:27017", + "localhost:27018", + "localhost:27019" + ], + "options": { + "loadBalanced": false, + "ssl": true + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/loadBalanced-false-txt.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/loadBalanced-false-txt.yml new file mode 100644 index 00000000000..424d1920725 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/loadBalanced-false-txt.yml @@ -0,0 +1,10 @@ +uri: "mongodb+srv://test21.test.build.10gen.cc/" +seeds: + - localhost.test.build.10gen.cc:27017 +hosts: + - localhost:27017 + - localhost:27018 + - localhost:27019 +options: + loadBalanced: false + ssl: true diff --git a/test/spec/initial-dns-seedlist-discovery/longer-parent-in-return.json b/test/spec/initial-dns-seedlist-discovery/replica-set/longer-parent-in-return.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/longer-parent-in-return.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/longer-parent-in-return.json diff --git a/test/spec/initial-dns-seedlist-discovery/longer-parent-in-return.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/longer-parent-in-return.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/longer-parent-in-return.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/longer-parent-in-return.yml diff --git a/test/spec/initial-dns-seedlist-discovery/misformatted-option.json b/test/spec/initial-dns-seedlist-discovery/replica-set/misformatted-option.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/misformatted-option.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/misformatted-option.json diff --git a/test/spec/initial-dns-seedlist-discovery/misformatted-option.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/misformatted-option.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/misformatted-option.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/misformatted-option.yml diff --git a/test/spec/initial-dns-seedlist-discovery/no-results.json b/test/spec/initial-dns-seedlist-discovery/replica-set/no-results.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/no-results.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/no-results.json diff --git a/test/spec/initial-dns-seedlist-discovery/no-results.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/no-results.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/no-results.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/no-results.yml diff --git a/test/spec/initial-dns-seedlist-discovery/not-enough-parts.json b/test/spec/initial-dns-seedlist-discovery/replica-set/not-enough-parts.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/not-enough-parts.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/not-enough-parts.json diff --git a/test/spec/initial-dns-seedlist-discovery/not-enough-parts.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/not-enough-parts.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/not-enough-parts.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/not-enough-parts.yml diff --git a/test/spec/initial-dns-seedlist-discovery/one-result-default-port.json b/test/spec/initial-dns-seedlist-discovery/replica-set/one-result-default-port.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/one-result-default-port.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/one-result-default-port.json diff --git a/test/spec/initial-dns-seedlist-discovery/one-result-default-port.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/one-result-default-port.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/one-result-default-port.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/one-result-default-port.yml diff --git a/test/spec/initial-dns-seedlist-discovery/one-txt-record-multiple-strings.json b/test/spec/initial-dns-seedlist-discovery/replica-set/one-txt-record-multiple-strings.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/one-txt-record-multiple-strings.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/one-txt-record-multiple-strings.json diff --git a/test/spec/initial-dns-seedlist-discovery/one-txt-record-multiple-strings.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/one-txt-record-multiple-strings.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/one-txt-record-multiple-strings.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/one-txt-record-multiple-strings.yml diff --git a/test/spec/initial-dns-seedlist-discovery/one-txt-record.json b/test/spec/initial-dns-seedlist-discovery/replica-set/one-txt-record.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/one-txt-record.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/one-txt-record.json diff --git a/test/spec/initial-dns-seedlist-discovery/one-txt-record.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/one-txt-record.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/one-txt-record.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/one-txt-record.yml diff --git a/test/spec/initial-dns-seedlist-discovery/parent-part-mismatch1.json b/test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch1.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/parent-part-mismatch1.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch1.json diff --git a/test/spec/initial-dns-seedlist-discovery/parent-part-mismatch1.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch1.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/parent-part-mismatch1.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch1.yml diff --git a/test/spec/initial-dns-seedlist-discovery/parent-part-mismatch2.json b/test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch2.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/parent-part-mismatch2.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch2.json diff --git a/test/spec/initial-dns-seedlist-discovery/parent-part-mismatch2.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch2.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/parent-part-mismatch2.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch2.yml diff --git a/test/spec/initial-dns-seedlist-discovery/parent-part-mismatch3.json b/test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch3.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/parent-part-mismatch3.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch3.json diff --git a/test/spec/initial-dns-seedlist-discovery/parent-part-mismatch3.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch3.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/parent-part-mismatch3.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch3.yml diff --git a/test/spec/initial-dns-seedlist-discovery/parent-part-mismatch4.json b/test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch4.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/parent-part-mismatch4.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch4.json diff --git a/test/spec/initial-dns-seedlist-discovery/parent-part-mismatch4.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch4.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/parent-part-mismatch4.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch4.yml diff --git a/test/spec/initial-dns-seedlist-discovery/parent-part-mismatch5.json b/test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch5.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/parent-part-mismatch5.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch5.json diff --git a/test/spec/initial-dns-seedlist-discovery/parent-part-mismatch5.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch5.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/parent-part-mismatch5.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/parent-part-mismatch5.yml diff --git a/test/spec/initial-dns-seedlist-discovery/returned-parent-too-short.json b/test/spec/initial-dns-seedlist-discovery/replica-set/returned-parent-too-short.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/returned-parent-too-short.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/returned-parent-too-short.json diff --git a/test/spec/initial-dns-seedlist-discovery/returned-parent-too-short.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/returned-parent-too-short.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/returned-parent-too-short.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/returned-parent-too-short.yml diff --git a/test/spec/initial-dns-seedlist-discovery/returned-parent-wrong.json b/test/spec/initial-dns-seedlist-discovery/replica-set/returned-parent-wrong.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/returned-parent-wrong.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/returned-parent-wrong.json diff --git a/test/spec/initial-dns-seedlist-discovery/returned-parent-wrong.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/returned-parent-wrong.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/returned-parent-wrong.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/returned-parent-wrong.yml diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srv-service-name.json b/test/spec/initial-dns-seedlist-discovery/replica-set/srv-service-name.json new file mode 100644 index 00000000000..ec36cdbb00c --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srv-service-name.json @@ -0,0 +1,16 @@ +{ + "uri": "mongodb+srv://test22.test.build.10gen.cc/?srvServiceName=customname", + "seeds": [ + "localhost.test.build.10gen.cc:27017", + "localhost.test.build.10gen.cc:27018" + ], + "hosts": [ + "localhost:27017", + "localhost:27018", + "localhost:27019" + ], + "options": { + "ssl": true, + "srvServiceName": "customname" + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srv-service-name.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/srv-service-name.yml new file mode 100644 index 00000000000..b6f25d0ca70 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srv-service-name.yml @@ -0,0 +1,11 @@ +uri: "mongodb+srv://test22.test.build.10gen.cc/?srvServiceName=customname" +seeds: + - localhost.test.build.10gen.cc:27017 + - localhost.test.build.10gen.cc:27018 +hosts: + - localhost:27017 + - localhost:27018 + - localhost:27019 +options: + ssl: true + srvServiceName: "customname" diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-conflicts_with_replicaSet-txt.json b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-conflicts_with_replicaSet-txt.json new file mode 100644 index 00000000000..6de1e37fa55 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-conflicts_with_replicaSet-txt.json @@ -0,0 +1,7 @@ +{ + "uri": "mongodb+srv://test5.test.build.10gen.cc/?srvMaxHosts=1", + "seeds": [], + "hosts": [], + "error": true, + "comment": "Should fail because positive integer for srvMaxHosts conflicts with replicaSet option (TXT)" +} diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-conflicts_with_replicaSet-txt.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-conflicts_with_replicaSet-txt.yml new file mode 100644 index 00000000000..3ea5f3a47b7 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-conflicts_with_replicaSet-txt.yml @@ -0,0 +1,5 @@ +uri: "mongodb+srv://test5.test.build.10gen.cc/?srvMaxHosts=1" +seeds: [] +hosts: [] +error: true +comment: Should fail because positive integer for srvMaxHosts conflicts with replicaSet option (TXT) diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-conflicts_with_replicaSet.json b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-conflicts_with_replicaSet.json new file mode 100644 index 00000000000..f968757502d --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-conflicts_with_replicaSet.json @@ -0,0 +1,7 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0&srvMaxHosts=1", + "seeds": [], + "hosts": [], + "error": true, + "comment": "Should fail because positive integer for srvMaxHosts conflicts with replicaSet option" +} diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-conflicts_with_replicaSet.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-conflicts_with_replicaSet.yml new file mode 100644 index 00000000000..f67f114c23f --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-conflicts_with_replicaSet.yml @@ -0,0 +1,5 @@ +uri: "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0&srvMaxHosts=1" +seeds: [] +hosts: [] +error: true +comment: Should fail because positive integer for srvMaxHosts conflicts with replicaSet option diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-equal_to_srv_records.json b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-equal_to_srv_records.json new file mode 100644 index 00000000000..d9765ac6631 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-equal_to_srv_records.json @@ -0,0 +1,17 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2", + "numSeeds": 2, + "seeds": [ + "localhost.test.build.10gen.cc:27017", + "localhost.test.build.10gen.cc:27018" + ], + "hosts": [ + "localhost:27017", + "localhost:27018", + "localhost:27019" + ], + "options": { + "srvMaxHosts": 2, + "ssl": true + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-equal_to_srv_records.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-equal_to_srv_records.yml new file mode 100644 index 00000000000..6d905809b90 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-equal_to_srv_records.yml @@ -0,0 +1,16 @@ +# When srvMaxHosts equals the number of SRV records, all hosts are added to the +# seed list. +# +# The replicaSet URI option is omitted to avoid a URI validation error. +uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2" +numSeeds: 2 +seeds: + - localhost.test.build.10gen.cc:27017 + - localhost.test.build.10gen.cc:27018 +hosts: + - localhost:27017 + - localhost:27018 + - localhost:27019 +options: + srvMaxHosts: 2 + ssl: true diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-greater_than_srv_records.json b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-greater_than_srv_records.json new file mode 100644 index 00000000000..494bb87687a --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-greater_than_srv_records.json @@ -0,0 +1,16 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=3", + "seeds": [ + "localhost.test.build.10gen.cc:27017", + "localhost.test.build.10gen.cc:27018" + ], + "hosts": [ + "localhost:27017", + "localhost:27018", + "localhost:27019" + ], + "options": { + "srvMaxHosts": 3, + "ssl": true + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-greater_than_srv_records.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-greater_than_srv_records.yml new file mode 100644 index 00000000000..03307f81106 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-greater_than_srv_records.yml @@ -0,0 +1,15 @@ +# When srvMaxHosts is greater than the number of SRV records, all hosts are +# added to the seed list. +# +# The replicaSet URI option is omitted to avoid a URI validation error. +uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=3" +seeds: + - localhost.test.build.10gen.cc:27017 + - localhost.test.build.10gen.cc:27018 +hosts: + - localhost:27017 + - localhost:27018 + - localhost:27019 +options: + srvMaxHosts: 3 + ssl: true diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-invalid_integer.json b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-invalid_integer.json new file mode 100644 index 00000000000..5ba1a3b540c --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-invalid_integer.json @@ -0,0 +1,7 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0&srvMaxHosts=-1", + "seeds": [], + "hosts": [], + "error": true, + "comment": "Should fail because srvMaxHosts is not greater than or equal to zero" +} diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-invalid_integer.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-invalid_integer.yml new file mode 100644 index 00000000000..c813e957653 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-invalid_integer.yml @@ -0,0 +1,5 @@ +uri: "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0&srvMaxHosts=-1" +seeds: [] +hosts: [] +error: true +comment: Should fail because srvMaxHosts is not greater than or equal to zero diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-invalid_type.json b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-invalid_type.json new file mode 100644 index 00000000000..79e75b9b158 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-invalid_type.json @@ -0,0 +1,7 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0&srvMaxHosts=foo", + "seeds": [], + "hosts": [], + "error": true, + "comment": "Should fail because srvMaxHosts is not an integer" +} diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-invalid_type.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-invalid_type.yml new file mode 100644 index 00000000000..27109b8856f --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-invalid_type.yml @@ -0,0 +1,5 @@ +uri: "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0&srvMaxHosts=foo" +seeds: [] +hosts: [] +error: true +comment: Should fail because srvMaxHosts is not an integer diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-less_than_srv_records.json b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-less_than_srv_records.json new file mode 100644 index 00000000000..66a5e90dada --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-less_than_srv_records.json @@ -0,0 +1,13 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=1", + "numSeeds": 1, + "hosts": [ + "localhost:27017", + "localhost:27018", + "localhost:27019" + ], + "options": { + "srvMaxHosts": 1, + "ssl": true + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-less_than_srv_records.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-less_than_srv_records.yml new file mode 100644 index 00000000000..4ff86a623f1 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-less_than_srv_records.yml @@ -0,0 +1,15 @@ +# When srvMaxHosts is less than the number of SRV records, a random subset of +# hosts are added to the seed list. We cannot anticipate which hosts will be +# selected, so this test uses numSeeds instead of seeds. Since this is a replica +# set, all hosts should ultimately be discovered by SDAM. +# +# The replicaSet URI option is omitted to avoid a URI validation error. +uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=1" +numSeeds: 1 +hosts: + - localhost:27017 + - localhost:27018 + - localhost:27019 +options: + srvMaxHosts: 1 + ssl: true diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-zero-txt.json b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-zero-txt.json new file mode 100644 index 00000000000..241a901c649 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-zero-txt.json @@ -0,0 +1,17 @@ +{ + "uri": "mongodb+srv://test5.test.build.10gen.cc/?srvMaxHosts=0", + "seeds": [ + "localhost.test.build.10gen.cc:27017" + ], + "hosts": [ + "localhost:27017", + "localhost:27018", + "localhost:27019" + ], + "options": { + "authSource": "thisDB", + "replicaSet": "repl0", + "srvMaxHosts": 0, + "ssl": true + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-zero-txt.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-zero-txt.yml new file mode 100644 index 00000000000..0df9fb49f41 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-zero-txt.yml @@ -0,0 +1,15 @@ +# When srvMaxHosts is zero, all hosts are added to the seed list. +# +# replicaSet (TXT) is permitted because srvMaxHosts is non-positive. +uri: "mongodb+srv://test5.test.build.10gen.cc/?srvMaxHosts=0" +seeds: + - localhost.test.build.10gen.cc:27017 +hosts: + - localhost:27017 + - localhost:27018 + - localhost:27019 +options: + authSource: thisDB + replicaSet: repl0 + srvMaxHosts: 0 + ssl: true diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-zero.json b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-zero.json new file mode 100644 index 00000000000..c68610a2012 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-zero.json @@ -0,0 +1,17 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0&srvMaxHosts=0", + "seeds": [ + "localhost.test.build.10gen.cc:27017", + "localhost.test.build.10gen.cc:27018" + ], + "hosts": [ + "localhost:27017", + "localhost:27018", + "localhost:27019" + ], + "options": { + "replicaSet": "repl0", + "srvMaxHosts": 0, + "ssl": true + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-zero.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-zero.yml new file mode 100644 index 00000000000..30928892053 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/replica-set/srvMaxHosts-zero.yml @@ -0,0 +1,15 @@ +# When srvMaxHosts is zero, all hosts are added to the seed list. +# +# replicaSet is permitted because srvMaxHosts is non-positive. +uri: "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0&srvMaxHosts=0" +seeds: + - localhost.test.build.10gen.cc:27017 + - localhost.test.build.10gen.cc:27018 +hosts: + - localhost:27017 + - localhost:27018 + - localhost:27019 +options: + replicaSet: repl0 + srvMaxHosts: 0 + ssl: true diff --git a/test/spec/initial-dns-seedlist-discovery/two-results-default-port.json b/test/spec/initial-dns-seedlist-discovery/replica-set/two-results-default-port.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/two-results-default-port.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/two-results-default-port.json diff --git a/test/spec/initial-dns-seedlist-discovery/two-results-default-port.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/two-results-default-port.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/two-results-default-port.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/two-results-default-port.yml diff --git a/test/spec/initial-dns-seedlist-discovery/two-results-nonstandard-port.json b/test/spec/initial-dns-seedlist-discovery/replica-set/two-results-nonstandard-port.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/two-results-nonstandard-port.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/two-results-nonstandard-port.json diff --git a/test/spec/initial-dns-seedlist-discovery/two-results-nonstandard-port.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/two-results-nonstandard-port.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/two-results-nonstandard-port.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/two-results-nonstandard-port.yml diff --git a/test/spec/initial-dns-seedlist-discovery/two-txt-records.json b/test/spec/initial-dns-seedlist-discovery/replica-set/two-txt-records.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/two-txt-records.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/two-txt-records.json diff --git a/test/spec/initial-dns-seedlist-discovery/two-txt-records.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/two-txt-records.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/two-txt-records.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/two-txt-records.yml diff --git a/test/spec/initial-dns-seedlist-discovery/txt-record-not-allowed-option.json b/test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-not-allowed-option.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/txt-record-not-allowed-option.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-not-allowed-option.json diff --git a/test/spec/initial-dns-seedlist-discovery/txt-record-not-allowed-option.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-not-allowed-option.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/txt-record-not-allowed-option.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-not-allowed-option.yml diff --git a/test/spec/initial-dns-seedlist-discovery/txt-record-with-overridden-ssl-option.json b/test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-with-overridden-ssl-option.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/txt-record-with-overridden-ssl-option.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-with-overridden-ssl-option.json diff --git a/test/spec/initial-dns-seedlist-discovery/txt-record-with-overridden-ssl-option.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-with-overridden-ssl-option.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/txt-record-with-overridden-ssl-option.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-with-overridden-ssl-option.yml diff --git a/test/spec/initial-dns-seedlist-discovery/txt-record-with-overridden-uri-option.json b/test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-with-overridden-uri-option.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/txt-record-with-overridden-uri-option.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-with-overridden-uri-option.json diff --git a/test/spec/initial-dns-seedlist-discovery/txt-record-with-overridden-uri-option.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-with-overridden-uri-option.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/txt-record-with-overridden-uri-option.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-with-overridden-uri-option.yml diff --git a/test/spec/initial-dns-seedlist-discovery/txt-record-with-unallowed-option.json b/test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-with-unallowed-option.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/txt-record-with-unallowed-option.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-with-unallowed-option.json diff --git a/test/spec/initial-dns-seedlist-discovery/txt-record-with-unallowed-option.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-with-unallowed-option.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/txt-record-with-unallowed-option.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/txt-record-with-unallowed-option.yml diff --git a/test/spec/initial-dns-seedlist-discovery/uri-with-admin-database.json b/test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-admin-database.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/uri-with-admin-database.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-admin-database.json diff --git a/test/spec/initial-dns-seedlist-discovery/uri-with-admin-database.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-admin-database.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/uri-with-admin-database.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-admin-database.yml diff --git a/test/spec/initial-dns-seedlist-discovery/uri-with-auth.json b/test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-auth.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/uri-with-auth.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-auth.json diff --git a/test/spec/initial-dns-seedlist-discovery/uri-with-auth.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-auth.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/uri-with-auth.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-auth.yml diff --git a/test/spec/initial-dns-seedlist-discovery/uri-with-port.json b/test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-port.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/uri-with-port.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-port.json diff --git a/test/spec/initial-dns-seedlist-discovery/uri-with-port.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-port.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/uri-with-port.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-port.yml diff --git a/test/spec/initial-dns-seedlist-discovery/uri-with-two-hosts.json b/test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-two-hosts.json similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/uri-with-two-hosts.json rename to test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-two-hosts.json diff --git a/test/spec/initial-dns-seedlist-discovery/uri-with-two-hosts.yml b/test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-two-hosts.yml similarity index 100% rename from test/spec/initial-dns-seedlist-discovery/uri-with-two-hosts.yml rename to test/spec/initial-dns-seedlist-discovery/replica-set/uri-with-two-hosts.yml diff --git a/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-equal_to_srv_records.json b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-equal_to_srv_records.json new file mode 100644 index 00000000000..46390726f0d --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-equal_to_srv_records.json @@ -0,0 +1,16 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2", + "numSeeds": 2, + "seeds": [ + "localhost.test.build.10gen.cc:27017", + "localhost.test.build.10gen.cc:27018" + ], + "hosts": [ + "localhost.test.build.10gen.cc:27017", + "localhost.test.build.10gen.cc:27018" + ], + "options": { + "srvMaxHosts": 2, + "ssl": true + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-equal_to_srv_records.yml b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-equal_to_srv_records.yml new file mode 100644 index 00000000000..89692308b65 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-equal_to_srv_records.yml @@ -0,0 +1,13 @@ +# When srvMaxHosts equals the number of SRV records, all hosts are added to the +# seed list. +uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2" +numSeeds: 2 +seeds: + - localhost.test.build.10gen.cc:27017 + - localhost.test.build.10gen.cc:27018 +hosts: + - localhost.test.build.10gen.cc:27017 + - localhost.test.build.10gen.cc:27018 +options: + srvMaxHosts: 2 + ssl: true diff --git a/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-greater_than_srv_records.json b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-greater_than_srv_records.json new file mode 100644 index 00000000000..e02d72bf280 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-greater_than_srv_records.json @@ -0,0 +1,15 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=3", + "seeds": [ + "localhost.test.build.10gen.cc:27017", + "localhost.test.build.10gen.cc:27018" + ], + "hosts": [ + "localhost.test.build.10gen.cc:27017", + "localhost.test.build.10gen.cc:27018" + ], + "options": { + "srvMaxHosts": 3, + "ssl": true + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-greater_than_srv_records.yml b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-greater_than_srv_records.yml new file mode 100644 index 00000000000..860dfacbb47 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-greater_than_srv_records.yml @@ -0,0 +1,12 @@ +# When srvMaxHosts is greater than the number of SRV records, all hosts are +# added to the seed list. +uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=3" +seeds: + - localhost.test.build.10gen.cc:27017 + - localhost.test.build.10gen.cc:27018 +hosts: + - localhost.test.build.10gen.cc:27017 + - localhost.test.build.10gen.cc:27018 +options: + srvMaxHosts: 3 + ssl: true diff --git a/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-invalid_integer.json b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-invalid_integer.json new file mode 100644 index 00000000000..0939624fc3a --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-invalid_integer.json @@ -0,0 +1,7 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=-1", + "seeds": [], + "hosts": [], + "error": true, + "comment": "Should fail because srvMaxHosts is not greater than or equal to zero" +} diff --git a/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-invalid_integer.yml b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-invalid_integer.yml new file mode 100644 index 00000000000..836e0191fa7 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-invalid_integer.yml @@ -0,0 +1,5 @@ +uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=-1" +seeds: [] +hosts: [] +error: true +comment: Should fail because srvMaxHosts is not greater than or equal to zero diff --git a/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-invalid_type.json b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-invalid_type.json new file mode 100644 index 00000000000..c228d266120 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-invalid_type.json @@ -0,0 +1,7 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=foo", + "seeds": [], + "hosts": [], + "error": true, + "comment": "Should fail because srvMaxHosts is not an integer" +} diff --git a/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-invalid_type.yml b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-invalid_type.yml new file mode 100644 index 00000000000..b852934b810 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-invalid_type.yml @@ -0,0 +1,5 @@ +uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=foo" +seeds: [] +hosts: [] +error: true +comment: Should fail because srvMaxHosts is not an integer diff --git a/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-less_than_srv_records.json b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-less_than_srv_records.json new file mode 100644 index 00000000000..fdcc1692c0f --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-less_than_srv_records.json @@ -0,0 +1,9 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=1", + "numSeeds": 1, + "numHosts": 1, + "options": { + "srvMaxHosts": 1, + "ssl": true + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-less_than_srv_records.yml b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-less_than_srv_records.yml new file mode 100644 index 00000000000..31849524df4 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-less_than_srv_records.yml @@ -0,0 +1,10 @@ +# When srvMaxHosts is less than the number of SRV records, a random subset of +# hosts are added to the seed list. We cannot anticipate which hosts will be +# selected, so this test uses numSeeds and numHosts instead of seeds and hosts, +# respectively. +uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=1" +numSeeds: 1 +numHosts: 1 +options: + srvMaxHosts: 1 + ssl: true diff --git a/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-zero.json b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-zero.json new file mode 100644 index 00000000000..10ab9e656dc --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-zero.json @@ -0,0 +1,15 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=0", + "seeds": [ + "localhost.test.build.10gen.cc:27017", + "localhost.test.build.10gen.cc:27018" + ], + "hosts": [ + "localhost.test.build.10gen.cc:27017", + "localhost.test.build.10gen.cc:27018" + ], + "options": { + "srvMaxHosts": 0, + "ssl": true + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-zero.yml b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-zero.yml new file mode 100644 index 00000000000..9043409dfda --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/sharded/srvMaxHosts-zero.yml @@ -0,0 +1,11 @@ +# When srvMaxHosts is zero, all hosts are added to the seed list. +uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=0" +seeds: + - localhost.test.build.10gen.cc:27017 + - localhost.test.build.10gen.cc:27018 +hosts: + - localhost.test.build.10gen.cc:27017 + - localhost.test.build.10gen.cc:27018 +options: + srvMaxHosts: 0 + ssl: true diff --git a/test/spec/uri-options/README.rst b/test/spec/uri-options/README.rst index 97bf598389c..f6a128bba93 100644 --- a/test/spec/uri-options/README.rst +++ b/test/spec/uri-options/README.rst @@ -38,6 +38,11 @@ The ``valid`` and ``warning`` fields are boolean in order to keep the tests flexible. We are not concerned with asserting the format of specific error or warnings messages strings. +Under normal circumstances, it should not be necessary to specify both +``valid: false`` and ``warning: true``. Typically, a URI test case will either +yield an error (e.g. options conflict) or a warning (e.g. invalid type or value +for an option), but not both. + Use as unit tests ================= diff --git a/test/spec/uri-options/srv-options.json b/test/spec/uri-options/srv-options.json new file mode 100644 index 00000000000..ffc356f12f0 --- /dev/null +++ b/test/spec/uri-options/srv-options.json @@ -0,0 +1,116 @@ +{ + "tests": [ + { + "description": "SRV URI with custom srvServiceName", + "uri": "mongodb+srv://test22.test.build.10gen.cc/?srvServiceName=customname", + "valid": true, + "warning": false, + "hosts": null, + "auth": null, + "options": { + "srvServiceName": "customname" + } + }, + { + "description": "Non-SRV URI with custom srvServiceName", + "uri": "mongodb://example.com/?srvServiceName=customname", + "valid": false, + "warning": false, + "hosts": null, + "auth": null, + "options": {} + }, + { + "description": "SRV URI with srvMaxHosts", + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2", + "valid": true, + "warning": false, + "hosts": null, + "auth": null, + "options": { + "srvMaxHosts": 2 + } + }, + { + "description": "SRV URI with negative integer for srvMaxHosts", + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=-1", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": {} + }, + { + "description": "SRV URI with invalid type for srvMaxHosts", + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=foo", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": {} + }, + { + "description": "Non-SRV URI with srvMaxHosts", + "uri": "mongodb://example.com/?srvMaxHosts=2", + "valid": false, + "warning": false, + "hosts": null, + "auth": null, + "options": {} + }, + { + "description": "SRV URI with positive srvMaxHosts and replicaSet", + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2&replicaSet=foo", + "valid": false, + "warning": false, + "hosts": null, + "auth": null, + "options": {} + }, + { + "description": "SRV URI with positive srvMaxHosts and loadBalanced=true", + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2&loadBalanced=true", + "valid": false, + "warning": false, + "hosts": null, + "auth": null, + "options": {} + }, + { + "description": "SRV URI with positive srvMaxHosts and loadBalanced=false", + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2&loadBalanced=false", + "valid": true, + "warning": false, + "hosts": null, + "auth": null, + "options": { + "loadBalanced": false, + "srvMaxHosts": 2 + } + }, + { + "description": "SRV URI with srvMaxHosts=0 and replicaSet", + "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=0&replicaSet=foo", + "valid": true, + "warning": false, + "hosts": null, + "auth": null, + "options": { + "replicaSet": "foo", + "srvMaxHosts": 0 + } + }, + { + "description": "SRV URI with srvMaxHosts=0 and loadBalanced=true", + "uri": "mongodb+srv://test3.test.build.10gen.cc/?srvMaxHosts=0&loadBalanced=true", + "valid": true, + "warning": false, + "hosts": null, + "auth": null, + "options": { + "loadBalanced": true, + "srvMaxHosts": 0 + } + } + ] +} diff --git a/test/spec/uri-options/srv-options.yml b/test/spec/uri-options/srv-options.yml new file mode 100644 index 00000000000..2f5210cbe75 --- /dev/null +++ b/test/spec/uri-options/srv-options.yml @@ -0,0 +1,89 @@ +tests: + - description: "SRV URI with custom srvServiceName" + uri: "mongodb+srv://test22.test.build.10gen.cc/?srvServiceName=customname" + valid: true + warning: false + hosts: ~ + auth: ~ + options: + srvServiceName: "customname" + - description: "Non-SRV URI with custom srvServiceName" + uri: "mongodb://example.com/?srvServiceName=customname" + valid: false + warning: false + hosts: ~ + auth: ~ + options: {} + - description: "SRV URI with srvMaxHosts" + uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2" + valid: true + warning: false + hosts: ~ + auth: ~ + options: + srvMaxHosts: 2 + - description: "SRV URI with negative integer for srvMaxHosts" + uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=-1" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} + - description: "SRV URI with invalid type for srvMaxHosts" + uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=foo" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} + - description: "Non-SRV URI with srvMaxHosts" + uri: "mongodb://example.com/?srvMaxHosts=2" + valid: false + warning: false + hosts: ~ + auth: ~ + options: {} + # Note: Testing URI validation for srvMaxHosts conflicting with either + # loadBalanced=true or replicaSet specified via TXT records is covered by + # the Initial DNS Seedlist Discovery test suite. + - description: "SRV URI with positive srvMaxHosts and replicaSet" + uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2&replicaSet=foo" + valid: false + warning: false + hosts: ~ + auth: ~ + options: {} + - description: "SRV URI with positive srvMaxHosts and loadBalanced=true" + uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2&loadBalanced=true" + valid: false + warning: false + hosts: ~ + auth: ~ + options: {} + - description: "SRV URI with positive srvMaxHosts and loadBalanced=false" + uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2&loadBalanced=false" + valid: true + warning: false + hosts: ~ + auth: ~ + options: + loadBalanced: false + srvMaxHosts: 2 + - description: "SRV URI with srvMaxHosts=0 and replicaSet" + uri: "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=0&replicaSet=foo" + valid: true + warning: false + hosts: ~ + auth: ~ + options: + replicaSet: foo + srvMaxHosts: 0 + - description: "SRV URI with srvMaxHosts=0 and loadBalanced=true" + uri: "mongodb+srv://test3.test.build.10gen.cc/?srvMaxHosts=0&loadBalanced=true" + valid: true + warning: false + hosts: ~ + auth: ~ + options: + loadBalanced: true + srvMaxHosts: 0 \ No newline at end of file diff --git a/test/unit/connection_string.test.js b/test/unit/connection_string.test.js index 4c2064faa6e..647599c64ee 100644 --- a/test/unit/connection_string.test.js +++ b/test/unit/connection_string.test.js @@ -25,6 +25,8 @@ const skipTests = [ 'Deprecated (or unknown) options are ignored if replacement exists' ]; +const SPEC_PATHS = ['load-balanced', 'replica-set', 'sharded']; + describe('Connection String', function () { it('should not support auth passed with user', function () { const optionsWithUser = { @@ -222,71 +224,79 @@ describe('Connection String', function () { expect(options.srvHost).to.equal('test1.test.build.10gen.cc'); }); - describe('spec tests', function () { - const specPath = path.join(__dirname, '../spec', 'initial-dns-seedlist-discovery'); - const testFiles = fs - .readdirSync(specPath) - .filter(x => x.indexOf('.json') !== -1) - .map(x => [x, fs.readFileSync(path.join(specPath, x), 'utf8')]) - .map(x => [path.basename(x[0], '.json'), JSON.parse(x[1])]); - - testFiles.forEach(test => { - if (!test[1].comment) { - test[1].comment = test[0]; - } + SPEC_PATHS.forEach(function (folder) { + describe('spec tests', function () { + const specPath = path.join(__dirname, '../spec', 'initial-dns-seedlist-discovery', folder); + const testFiles = fs + .readdirSync(specPath) + .filter(x => x.indexOf('.json') !== -1) + .map(x => [x, fs.readFileSync(path.join(specPath, x), 'utf8')]) + .map(x => [path.basename(x[0], '.json'), JSON.parse(x[1])]); + + testFiles.forEach(test => { + if (!test[1].comment) { + test[1].comment = test[0]; + } - it(test[1].comment, { - metadata: { requires: { topology: ['single'] } }, - test: function (done) { - try { - const options = parseOptions(test[1].uri); - resolveSRVRecord(options, (err, result) => { - if (test[1].error) { - expect(err).to.exist; - expect(result).to.not.exist; - } else { - expect(err).to.not.exist; - expect(result).to.exist; - // Implicit SRV options must be set. - expect(options.directConnection).to.be.false; - const testOptions = test[1].options; - if (testOptions && 'tls' in testOptions) { - expect(options).to.have.property('tls', testOptions.tls); - } else if (testOptions && 'ssl' in testOptions) { - expect(options).to.have.property('tls', testOptions.ssl); + const comment = test[1].comment; + const skipTest = comment.search(/^(srvMaxHosts|srv-service-name)/) > -1; + const maybeIt = skipTest ? it.skip : it; + // TODO: NODE-3467: Implement maxSrvHosts work + maybeIt(comment, { + metadata: { requires: { topology: ['single'] } }, + test: function (done) { + try { + const options = parseOptions(test[1].uri); + resolveSRVRecord(options, (err, result) => { + if (test[1].error) { + expect(err).to.exist; + expect(result).to.not.exist; } else { - expect(options.tls).to.be.true; - } - if (testOptions && testOptions.replicaSet) { - expect(options).to.have.property('replicaSet', testOptions.replicaSet); - } - if (testOptions && testOptions.authSource) { - expect(options).to.have.property('credentials'); - expect(options.credentials.source).to.equal(testOptions.authSource); - } - if (testOptions && testOptions.loadBalanced) { - expect(options).to.have.property('loadBalanced', testOptions.loadBalanced); - } - if ( - test[1].parsed_options && - test[1].parsed_options.user && - test[1].parsed_options.password - ) { - expect(options.credentials.username).to.equal(test[1].parsed_options.user); - expect(options.credentials.password).to.equal(test[1].parsed_options.password); + expect(err).to.not.exist; + expect(result).to.exist; + // Implicit SRV options must be set. + expect(options.directConnection).to.be.false; + const testOptions = test[1].options; + if (testOptions && 'tls' in testOptions) { + expect(options).to.have.property('tls', testOptions.tls); + } else if (testOptions && 'ssl' in testOptions) { + expect(options).to.have.property('tls', testOptions.ssl); + } else { + expect(options.tls).to.be.true; + } + if (testOptions && testOptions.replicaSet) { + expect(options).to.have.property('replicaSet', testOptions.replicaSet); + } + if (testOptions && testOptions.authSource) { + expect(options).to.have.property('credentials'); + expect(options.credentials.source).to.equal(testOptions.authSource); + } + if (testOptions && testOptions.loadBalanced) { + expect(options).to.have.property('loadBalanced', testOptions.loadBalanced); + } + if ( + test[1].parsed_options && + test[1].parsed_options.user && + test[1].parsed_options.password + ) { + expect(options.credentials.username).to.equal(test[1].parsed_options.user); + expect(options.credentials.password).to.equal( + test[1].parsed_options.password + ); + } } + done(); + }); + } catch (error) { + if (test[1].error) { + expect(error).to.exist; + done(); + } else { + throw error; } - done(); - }); - } catch (error) { - if (test[1].error) { - expect(error).to.exist; - done(); - } else { - throw error; } } - } + }); }); }); });