Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

Commit 01c3120

Browse files
committed
test(mongodb-srv): add initial-dns-seedlist-discovery spec tests
NODE-1295
1 parent 45fbe34 commit 01c3120

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+479
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
====================================
2+
Initial DNS Seedlist Discovery tests
3+
====================================
4+
5+
This directory contains platform-independent tests that drivers can use
6+
to prove their conformance to the Initial DNS Seedlist Discovery spec.
7+
8+
Test Setup
9+
----------
10+
11+
Start a three-node replica set on localhost, on ports 27017, 27018, and 27019,
12+
with replica set name "repl0". The replica set MUST be started with SSL
13+
enabled.
14+
15+
To run the tests that accompany this spec, you need to configure the SRV and
16+
TXT records with a real name server. The following records are required for
17+
these tests::
18+
19+
Record TTL Class Address
20+
localhost.test.build.10gen.cc. 86400 IN A 127.0.0.1
21+
localhost.sub.test.build.10gen.cc. 86400 IN A 127.0.0.1
22+
23+
Record TTL Class Port Target
24+
_mongodb._tcp.test1.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
25+
_mongodb._tcp.test1.test.build.10gen.cc. 86400 IN SRV 27018 localhost.test.build.10gen.cc.
26+
_mongodb._tcp.test2.test.build.10gen.cc. 86400 IN SRV 27018 localhost.test.build.10gen.cc.
27+
_mongodb._tcp.test2.test.build.10gen.cc. 86400 IN SRV 27019 localhost.test.build.10gen.cc.
28+
_mongodb._tcp.test3.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
29+
_mongodb._tcp.test5.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
30+
_mongodb._tcp.test6.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
31+
_mongodb._tcp.test7.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
32+
_mongodb._tcp.test8.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
33+
_mongodb._tcp.test10.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
34+
_mongodb._tcp.test11.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
35+
_mongodb._tcp.test12.test.build.10gen.cc. 86400 IN SRV 27017 localhost.build.10gen.cc.
36+
_mongodb._tcp.test13.test.build.10gen.cc. 86400 IN SRV 27017 test.build.10gen.cc.
37+
_mongodb._tcp.test14.test.build.10gen.cc. 86400 IN SRV 27017 localhost.not-test.build.10gen.cc.
38+
_mongodb._tcp.test15.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.not-build.10gen.cc.
39+
_mongodb._tcp.test16.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.not-10gen.cc.
40+
_mongodb._tcp.test17.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.not-cc.
41+
_mongodb._tcp.test18.test.build.10gen.cc. 86400 IN SRV 27017 localhost.sub.test.build.10gen.cc.
42+
_mongodb._tcp.test19.test.build.10gen.cc. 86400 IN SRV 27017 localhost.evil.build.10gen.cc.
43+
_mongodb._tcp.test19.test.build.10gen.cc. 86400 IN SRV 27017 localhost.test.build.10gen.cc.
44+
45+
Record TTL Class Text
46+
test5.test.build.10gen.cc. 86400 IN TXT "replicaSet=repl0&authSource=thisDB"
47+
test6.test.build.10gen.cc. 86400 IN TXT "replicaSet=repl0"
48+
test6.test.build.10gen.cc. 86400 IN TXT "authSource=otherDB"
49+
test7.test.build.10gen.cc. 86400 IN TXT "ssl=false"
50+
test8.test.build.10gen.cc. 86400 IN TXT "authSource"
51+
test10.test.build.10gen.cc. 86400 IN TXT "socketTimeoutMS=500"
52+
test11.test.build.10gen.cc. 86400 IN TXT "replicaS" "et=rep" "l0"
53+
54+
Note that ``test4`` is omitted deliberately to test what happens with no SRV
55+
record. ``test9`` is missing because it was deleted during the development of
56+
the tests. The missing ``test.`` sub-domain in the SRV record target for
57+
``test12`` is deliberate.
58+
59+
In our tests we have used ``localhost.test.build.10gen.cc`` as the domain, and
60+
then configured ``localhost.test.build.10gen.cc`` to resolve to 127.0.0.1.
61+
62+
You need to adapt the records shown above to replace ``test.build.10gen.cc``
63+
with your own domain name, and update the "uri" field in the YAML or JSON files
64+
in this directory with the actual domain.
65+
66+
Test Format and Use
67+
-------------------
68+
69+
These YAML and JSON files contain the following fields:
70+
71+
- ``uri``: a mongodb+srv connection string
72+
- ``seeds``: the expected set of initial seeds discovered from the SRV record
73+
- ``hosts``: the discovered topology's list of hosts once SDAM completes a scan
74+
- ``options``: the parsed connection string options as discovered from URI and
75+
TXT records
76+
- ``error``: indicates that the parsing of the URI, or the resolving or
77+
contents of the SRV or TXT records included errors.
78+
- ``comment``: a comment to indicate why a test would fail.
79+
80+
For each file, create MongoClient initialized with the mongodb+srv connection
81+
string. You SHOULD verify that the client's initial seed list matches the list of
82+
seeds. You MUST verify that the set of ServerDescriptions in the client's
83+
TopologyDescription eventually matches the list of hosts. You MUST verify that
84+
each of the values of the Connection String Options under ``options`` match the
85+
Client's parsed value for that option. There may be other options parsed by
86+
the Client as well, which a test does not verify. You MUST verify that an
87+
error has been thrown if ``error`` is present.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"uri": "mongodb+srv://test18.test.build.10gen.cc/?replicaSet=repl0",
3+
"seeds": [
4+
"localhost.sub.test.build.10gen.cc:27017"
5+
],
6+
"hosts": [
7+
"localhost:27017",
8+
"localhost:27018",
9+
"localhost:27019"
10+
],
11+
"options": {
12+
"replicaSet": "repl0",
13+
"ssl": true
14+
},
15+
"comment": "Is correct, as returned host name shared the URI root \"test.build.10gen.cc\"."
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
uri: "mongodb+srv://test18.test.build.10gen.cc/?replicaSet=repl0"
2+
seeds:
3+
- localhost.sub.test.build.10gen.cc:27017
4+
hosts:
5+
- localhost:27017
6+
- localhost:27018
7+
- localhost:27019
8+
options:
9+
replicaSet: repl0
10+
ssl: true
11+
comment: Is correct, as returned host name shared the URI root "test.build.10gen.cc".
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uri": "mongodb+srv://test8.test.build.10gen.cc/",
3+
"seeds": [],
4+
"hosts": [],
5+
"error": true,
6+
"comment": "Should fail because the options in the TXT record are incorrectly formatted (misses value)."
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
uri: "mongodb+srv://test8.test.build.10gen.cc/"
2+
seeds: []
3+
hosts: []
4+
error: true
5+
comment: Should fail because the options in the TXT record are incorrectly formatted (misses value).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uri": "mongodb+srv://test4.test.build.10gen.cc/",
3+
"seeds": [],
4+
"hosts": [],
5+
"error": true,
6+
"comment": "Should fail because no SRV records are present for this URI."
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
uri: "mongodb+srv://test4.test.build.10gen.cc/"
2+
seeds: []
3+
hosts: []
4+
error: true
5+
comment: Should fail because no SRV records are present for this URI.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uri": "mongodb+srv://10gen.cc/",
3+
"seeds": [],
4+
"hosts": [],
5+
"error": true,
6+
"comment": "Should fail because host in URI does not have {hostname}, {domainname} and {tld}."
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
uri: "mongodb+srv://10gen.cc/"
2+
seeds: []
3+
hosts: []
4+
error: true
5+
comment: Should fail because host in URI does not have {hostname}, {domainname} and {tld}.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"uri": "mongodb+srv://test3.test.build.10gen.cc/?replicaSet=repl0",
3+
"seeds": [
4+
"localhost.test.build.10gen.cc:27017"
5+
],
6+
"hosts": [
7+
"localhost:27017",
8+
"localhost:27018",
9+
"localhost:27019"
10+
],
11+
"options": {
12+
"replicaSet": "repl0",
13+
"ssl": true
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
uri: "mongodb+srv://test3.test.build.10gen.cc/?replicaSet=repl0"
2+
seeds:
3+
- localhost.test.build.10gen.cc:27017
4+
hosts:
5+
- localhost:27017
6+
- localhost:27018
7+
- localhost:27019
8+
options:
9+
replicaSet: repl0
10+
ssl: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"uri": "mongodb+srv://test11.test.build.10gen.cc/",
3+
"seeds": [
4+
"localhost.test.build.10gen.cc:27017"
5+
],
6+
"hosts": [
7+
"localhost:27017",
8+
"localhost:27018",
9+
"localhost:27019"
10+
],
11+
"options": {
12+
"replicaSet": "repl0",
13+
"ssl": true
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
uri: "mongodb+srv://test11.test.build.10gen.cc/"
2+
seeds:
3+
- localhost.test.build.10gen.cc:27017
4+
hosts:
5+
- localhost:27017
6+
- localhost:27018
7+
- localhost:27019
8+
options:
9+
replicaSet: repl0
10+
ssl: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"uri": "mongodb+srv://test5.test.build.10gen.cc/",
3+
"seeds": [
4+
"localhost.test.build.10gen.cc:27017"
5+
],
6+
"hosts": [
7+
"localhost:27017",
8+
"localhost:27018",
9+
"localhost:27019"
10+
],
11+
"options": {
12+
"replicaSet": "repl0",
13+
"authSource": "thisDB",
14+
"ssl": true
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
uri: "mongodb+srv://test5.test.build.10gen.cc/"
2+
seeds:
3+
- localhost.test.build.10gen.cc:27017
4+
hosts:
5+
- localhost:27017
6+
- localhost:27018
7+
- localhost:27019
8+
options:
9+
replicaSet: repl0
10+
authSource: thisDB
11+
ssl: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uri": "mongodb+srv://test14.test.build.10gen.cc/",
3+
"seeds": [],
4+
"hosts": [],
5+
"error": true,
6+
"comment": "Should fail because returned host name's part \"not-test\" mismatches URI parent part \"test\"."
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
uri: "mongodb+srv://test14.test.build.10gen.cc/"
2+
seeds: []
3+
hosts: []
4+
error: true
5+
comment: Should fail because returned host name's part "not-test" mismatches URI parent part "test".
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uri": "mongodb+srv://test15.test.build.10gen.cc/",
3+
"seeds": [],
4+
"hosts": [],
5+
"error": true,
6+
"comment": "Should fail because returned host name's part \"not-build\" mismatches URI parent part \"build\"."
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
uri: "mongodb+srv://test15.test.build.10gen.cc/"
2+
seeds: []
3+
hosts: []
4+
error: true
5+
comment: Should fail because returned host name's part "not-build" mismatches URI parent part "build".
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uri": "mongodb+srv://test16.test.build.10gen.cc/",
3+
"seeds": [],
4+
"hosts": [],
5+
"error": true,
6+
"comment": "Should fail because returned host name's part \"not-10gen\" mismatches URI parent part \"10gen\"."
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
uri: "mongodb+srv://test16.test.build.10gen.cc/"
2+
seeds: []
3+
hosts: []
4+
error: true
5+
comment: Should fail because returned host name's part "not-10gen" mismatches URI parent part "10gen".
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uri": "mongodb+srv://test17.test.build.10gen.cc/",
3+
"seeds": [],
4+
"hosts": [],
5+
"error": true,
6+
"comment": "Should fail because returned host name's TLD \"not-cc\" mismatches URI TLD \"cc\"."
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
uri: "mongodb+srv://test17.test.build.10gen.cc/"
2+
seeds: []
3+
hosts: []
4+
error: true
5+
comment: Should fail because returned host name's TLD "not-cc" mismatches URI TLD "cc".
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uri": "mongodb+srv://test19.test.build.10gen.cc/",
3+
"seeds": [],
4+
"hosts": [],
5+
"error": true,
6+
"comment": "Should fail because one of the returned host names' domain name parts \"evil\" mismatches \"test\"."
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
uri: "mongodb+srv://test19.test.build.10gen.cc/"
2+
seeds: []
3+
hosts: []
4+
error: true
5+
comment: Should fail because one of the returned host names' domain name parts "evil" mismatches "test".
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uri": "mongodb+srv://test13.test.build.10gen.cc/",
3+
"seeds": [],
4+
"hosts": [],
5+
"error": true,
6+
"comment": "Should fail because returned host name's parent (build.10gen.cc) misses \"test.\""
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
uri: "mongodb+srv://test13.test.build.10gen.cc/"
2+
seeds: []
3+
hosts: []
4+
error: true
5+
comment: Should fail because returned host name's parent (build.10gen.cc) misses "test."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uri": "mongodb+srv://test12.test.build.10gen.cc/",
3+
"seeds": [],
4+
"hosts": [],
5+
"error": true,
6+
"comment": "Should fail because returned host name is too short and mismatches a parent."
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
uri: "mongodb+srv://test12.test.build.10gen.cc/"
2+
seeds: []
3+
hosts: []
4+
error: true
5+
comment: Should fail because returned host name is too short and mismatches a parent.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"uri": "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0",
3+
"seeds": [
4+
"localhost.test.build.10gen.cc:27017",
5+
"localhost.test.build.10gen.cc:27018"
6+
],
7+
"hosts": [
8+
"localhost:27017",
9+
"localhost:27018",
10+
"localhost:27019"
11+
],
12+
"options": {
13+
"replicaSet": "repl0",
14+
"ssl": true
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
uri: "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0"
2+
seeds:
3+
- localhost.test.build.10gen.cc:27017
4+
- localhost.test.build.10gen.cc:27018
5+
hosts:
6+
- localhost:27017
7+
- localhost:27018
8+
- localhost:27019
9+
options:
10+
replicaSet: repl0
11+
ssl: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"uri": "mongodb+srv://test2.test.build.10gen.cc/?replicaSet=repl0",
3+
"seeds": [
4+
"localhost.test.build.10gen.cc:27018",
5+
"localhost.test.build.10gen.cc:27019"
6+
],
7+
"hosts": [
8+
"localhost:27017",
9+
"localhost:27018",
10+
"localhost:27019"
11+
],
12+
"options": {
13+
"replicaSet": "repl0",
14+
"ssl": true
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
uri: "mongodb+srv://test2.test.build.10gen.cc/?replicaSet=repl0"
2+
seeds:
3+
- localhost.test.build.10gen.cc:27018
4+
- localhost.test.build.10gen.cc:27019
5+
hosts:
6+
- localhost:27017
7+
- localhost:27018
8+
- localhost:27019
9+
options:
10+
replicaSet: repl0
11+
ssl: true

0 commit comments

Comments
 (0)