From 53d80883077c0d4f3dd339a725cc5a4545be5ea2 Mon Sep 17 00:00:00 2001 From: Kaitlin Mahar Date: Wed, 1 Sep 2021 15:36:04 -0400 Subject: [PATCH 1/4] Move existing files to replica-set/ directory --- Tests/MongoSwiftTests/DNSSeedlistTests.swift | 1 + .../tests/{ => replica-set}/direct-connection-false.json | 0 .../tests/{ => replica-set}/direct-connection-true.json | 0 .../tests/{ => replica-set}/encoded-userinfo-and-db.json | 0 .../tests/{ => replica-set}/longer-parent-in-return.json | 0 .../tests/{ => replica-set}/misformatted-option.json | 0 .../tests/{ => replica-set}/no-results.json | 0 .../tests/{ => replica-set}/not-enough-parts.json | 0 .../tests/{ => replica-set}/one-result-default-port.json | 0 .../tests/{ => replica-set}/one-txt-record-multiple-strings.json | 0 .../tests/{ => replica-set}/one-txt-record.json | 0 .../tests/{ => replica-set}/parent-part-mismatch1.json | 0 .../tests/{ => replica-set}/parent-part-mismatch2.json | 0 .../tests/{ => replica-set}/parent-part-mismatch3.json | 0 .../tests/{ => replica-set}/parent-part-mismatch4.json | 0 .../tests/{ => replica-set}/parent-part-mismatch5.json | 0 .../tests/{ => replica-set}/returned-parent-too-short.json | 0 .../tests/{ => replica-set}/returned-parent-wrong.json | 0 .../tests/{ => replica-set}/two-results-default-port.json | 0 .../tests/{ => replica-set}/two-results-nonstandard-port.json | 0 .../tests/{ => replica-set}/two-txt-records.json | 0 .../tests/{ => replica-set}/txt-record-not-allowed-option.json | 0 .../{ => replica-set}/txt-record-with-overridden-ssl-option.json | 0 .../{ => replica-set}/txt-record-with-overridden-uri-option.json | 0 .../{ => replica-set}/txt-record-with-unallowed-option.json | 0 .../tests/{ => replica-set}/uri-with-admin-database.json | 0 .../tests/{ => replica-set}/uri-with-auth.json | 0 .../tests/{ => replica-set}/uri-with-port.json | 0 .../tests/{ => replica-set}/uri-with-two-hosts.json | 0 29 files changed, 1 insertion(+) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/direct-connection-false.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/direct-connection-true.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/encoded-userinfo-and-db.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/longer-parent-in-return.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/misformatted-option.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/no-results.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/not-enough-parts.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/one-result-default-port.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/one-txt-record-multiple-strings.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/one-txt-record.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/parent-part-mismatch1.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/parent-part-mismatch2.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/parent-part-mismatch3.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/parent-part-mismatch4.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/parent-part-mismatch5.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/returned-parent-too-short.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/returned-parent-wrong.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/two-results-default-port.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/two-results-nonstandard-port.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/two-txt-records.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/txt-record-not-allowed-option.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/txt-record-with-overridden-ssl-option.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/txt-record-with-overridden-uri-option.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/txt-record-with-unallowed-option.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/uri-with-admin-database.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/uri-with-auth.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/uri-with-port.json (100%) rename Tests/Specs/initial-dns-seedlist-discovery/tests/{ => replica-set}/uri-with-two-hosts.json (100%) diff --git a/Tests/MongoSwiftTests/DNSSeedlistTests.swift b/Tests/MongoSwiftTests/DNSSeedlistTests.swift index d4e4e2f37..0b37bfcff 100644 --- a/Tests/MongoSwiftTests/DNSSeedlistTests.swift +++ b/Tests/MongoSwiftTests/DNSSeedlistTests.swift @@ -54,6 +54,7 @@ final class DNSSeedlistTests: MongoSwiftTestCase { let tests = try retrieveSpecTestFiles( specName: "initial-dns-seedlist-discovery", + subdirectory: "replica-set", asType: DNSSeedlistTestCase.self ) for (fileName, testCase) in tests { diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/direct-connection-false.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/direct-connection-false.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/direct-connection-false.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/direct-connection-false.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/direct-connection-true.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/direct-connection-true.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/direct-connection-true.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/direct-connection-true.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/encoded-userinfo-and-db.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/encoded-userinfo-and-db.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/encoded-userinfo-and-db.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/encoded-userinfo-and-db.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/longer-parent-in-return.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/longer-parent-in-return.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/longer-parent-in-return.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/longer-parent-in-return.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/misformatted-option.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/misformatted-option.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/misformatted-option.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/misformatted-option.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/no-results.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/no-results.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/no-results.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/no-results.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/not-enough-parts.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/not-enough-parts.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/not-enough-parts.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/not-enough-parts.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/one-result-default-port.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/one-result-default-port.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/one-result-default-port.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/one-result-default-port.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/one-txt-record-multiple-strings.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/one-txt-record-multiple-strings.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/one-txt-record-multiple-strings.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/one-txt-record-multiple-strings.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/one-txt-record.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/one-txt-record.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/one-txt-record.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/one-txt-record.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/parent-part-mismatch1.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/parent-part-mismatch1.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/parent-part-mismatch1.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/parent-part-mismatch1.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/parent-part-mismatch2.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/parent-part-mismatch2.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/parent-part-mismatch2.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/parent-part-mismatch2.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/parent-part-mismatch3.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/parent-part-mismatch3.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/parent-part-mismatch3.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/parent-part-mismatch3.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/parent-part-mismatch4.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/parent-part-mismatch4.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/parent-part-mismatch4.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/parent-part-mismatch4.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/parent-part-mismatch5.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/parent-part-mismatch5.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/parent-part-mismatch5.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/parent-part-mismatch5.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/returned-parent-too-short.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/returned-parent-too-short.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/returned-parent-too-short.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/returned-parent-too-short.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/returned-parent-wrong.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/returned-parent-wrong.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/returned-parent-wrong.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/returned-parent-wrong.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/two-results-default-port.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/two-results-default-port.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/two-results-default-port.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/two-results-default-port.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/two-results-nonstandard-port.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/two-results-nonstandard-port.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/two-results-nonstandard-port.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/two-results-nonstandard-port.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/two-txt-records.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/two-txt-records.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/two-txt-records.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/two-txt-records.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/txt-record-not-allowed-option.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/txt-record-not-allowed-option.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/txt-record-not-allowed-option.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/txt-record-not-allowed-option.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/txt-record-with-overridden-ssl-option.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/txt-record-with-overridden-ssl-option.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/txt-record-with-overridden-ssl-option.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/txt-record-with-overridden-ssl-option.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/txt-record-with-overridden-uri-option.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/txt-record-with-overridden-uri-option.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/txt-record-with-overridden-uri-option.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/txt-record-with-overridden-uri-option.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/txt-record-with-unallowed-option.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/txt-record-with-unallowed-option.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/txt-record-with-unallowed-option.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/txt-record-with-unallowed-option.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/uri-with-admin-database.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/uri-with-admin-database.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/uri-with-admin-database.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/uri-with-admin-database.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/uri-with-auth.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/uri-with-auth.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/uri-with-auth.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/uri-with-auth.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/uri-with-port.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/uri-with-port.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/uri-with-port.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/uri-with-port.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/uri-with-two-hosts.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/uri-with-two-hosts.json similarity index 100% rename from Tests/Specs/initial-dns-seedlist-discovery/tests/uri-with-two-hosts.json rename to Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/uri-with-two-hosts.json From 78c0109bb151cc22ef35e34f05c6aa48f142194f Mon Sep 17 00:00:00 2001 From: Kaitlin Mahar Date: Wed, 1 Sep 2021 15:39:09 -0400 Subject: [PATCH 2/4] Sync README and new test files --- .../tests/README.rst | 14 +++++++++++--- .../loadBalanced-directConnection.json | 14 ++++++++++++++ .../load-balanced/loadBalanced-no-results.json | 7 +++++++ .../loadBalanced-replicaSet-errors.json | 7 +++++++ .../loadBalanced-true-multiple-hosts.json | 7 +++++++ .../load-balanced/loadBalanced-true-txt.json | 13 +++++++++++++ .../replica-set/direct-connection-false.json | 3 ++- .../tests/replica-set/loadBalanced-false-txt.json | 15 +++++++++++++++ 8 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-directConnection.json create mode 100644 Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-no-results.json create mode 100644 Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-replicaSet-errors.json create mode 100644 Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-true-multiple-hosts.json create mode 100644 Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-true-txt.json create mode 100644 Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/loadBalanced-false-txt.json diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/README.rst b/Tests/Specs/initial-dns-seedlist-discovery/tests/README.rst index 6072deb73..47bb75b4f 100644 --- a/Tests/Specs/initial-dns-seedlist-discovery/tests/README.rst +++ b/Tests/Specs/initial-dns-seedlist-discovery/tests/README.rst @@ -8,9 +8,13 @@ to prove their conformance to the Initial DNS Seedlist Discovery spec. Test Setup ---------- -Start a three-node replica set on localhost, on ports 27017, 27018, and 27019, -with replica set name "repl0". The replica set MUST be started with SSL -enabled. +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. 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 @@ -41,6 +45,8 @@ these tests:: _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 Text test5.test.build.10gen.cc. 86400 IN TXT "replicaSet=repl0&authSource=thisDB" @@ -50,6 +56,8 @@ these tests:: test8.test.build.10gen.cc. 86400 IN TXT "authSource" test10.test.build.10gen.cc. 86400 IN TXT "socketTimeoutMS=500" 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" 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 diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-directConnection.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-directConnection.json new file mode 100644 index 000000000..7f41932bb --- /dev/null +++ b/Tests/Specs/initial-dns-seedlist-discovery/tests/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/Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-no-results.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-no-results.json new file mode 100644 index 000000000..7f49416aa --- /dev/null +++ b/Tests/Specs/initial-dns-seedlist-discovery/tests/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/Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-replicaSet-errors.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-replicaSet-errors.json new file mode 100644 index 000000000..9ed5ff22c --- /dev/null +++ b/Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-replicaSet-errors.json @@ -0,0 +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" +} diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-true-multiple-hosts.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-true-multiple-hosts.json new file mode 100644 index 000000000..f425c06b3 --- /dev/null +++ b/Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-true-multiple-hosts.json @@ -0,0 +1,7 @@ +{ + "uri": "mongodb+srv://test1.test.build.10gen.cc/?loadBalanced=true", + "seeds": [], + "hosts": [], + "error": true, + "comment": "Should fail because loadBalanced is true but the SRV record resolves to multiple hosts" +} diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-true-txt.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-true-txt.json new file mode 100644 index 000000000..0117b3e9c --- /dev/null +++ b/Tests/Specs/initial-dns-seedlist-discovery/tests/load-balanced/loadBalanced-true-txt.json @@ -0,0 +1,13 @@ +{ + "uri": "mongodb+srv://test20.test.build.10gen.cc/", + "seeds": [ + "localhost.test.build.10gen.cc:27017" + ], + "hosts": [ + "localhost.test.build.10gen.cc:27017" + ], + "options": { + "loadBalanced": true, + "ssl": true + } +} diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/direct-connection-false.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/direct-connection-false.json index 01560d5ac..1d57bdcb3 100644 --- a/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/direct-connection-false.json +++ b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/direct-connection-false.json @@ -9,6 +9,7 @@ "localhost:27019" ], "options": { - "ssl": true + "ssl": true, + "directConnection": false } } diff --git a/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/loadBalanced-false-txt.json b/Tests/Specs/initial-dns-seedlist-discovery/tests/replica-set/loadBalanced-false-txt.json new file mode 100644 index 000000000..fd2e565c7 --- /dev/null +++ b/Tests/Specs/initial-dns-seedlist-discovery/tests/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 + } +} From ac861bb51918c9e9398e4e586cad348e6c7ae873 Mon Sep 17 00:00:00 2001 From: Kaitlin Mahar Date: Wed, 1 Sep 2021 17:51:34 -0400 Subject: [PATCH 3/4] Run new tests, fix error msg --- Sources/TestsCommon/CommonTestUtils.swift | 2 +- Tests/MongoSwiftTests/DNSSeedlistTests.swift | 33 +++++++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Sources/TestsCommon/CommonTestUtils.swift b/Sources/TestsCommon/CommonTestUtils.swift index 1277b5e47..51bbb4da4 100644 --- a/Sources/TestsCommon/CommonTestUtils.swift +++ b/Sources/TestsCommon/CommonTestUtils.swift @@ -58,7 +58,7 @@ open class MongoSwiftTestCase: XCTestCase { return try! ConnectionString(uri) case (.loadBalanced, false): guard let uri = Self.multipleMongosLoadBalancedURI else { - fatalError("Missing MULTIPLE_MONGOS_LB_URI environment variable") + fatalError("Missing MULTI_MONGOS_LB_URI environment variable") } return try! ConnectionString(uri) default: diff --git a/Tests/MongoSwiftTests/DNSSeedlistTests.swift b/Tests/MongoSwiftTests/DNSSeedlistTests.swift index 0b37bfcff..3be5716b0 100644 --- a/Tests/MongoSwiftTests/DNSSeedlistTests.swift +++ b/Tests/MongoSwiftTests/DNSSeedlistTests.swift @@ -46,7 +46,7 @@ final class DNSSeedlistTests: MongoSwiftTestCase { // Note: the file txt-record-with-overridden-uri-option.json causes a mongoc warning. This is expected. // swiftlint:disable:next cyclomatic_complexity - func testInitialDNSSeedlistDiscovery() throws { + func testInitialDNSSeedlistDiscoveryReplicaSet() throws { guard MongoSwiftTestCase.topologyType == .replicaSetWithPrimary else { print("Skipping test because of unsupported topology type \(MongoSwiftTestCase.topologyType)") return @@ -57,16 +57,35 @@ final class DNSSeedlistTests: MongoSwiftTestCase { subdirectory: "replica-set", asType: DNSSeedlistTestCase.self ) - for (fileName, testCase) in tests { - // TODO: SWIFT-910: unskip this test - guard fileName != "txt-record-with-overridden-uri-option.json" else { - print("Skipping test file \(fileName); see SWIFT-910") - continue - } + + try runDNSSeedlistTests(tests) + } + + func testInitialDNSSeedlistDiscoveryLoadBalanced() throws { + guard MongoSwiftTestCase.topologyType == .loadBalanced else { + print("Skipping test because of unsupported topology type \(MongoSwiftTestCase.topologyType)") + return + } + + let tests = try retrieveSpecTestFiles( + specName: "initial-dns-seedlist-discovery", + subdirectory: "load-balanced", + asType: DNSSeedlistTestCase.self + ) + + try runDNSSeedlistTests(tests) + } + func runDNSSeedlistTests(_ tests: [(String, DNSSeedlistTestCase)]) throws { + for (fileName, testCase) in tests { // this particular test case requires SSL is disabled. see DRIVERS-1324. let requiresTLS = fileName != "txt-record-with-overridden-ssl-option.json" + // skipping due to a libmongoc bug. TODO: SWIFT-1343 unskip. + guard fileName != "loadBalanced-replicaSet-errors.json" else { + continue + } + // TLS requirement for this test case is not met. guard (requiresTLS && MongoSwiftTestCase.ssl) || (!requiresTLS && !MongoSwiftTestCase.ssl) else { print("Skipping test file \(fileName); TLS requirement not met") From edaee58a94a61557b4c070e1a64072059be53d63 Mon Sep 17 00:00:00 2001 From: Kaitlin Mahar Date: Wed, 1 Sep 2021 17:59:27 -0400 Subject: [PATCH 4/4] format/lint, update linuxmain --- Tests/LinuxMain.swift | 3 ++- Tests/MongoSwiftTests/DNSSeedlistTests.swift | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index b8f713ab7..3aa077a4b 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -92,7 +92,8 @@ extension CrudTests { extension DNSSeedlistTests { static var allTests = [ - ("testInitialDNSSeedlistDiscovery", testInitialDNSSeedlistDiscovery), + ("testInitialDNSSeedlistDiscoveryReplicaSet", testInitialDNSSeedlistDiscoveryReplicaSet), + ("testInitialDNSSeedlistDiscoveryLoadBalanced", testInitialDNSSeedlistDiscoveryLoadBalanced), ] } diff --git a/Tests/MongoSwiftTests/DNSSeedlistTests.swift b/Tests/MongoSwiftTests/DNSSeedlistTests.swift index 3be5716b0..cbd60ef18 100644 --- a/Tests/MongoSwiftTests/DNSSeedlistTests.swift +++ b/Tests/MongoSwiftTests/DNSSeedlistTests.swift @@ -57,7 +57,7 @@ final class DNSSeedlistTests: MongoSwiftTestCase { subdirectory: "replica-set", asType: DNSSeedlistTestCase.self ) - + try runDNSSeedlistTests(tests) } @@ -72,7 +72,7 @@ final class DNSSeedlistTests: MongoSwiftTestCase { subdirectory: "load-balanced", asType: DNSSeedlistTestCase.self ) - + try runDNSSeedlistTests(tests) }