From 34c9195251adeeb1c9e8bc4234c8afb076d1d60e Mon Sep 17 00:00:00 2001 From: Thomas Reggi Date: Fri, 15 May 2020 11:57:58 -0400 Subject: [PATCH] feat: directConnection adds unify behavior for replica set discovery (#2349) Adds `directConnection` option to unify behavior around configuration for replica set discovery. Migrated mongodb/specifications tests from commit "e56f5eceed7729f8b9b43a4a1f76c7e5840db49f". Skips SDAM tests for legacy topology / behavior that we do not intend to introduce to the legacy topology types. Users should switch to the unified topology. NODE-2452 --- lib/connection_string.js | 24 ++++-- lib/mongo_client.js | 6 +- lib/operations/connect.js | 3 +- lib/sdam/server_selection.js | 4 + lib/sdam/topology.js | 25 ++++-- lib/sdam/topology_description.js | 18 ++++- .../direct-connection-false.json | 14 ++++ .../direct-connection-false.yml | 9 +++ .../direct-connection-true.json | 7 ++ .../direct-connection-true.yml | 5 ++ .../rs/compatible.yml | 2 + .../rs/compatible_unknown.yml | 2 + .../rs/discover_arbiters.json | 4 +- .../rs/discover_arbiters.yml | 4 +- .../rs/discover_arbiters_replicaset.json | 41 ++++++++++ .../rs/discover_arbiters_replicaset.yml | 43 ++++++++++ .../rs/discover_ghost.json | 31 +++++++ .../rs/discover_ghost.yml | 35 ++++++++ ...ed.json => discover_ghost_replicaset.json} | 2 +- ...ered.yml => discover_ghost_replicaset.yml} | 2 +- .../rs/discover_hidden.json | 45 +++++++++++ .../rs/discover_hidden.yml | 50 ++++++++++++ .../rs/discover_hidden_replicaset.json | 45 +++++++++++ .../rs/discover_hidden_replicaset.yml | 50 ++++++++++++ .../rs/discover_passives.json | 4 +- .../rs/discover_passives.yml | 4 +- .../rs/discover_passives_replicaset.json | 78 ++++++++++++++++++ .../rs/discover_passives_replicaset.yml | 81 +++++++++++++++++++ .../rs/discover_primary.json | 4 +- .../rs/discover_primary.yml | 4 +- .../rs/discover_primary_replicaset.json | 39 +++++++++ .../rs/discover_primary_replicaset.yml | 42 ++++++++++ .../rs/discover_rsother.json | 44 ++++++++++ .../rs/discover_rsother.yml | 49 +++++++++++ ....json => discover_rsother_replicaset.json} | 2 +- ...ed.yml => discover_rsother_replicaset.yml} | 2 +- .../rs/discover_secondary.json | 4 +- .../rs/discover_secondary.yml | 4 +- .../rs/discover_secondary_replicaset.json | 40 +++++++++ .../rs/discover_secondary_replicaset.yml | 43 ++++++++++ .../rs/incompatible_arbiter.yml | 2 + .../rs/incompatible_ghost.yml | 2 + .../rs/incompatible_other.yml | 2 + .../rs/replicaset_rsnp.json | 25 ++++++ .../rs/replicaset_rsnp.yml | 20 +++++ .../rs/secondary_mismatched_me.json | 4 +- .../rs/secondary_mismatched_me.yml | 5 +- .../rs/too_new.yml | 2 + .../sharded/discover_single_mongos.json | 30 +++++++ .../sharded/discover_single_mongos.yml | 23 ++++++ .../single/direct_connection_external_ip.json | 2 +- .../single/direct_connection_external_ip.yml | 2 +- .../single/direct_connection_mongos.json | 4 +- .../single/direct_connection_mongos.yml | 4 +- .../single/direct_connection_replicaset.json | 31 +++++++ .../single/direct_connection_replicaset.yml | 22 +++++ .../single/direct_connection_rsarbiter.json | 4 +- .../single/direct_connection_rsarbiter.yml | 4 +- .../single/direct_connection_rsprimary.json | 4 +- .../single/direct_connection_rsprimary.yml | 4 +- .../single/direct_connection_rssecondary.json | 4 +- .../single/direct_connection_rssecondary.yml | 4 +- .../single/direct_connection_slave.json | 2 +- .../single/direct_connection_slave.yml | 2 +- .../single/direct_connection_standalone.json | 4 +- .../single/direct_connection_standalone.yml | 4 +- ...> direct_connection_unavailable_seed.json} | 4 +- ...=> direct_connection_unavailable_seed.yml} | 4 +- .../direct_connection_wrong_set_name.json | 35 ++++++++ .../direct_connection_wrong_set_name.yml | 36 +++++++++ .../single/discover_standalone.json | 30 +++++++ .../single/discover_standalone.yml | 34 ++++++++ .../single/discover_unavailable_seed.json | 25 ++++++ .../single/discover_unavailable_seed.yml | 28 +++++++ test/spec/uri-options/concern-options.json | 9 --- test/spec/uri-options/connection-options.json | 50 ++++++++++++ test/spec/uri-options/connection-options.yml | 43 ++++++++++ test/unit/core/mongodb_srv.test.js | 19 ++--- test/unit/sdam/spec.test.js | 13 ++- 79 files changed, 1368 insertions(+), 93 deletions(-) create mode 100644 test/spec/initial-dns-seedlist-discovery/direct-connection-false.json create mode 100644 test/spec/initial-dns-seedlist-discovery/direct-connection-false.yml create mode 100644 test/spec/initial-dns-seedlist-discovery/direct-connection-true.json create mode 100644 test/spec/initial-dns-seedlist-discovery/direct-connection-true.yml create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_arbiters_replicaset.json create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_arbiters_replicaset.yml create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_ghost.json create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_ghost.yml rename test/spec/server-discovery-and-monitoring/rs/{ghost_discovered.json => discover_ghost_replicaset.json} (91%) rename test/spec/server-discovery-and-monitoring/rs/{ghost_discovered.yml => discover_ghost_replicaset.yml} (92%) create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_hidden.json create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_hidden.yml create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_hidden_replicaset.json create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_hidden_replicaset.yml create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_passives_replicaset.json create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_passives_replicaset.yml create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_primary_replicaset.json create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_primary_replicaset.yml create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_rsother.json create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_rsother.yml rename test/spec/server-discovery-and-monitoring/rs/{rsother_discovered.json => discover_rsother_replicaset.json} (95%) rename test/spec/server-discovery-and-monitoring/rs/{rsother_discovered.yml => discover_rsother_replicaset.yml} (96%) create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_secondary_replicaset.json create mode 100644 test/spec/server-discovery-and-monitoring/rs/discover_secondary_replicaset.yml create mode 100644 test/spec/server-discovery-and-monitoring/rs/replicaset_rsnp.json create mode 100644 test/spec/server-discovery-and-monitoring/rs/replicaset_rsnp.yml create mode 100644 test/spec/server-discovery-and-monitoring/sharded/discover_single_mongos.json create mode 100644 test/spec/server-discovery-and-monitoring/sharded/discover_single_mongos.yml create mode 100644 test/spec/server-discovery-and-monitoring/single/direct_connection_replicaset.json create mode 100644 test/spec/server-discovery-and-monitoring/single/direct_connection_replicaset.yml rename test/spec/server-discovery-and-monitoring/single/{unavailable_seed.json => direct_connection_unavailable_seed.json} (78%) rename test/spec/server-discovery-and-monitoring/single/{unavailable_seed.yml => direct_connection_unavailable_seed.yml} (80%) create mode 100644 test/spec/server-discovery-and-monitoring/single/direct_connection_wrong_set_name.json create mode 100644 test/spec/server-discovery-and-monitoring/single/direct_connection_wrong_set_name.yml create mode 100644 test/spec/server-discovery-and-monitoring/single/discover_standalone.json create mode 100644 test/spec/server-discovery-and-monitoring/single/discover_standalone.yml create mode 100644 test/spec/server-discovery-and-monitoring/single/discover_unavailable_seed.json create mode 100644 test/spec/server-discovery-and-monitoring/single/discover_unavailable_seed.yml diff --git a/lib/connection_string.js b/lib/connection_string.js index ceda32d6e5..01789218aa 100644 --- a/lib/connection_string.js +++ b/lib/connection_string.js @@ -37,6 +37,10 @@ function matchesParentDomain(srvAddress, parentDomain) { function parseSrvConnectionString(uri, options, callback) { const result = URL.parse(uri, true); + if (options.directConnection) { + return callback(new MongoParseError('directConnection not supported with SRV URI')); + } + if (result.hostname.split('.').length < 3) { return callback(new MongoParseError('URI does not have hostname, domain name and tld')); } @@ -217,7 +221,8 @@ const CASE_TRANSLATION = { tlscertificatekeyfile: 'tlsCertificateKeyFile', tlscertificatekeyfilepassword: 'tlsCertificateKeyFilePassword', wtimeout: 'wTimeoutMS', - j: 'journal' + j: 'journal', + directconnection: 'directConnection' }; /** @@ -594,10 +599,6 @@ function parseConnectionString(uri, options, callback) { return callback(new MongoParseError('Invalid protocol provided')); } - if (protocol === PROTOCOL_MONGODB_SRV) { - return parseSrvConnectionString(uri, options, callback); - } - const dbAndQuery = cap[4].split('?'); const db = dbAndQuery.length > 0 ? dbAndQuery[0] : null; const query = dbAndQuery.length > 1 ? dbAndQuery[1] : null; @@ -613,6 +614,12 @@ function parseConnectionString(uri, options, callback) { return callback(parseError); } + parsedOptions = Object.assign({}, parsedOptions, options); + + if (protocol === PROTOCOL_MONGODB_SRV) { + return parseSrvConnectionString(uri, parsedOptions, callback); + } + const auth = { username: null, password: null, db: db && db !== '' ? qs.unescape(db) : null }; if (parsedOptions.auth) { // maintain support for legacy options passed into `MongoClient` @@ -706,6 +713,13 @@ function parseConnectionString(uri, options, callback) { return callback(new MongoParseError('No hostname or hostnames provided in connection string')); } + const directConnection = !!parsedOptions.directConnection; + if (directConnection && hosts.length !== 1) { + // If the option is set to true, the driver MUST validate that there is exactly one host given + // in the host list in the URI, and fail client creation otherwise. + return callback(new MongoParseError('directConnection option requires exactly one host')); + } + const result = { hosts: hosts, auth: auth.db || auth.username ? auth : null, diff --git a/lib/mongo_client.js b/lib/mongo_client.js index 9c389844d4..609fa0561b 100644 --- a/lib/mongo_client.js +++ b/lib/mongo_client.js @@ -103,7 +103,7 @@ const PromiseProvider = require('./promise_provider'); * @param {number} [options.reconnectInterval=1000] Server will wait # milliseconds between retries * @param {boolean} [options.ha=true] Control if high availability monitoring runs for Replicaset or Mongos proxies * @param {number} [options.haInterval=10000] The High availability period for replicaset inquiry - * @param {string} [options.replicaSet=undefined] The Replicaset set name + * @param {string} [options.replicaSet] The name of the replica set to connect to * @param {number} [options.secondaryAcceptableLatencyMS=15] Cutoff latency point in MS for Replicaset member selection * @param {number} [options.acceptableLatencyMS=15] Cutoff latency point in MS for Mongos proxies selection * @param {boolean} [options.connectWithNoPrimary=false] Sets if the driver should connect even if no primary is available @@ -143,6 +143,7 @@ const PromiseProvider = require('./promise_provider'); * @param {number} [options.minSize] If present, the connection pool will be initialized with minSize connections, and will never dip below minSize connections * @param {boolean} [options.useNewUrlParser=true] Determines whether or not to use the new url parser. Enables the new, spec-compliant, url parser shipped in the core driver. This url parser fixes a number of problems with the original parser, and aims to outright replace that parser in the near future. Defaults to true, and must be explicitly set to false to use the legacy url parser. * @param {DriverInfoOptions} [options.driverInfo] Allows a wrapping driver to amend the client metadata generated by the driver to include information about the wrapping driver + * @param {boolean} [options.directConnection=false] Whether to connect to the deployment in Single topology. * @param {AutoEncrypter~AutoEncryptionOptions} [options.autoEncryption] Optionally enable client side auto encryption * @returns {MongoClient} a MongoClient instance */ @@ -353,7 +354,7 @@ MongoClient.prototype.isConnected = function(options) { * @param {number} [options.reconnectInterval=1000] Server will wait # milliseconds between retries * @param {boolean} [options.ha=true] Control if high availability monitoring runs for Replicaset or Mongos proxies * @param {number} [options.haInterval=10000] The High availability period for replicaset inquiry - * @param {string} [options.replicaSet=undefined] The Replicaset set name + * @param {string} [options.replicaSet] The name of the replica set to connect to * @param {number} [options.secondaryAcceptableLatencyMS=15] Cutoff latency point in MS for Replicaset member selection * @param {number} [options.acceptableLatencyMS=15] Cutoff latency point in MS for Mongos proxies selection * @param {boolean} [options.connectWithNoPrimary=false] Sets if the driver should connect even if no primary is available @@ -389,6 +390,7 @@ MongoClient.prototype.isConnected = function(options) { * @param {number} [options.numberOfRetries=5] The number of retries for a tailable cursor * @param {boolean} [options.auto_reconnect=true] Enable auto reconnecting for single server instances * @param {number} [options.minSize] If present, the connection pool will be initialized with minSize connections, and will never dip below minSize connections + * @param {boolean} [options.directConnection=false] Whether to connect to the deployment in Single topology. * @param {MongoClient~connectCallback} [callback] The command result callback * @returns {Promise} returns Promise if no callback passed */ diff --git a/lib/operations/connect.js b/lib/operations/connect.js index a16bc8ab63..2612d74728 100644 --- a/lib/operations/connect.js +++ b/lib/operations/connect.js @@ -112,7 +112,8 @@ const validOptionNames = [ 'tlsCertificateKeyFilePassword', 'minHeartbeatFrequencyMS', 'heartbeatFrequencyMS', - 'waitQueueTimeoutMS' + 'waitQueueTimeoutMS', + 'directConnection' ]; const ignoreOptionNames = ['native_parser']; diff --git a/lib/sdam/server_selection.js b/lib/sdam/server_selection.js index 071d4cc20a..6286ab5d3a 100644 --- a/lib/sdam/server_selection.js +++ b/lib/sdam/server_selection.js @@ -185,6 +185,10 @@ function readPreferenceServerSelector(readPreference) { ); } + if (topologyDescription.type === TopologyType.Unknown) { + return []; + } + if ( topologyDescription.type === TopologyType.Single || topologyDescription.type === TopologyType.Sharded diff --git a/lib/sdam/topology.js b/lib/sdam/topology.js index 119c7a4556..9829a00800 100644 --- a/lib/sdam/topology.js +++ b/lib/sdam/topology.js @@ -102,6 +102,8 @@ class Topology extends EventEmitter { * @param {number} [options.localThresholdMS=15] The size of the latency window for selecting among multiple suitable servers * @param {number} [options.serverSelectionTimeoutMS=30000] How long to block for server selection before throwing an error * @param {number} [options.heartbeatFrequencyMS=10000] The frequency with which topology updates are scheduled + * @param {boolean} [options.directConnection] Indicates that a client should directly connect to a node without attempting to discover its topology type + * @param {string} [options.replicaSet] The name of the replica set to connect to */ constructor(seedlist, options) { super(); @@ -140,7 +142,7 @@ class Topology extends EventEmitter { } }); - const topologyType = topologyTypeFromSeedlist(seedlist, options); + const topologyType = topologyTypeFromOptions(options); const topologyId = globalTopologyCounter++; const serverDescriptions = seedlist.reduce((result, seed) => { if (seed.domain_socket) seed.host = seed.domain_socket; @@ -799,10 +801,23 @@ function parseStringSeedlist(seedlist) { })); } -function topologyTypeFromSeedlist(seedlist, options) { - const replicaSet = options.replicaSet || options.setName || options.rs_name; - if (seedlist.length === 1 && !replicaSet) return TopologyType.Single; - if (replicaSet) return TopologyType.ReplicaSetNoPrimary; +/** + * Gets the TopologyType from the client options + * + * @param {object} options mongo client options + * @param {boolean} [options.directConnection] Indicates that a client should directly connect to a node without attempting to discover its topology type + * @param {string} [options.replicaSet] The name of the replica set to connect to + * @returns TopologyType + */ +function topologyTypeFromOptions(options) { + if (options.directConnection) { + return TopologyType.Single; + } + + if (options.replicaSet) { + return TopologyType.ReplicaSetNoPrimary; + } + return TopologyType.Unknown; } diff --git a/lib/sdam/topology_description.js b/lib/sdam/topology_description.js index e802469e8d..fc4b489e47 100644 --- a/lib/sdam/topology_description.js +++ b/lib/sdam/topology_description.js @@ -163,7 +163,7 @@ class TopologyDescription { } if (topologyType === TopologyType.Unknown) { - if (serverType === ServerType.Standalone) { + if (serverType === ServerType.Standalone && this.servers.size !== 1) { serverDescriptions.delete(address); } else { topologyType = topologyTypeForServerType(serverType); @@ -277,9 +277,19 @@ class TopologyDescription { } function topologyTypeForServerType(serverType) { - if (serverType === ServerType.Mongos) return TopologyType.Sharded; - if (serverType === ServerType.RSPrimary) return TopologyType.ReplicaSetWithPrimary; - return TopologyType.ReplicaSetNoPrimary; + switch (serverType) { + case ServerType.Standalone: + return TopologyType.Single; + case ServerType.Mongos: + return TopologyType.Sharded; + case ServerType.RSPrimary: + return TopologyType.ReplicaSetWithPrimary; + case ServerType.RSOther: + case ServerType.RSSecondary: + return TopologyType.ReplicaSetNoPrimary; + default: + return TopologyType.Unknown; + } } function compareObjectId(oid1, oid2) { diff --git a/test/spec/initial-dns-seedlist-discovery/direct-connection-false.json b/test/spec/initial-dns-seedlist-discovery/direct-connection-false.json new file mode 100644 index 0000000000..01560d5acc --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/direct-connection-false.json @@ -0,0 +1,14 @@ +{ + "uri": "mongodb+srv://test3.test.build.10gen.cc/?directConnection=false", + "seeds": [ + "localhost.test.build.10gen.cc:27017" + ], + "hosts": [ + "localhost:27017", + "localhost:27018", + "localhost:27019" + ], + "options": { + "ssl": true + } +} diff --git a/test/spec/initial-dns-seedlist-discovery/direct-connection-false.yml b/test/spec/initial-dns-seedlist-discovery/direct-connection-false.yml new file mode 100644 index 0000000000..6bc97e075f --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/direct-connection-false.yml @@ -0,0 +1,9 @@ +uri: "mongodb+srv://test3.test.build.10gen.cc/?directConnection=false" +seeds: + - localhost.test.build.10gen.cc:27017 +hosts: + - localhost:27017 + - localhost:27018 + - localhost:27019 +options: + ssl: true diff --git a/test/spec/initial-dns-seedlist-discovery/direct-connection-true.json b/test/spec/initial-dns-seedlist-discovery/direct-connection-true.json new file mode 100644 index 0000000000..ace6700106 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/direct-connection-true.json @@ -0,0 +1,7 @@ +{ + "uri": "mongodb+srv://test3.test.build.10gen.cc/?directConnection=true", + "seeds": [], + "hosts": [], + "error": true, + "comment": "Should fail because directConnection=true is incompatible with SRV URIs." +} diff --git a/test/spec/initial-dns-seedlist-discovery/direct-connection-true.yml b/test/spec/initial-dns-seedlist-discovery/direct-connection-true.yml new file mode 100644 index 0000000000..923e4e6753 --- /dev/null +++ b/test/spec/initial-dns-seedlist-discovery/direct-connection-true.yml @@ -0,0 +1,5 @@ +uri: "mongodb+srv://test3.test.build.10gen.cc/?directConnection=true" +seeds: [] +hosts: [] +error: true +comment: Should fail because directConnection=true is incompatible with SRV URIs. diff --git a/test/spec/server-discovery-and-monitoring/rs/compatible.yml b/test/spec/server-discovery-and-monitoring/rs/compatible.yml index 3e041d6030..6fade62db9 100644 --- a/test/spec/server-discovery-and-monitoring/rs/compatible.yml +++ b/test/spec/server-discovery-and-monitoring/rs/compatible.yml @@ -1,5 +1,7 @@ description: "Replica set member with large maxWireVersion" + uri: "mongodb://a,b/?replicaSet=rs" + phases: [ { responses: [ diff --git a/test/spec/server-discovery-and-monitoring/rs/compatible_unknown.yml b/test/spec/server-discovery-and-monitoring/rs/compatible_unknown.yml index c1cb73aceb..b36b69dd4a 100644 --- a/test/spec/server-discovery-and-monitoring/rs/compatible_unknown.yml +++ b/test/spec/server-discovery-and-monitoring/rs/compatible_unknown.yml @@ -1,5 +1,7 @@ description: "Replica set member and an unknown server" + uri: "mongodb://a,b/?replicaSet=rs" + phases: [ { responses: [ diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_arbiters.json b/test/spec/server-discovery-and-monitoring/rs/discover_arbiters.json index ced7baeb65..ad337c127a 100644 --- a/test/spec/server-discovery-and-monitoring/rs/discover_arbiters.json +++ b/test/spec/server-discovery-and-monitoring/rs/discover_arbiters.json @@ -1,6 +1,6 @@ { - "description": "Discover arbiters", - "uri": "mongodb://a/?replicaSet=rs", + "description": "Discover arbiters with directConnection URI option", + "uri": "mongodb://a/?directConnection=false", "phases": [ { "responses": [ diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_arbiters.yml b/test/spec/server-discovery-and-monitoring/rs/discover_arbiters.yml index 831f9da0ed..15cd0308d5 100644 --- a/test/spec/server-discovery-and-monitoring/rs/discover_arbiters.yml +++ b/test/spec/server-discovery-and-monitoring/rs/discover_arbiters.yml @@ -1,6 +1,6 @@ -description: "Discover arbiters" +description: "Discover arbiters with directConnection URI option" -uri: "mongodb://a/?replicaSet=rs" +uri: "mongodb://a/?directConnection=false" phases: [ diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_arbiters_replicaset.json b/test/spec/server-discovery-and-monitoring/rs/discover_arbiters_replicaset.json new file mode 100644 index 0000000000..dc00dca5f0 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_arbiters_replicaset.json @@ -0,0 +1,41 @@ +{ + "description": "Discover arbiters with replicaSet URI option", + "uri": "mongodb://a/?replicaSet=rs", + "phases": [ + { + "responses": [ + [ + "a:27017", + { + "ok": 1, + "ismaster": true, + "hosts": [ + "a:27017" + ], + "arbiters": [ + "b:27017" + ], + "setName": "rs", + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": { + "a:27017": { + "type": "RSPrimary", + "setName": "rs" + }, + "b:27017": { + "type": "Unknown", + "setName": null + } + }, + "topologyType": "ReplicaSetWithPrimary", + "logicalSessionTimeoutMinutes": null, + "setName": "rs" + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_arbiters_replicaset.yml b/test/spec/server-discovery-and-monitoring/rs/discover_arbiters_replicaset.yml new file mode 100644 index 0000000000..c9255aa3ef --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_arbiters_replicaset.yml @@ -0,0 +1,43 @@ +description: "Discover arbiters with replicaSet URI option" + +uri: "mongodb://a/?replicaSet=rs" + +phases: [ + + { + responses: [ + + ["a:27017", { + + ok: 1, + ismaster: true, + hosts: ["a:27017"], + arbiters: ["b:27017"], + setName: "rs", + minWireVersion: 0, + maxWireVersion: 6 + }] + ], + + outcome: { + + servers: { + + "a:27017": { + + type: "RSPrimary", + setName: "rs" + }, + + "b:27017": { + + type: "Unknown", + setName: + } + }, + topologyType: "ReplicaSetWithPrimary", + logicalSessionTimeoutMinutes: null, + setName: "rs" + } + } +] diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_ghost.json b/test/spec/server-discovery-and-monitoring/rs/discover_ghost.json new file mode 100644 index 0000000000..1e2ca91bcb --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_ghost.json @@ -0,0 +1,31 @@ +{ + "description": "Discover ghost with directConnection URI option", + "uri": "mongodb://b/?directConnection=false", + "phases": [ + { + "responses": [ + [ + "b:27017", + { + "ok": 1, + "ismaster": false, + "isreplicaset": true, + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": { + "b:27017": { + "type": "RSGhost", + "setName": null + } + }, + "topologyType": "Unknown", + "logicalSessionTimeoutMinutes": null, + "setName": null + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_ghost.yml b/test/spec/server-discovery-and-monitoring/rs/discover_ghost.yml new file mode 100644 index 0000000000..9b2ddd6a85 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_ghost.yml @@ -0,0 +1,35 @@ +description: "Discover ghost with directConnection URI option" + +uri: "mongodb://b/?directConnection=false" + +phases: [ + + { + responses: [ + + ["b:27017", { + + ok: 1, + ismaster: false, + isreplicaset: true, + minWireVersion: 0, + maxWireVersion: 6 + }] + ], + + outcome: { + + servers: { + + "b:27017": { + + type: "RSGhost", + setName: + } + }, + topologyType: "Unknown", + logicalSessionTimeoutMinutes: null, + setName: + } + } +] diff --git a/test/spec/server-discovery-and-monitoring/rs/ghost_discovered.json b/test/spec/server-discovery-and-monitoring/rs/discover_ghost_replicaset.json similarity index 91% rename from test/spec/server-discovery-and-monitoring/rs/ghost_discovered.json rename to test/spec/server-discovery-and-monitoring/rs/discover_ghost_replicaset.json index bf22cbb0eb..df504b6ca4 100644 --- a/test/spec/server-discovery-and-monitoring/rs/ghost_discovered.json +++ b/test/spec/server-discovery-and-monitoring/rs/discover_ghost_replicaset.json @@ -1,5 +1,5 @@ { - "description": "Ghost discovered", + "description": "Discover ghost with replicaSet URI option", "uri": "mongodb://a,b/?replicaSet=rs", "phases": [ { diff --git a/test/spec/server-discovery-and-monitoring/rs/ghost_discovered.yml b/test/spec/server-discovery-and-monitoring/rs/discover_ghost_replicaset.yml similarity index 92% rename from test/spec/server-discovery-and-monitoring/rs/ghost_discovered.yml rename to test/spec/server-discovery-and-monitoring/rs/discover_ghost_replicaset.yml index 97cc92b9ed..638301e63e 100644 --- a/test/spec/server-discovery-and-monitoring/rs/ghost_discovered.yml +++ b/test/spec/server-discovery-and-monitoring/rs/discover_ghost_replicaset.yml @@ -1,4 +1,4 @@ -description: "Ghost discovered" +description: "Discover ghost with replicaSet URI option" uri: "mongodb://a,b/?replicaSet=rs" diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_hidden.json b/test/spec/server-discovery-and-monitoring/rs/discover_hidden.json new file mode 100644 index 0000000000..cb68120eaf --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_hidden.json @@ -0,0 +1,45 @@ +{ + "description": "Discover hidden with directConnection URI option", + "uri": "mongodb://a/?directConnection=false", + "phases": [ + { + "responses": [ + [ + "a:27017", + { + "ok": 1, + "ismaster": false, + "secondary": true, + "hidden": true, + "hosts": [ + "c:27017", + "d:27017" + ], + "setName": "rs", + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": { + "a:27017": { + "type": "RSOther", + "setName": "rs" + }, + "c:27017": { + "type": "Unknown", + "setName": null + }, + "d:27017": { + "type": "Unknown", + "setName": null + } + }, + "topologyType": "ReplicaSetNoPrimary", + "logicalSessionTimeoutMinutes": null, + "setName": "rs" + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_hidden.yml b/test/spec/server-discovery-and-monitoring/rs/discover_hidden.yml new file mode 100644 index 0000000000..a54069c338 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_hidden.yml @@ -0,0 +1,50 @@ +description: "Discover hidden with directConnection URI option" + +uri: "mongodb://a/?directConnection=false" + +phases: [ + + { + responses: [ + + ["a:27017", { + + ok: 1, + ismaster: false, + secondary: true, + hidden: true, + hosts: ["c:27017", "d:27017"], + setName: "rs", + minWireVersion: 0, + maxWireVersion: 6 + }], + ], + + outcome: { + + servers: { + + "a:27017": { + + type: "RSOther", + setName: "rs" + }, + + "c:27017": { + + type: "Unknown", + setName: + }, + + "d:27017": { + + type: "Unknown", + setName: + } + }, + topologyType: "ReplicaSetNoPrimary", + logicalSessionTimeoutMinutes: null, + setName: "rs" + } + } +] diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_hidden_replicaset.json b/test/spec/server-discovery-and-monitoring/rs/discover_hidden_replicaset.json new file mode 100644 index 0000000000..216328dfa5 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_hidden_replicaset.json @@ -0,0 +1,45 @@ +{ + "description": "Discover hidden with replicaSet URI option", + "uri": "mongodb://a/?replicaSet=rs", + "phases": [ + { + "responses": [ + [ + "a:27017", + { + "ok": 1, + "ismaster": false, + "secondary": true, + "hidden": true, + "hosts": [ + "c:27017", + "d:27017" + ], + "setName": "rs", + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": { + "a:27017": { + "type": "RSOther", + "setName": "rs" + }, + "c:27017": { + "type": "Unknown", + "setName": null + }, + "d:27017": { + "type": "Unknown", + "setName": null + } + }, + "topologyType": "ReplicaSetNoPrimary", + "logicalSessionTimeoutMinutes": null, + "setName": "rs" + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_hidden_replicaset.yml b/test/spec/server-discovery-and-monitoring/rs/discover_hidden_replicaset.yml new file mode 100644 index 0000000000..1b6f41b01f --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_hidden_replicaset.yml @@ -0,0 +1,50 @@ +description: "Discover hidden with replicaSet URI option" + +uri: "mongodb://a/?replicaSet=rs" + +phases: [ + + { + responses: [ + + ["a:27017", { + + ok: 1, + ismaster: false, + secondary: true, + hidden: true, + hosts: ["c:27017", "d:27017"], + setName: "rs", + minWireVersion: 0, + maxWireVersion: 6 + }], + ], + + outcome: { + + servers: { + + "a:27017": { + + type: "RSOther", + setName: "rs" + }, + + "c:27017": { + + type: "Unknown", + setName: + }, + + "d:27017": { + + type: "Unknown", + setName: + } + }, + topologyType: "ReplicaSetNoPrimary", + logicalSessionTimeoutMinutes: null, + setName: "rs" + } + } +] diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_passives.json b/test/spec/server-discovery-and-monitoring/rs/discover_passives.json index e46249d668..05922dc51c 100644 --- a/test/spec/server-discovery-and-monitoring/rs/discover_passives.json +++ b/test/spec/server-discovery-and-monitoring/rs/discover_passives.json @@ -1,6 +1,6 @@ { - "description": "Discover passives", - "uri": "mongodb://a/?replicaSet=rs", + "description": "Discover passives with directConnection URI option", + "uri": "mongodb://a/?directConnection=false", "phases": [ { "responses": [ diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_passives.yml b/test/spec/server-discovery-and-monitoring/rs/discover_passives.yml index 14ca42e454..3baed64aa0 100644 --- a/test/spec/server-discovery-and-monitoring/rs/discover_passives.yml +++ b/test/spec/server-discovery-and-monitoring/rs/discover_passives.yml @@ -1,6 +1,6 @@ -description: "Discover passives" +description: "Discover passives with directConnection URI option" -uri: "mongodb://a/?replicaSet=rs" +uri: "mongodb://a/?directConnection=false" phases: [ diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_passives_replicaset.json b/test/spec/server-discovery-and-monitoring/rs/discover_passives_replicaset.json new file mode 100644 index 0000000000..f9d8c2e032 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_passives_replicaset.json @@ -0,0 +1,78 @@ +{ + "description": "Discover passives with replicaSet URI option", + "uri": "mongodb://a/?replicaSet=rs", + "phases": [ + { + "responses": [ + [ + "a:27017", + { + "ok": 1, + "ismaster": true, + "hosts": [ + "a:27017" + ], + "passives": [ + "b:27017" + ], + "setName": "rs", + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": { + "a:27017": { + "type": "RSPrimary", + "setName": "rs" + }, + "b:27017": { + "type": "Unknown", + "setName": null + } + }, + "topologyType": "ReplicaSetWithPrimary", + "logicalSessionTimeoutMinutes": null, + "setName": "rs" + } + }, + { + "responses": [ + [ + "b:27017", + { + "ok": 1, + "ismaster": false, + "secondary": true, + "passive": true, + "hosts": [ + "a:27017" + ], + "passives": [ + "b:27017" + ], + "setName": "rs", + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": { + "a:27017": { + "type": "RSPrimary", + "setName": "rs" + }, + "b:27017": { + "type": "RSSecondary", + "setName": "rs" + } + }, + "topologyType": "ReplicaSetWithPrimary", + "logicalSessionTimeoutMinutes": null, + "setName": "rs" + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_passives_replicaset.yml b/test/spec/server-discovery-and-monitoring/rs/discover_passives_replicaset.yml new file mode 100644 index 0000000000..6d34516afc --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_passives_replicaset.yml @@ -0,0 +1,81 @@ +description: "Discover passives with replicaSet URI option" + +uri: "mongodb://a/?replicaSet=rs" + +phases: [ + + { + responses: [ + + ["a:27017", { + + ok: 1, + ismaster: true, + hosts: ["a:27017"], + passives: ["b:27017"], + setName: "rs", + minWireVersion: 0, + maxWireVersion: 6 + }] + ], + + outcome: { + + servers: { + + "a:27017": { + + type: "RSPrimary", + setName: "rs" + }, + + "b:27017": { + + type: "Unknown", + setName: + } + }, + topologyType: "ReplicaSetWithPrimary", + logicalSessionTimeoutMinutes: null, + setName: "rs" + } + }, + { + responses: [ + + ["b:27017", { + + ok: 1, + ismaster: false, + secondary: true, + passive: true, + hosts: ["a:27017"], + passives: ["b:27017"], + setName: "rs", + minWireVersion: 0, + maxWireVersion: 6 + }] + ], + + outcome: { + + servers: { + + "a:27017": { + + type: "RSPrimary", + setName: "rs" + }, + + "b:27017": { + + type: "RSSecondary", + setName: "rs" + } + }, + topologyType: "ReplicaSetWithPrimary", + logicalSessionTimeoutMinutes: null, + setName: "rs" + } + } +] diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_primary.json b/test/spec/server-discovery-and-monitoring/rs/discover_primary.json index ea2cce9b72..b9032144d4 100644 --- a/test/spec/server-discovery-and-monitoring/rs/discover_primary.json +++ b/test/spec/server-discovery-and-monitoring/rs/discover_primary.json @@ -1,6 +1,6 @@ { - "description": "Replica set discovery from primary", - "uri": "mongodb://a/?replicaSet=rs", + "description": "Discover primary with directConnection URI option", + "uri": "mongodb://a/?directConnection=false", "phases": [ { "responses": [ diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_primary.yml b/test/spec/server-discovery-and-monitoring/rs/discover_primary.yml index 8eb078d958..505acfb86f 100644 --- a/test/spec/server-discovery-and-monitoring/rs/discover_primary.yml +++ b/test/spec/server-discovery-and-monitoring/rs/discover_primary.yml @@ -1,6 +1,6 @@ -description: "Replica set discovery from primary" +description: "Discover primary with directConnection URI option" -uri: "mongodb://a/?replicaSet=rs" +uri: "mongodb://a/?directConnection=false" phases: [ diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_primary_replicaset.json b/test/spec/server-discovery-and-monitoring/rs/discover_primary_replicaset.json new file mode 100644 index 0000000000..6f639b1c7e --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_primary_replicaset.json @@ -0,0 +1,39 @@ +{ + "description": "Discover primary with replicaSet URI option", + "uri": "mongodb://a/?replicaSet=rs", + "phases": [ + { + "responses": [ + [ + "a:27017", + { + "ok": 1, + "ismaster": true, + "setName": "rs", + "hosts": [ + "a:27017", + "b:27017" + ], + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": { + "a:27017": { + "type": "RSPrimary", + "setName": "rs" + }, + "b:27017": { + "type": "Unknown", + "setName": null + } + }, + "topologyType": "ReplicaSetWithPrimary", + "logicalSessionTimeoutMinutes": null, + "setName": "rs" + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_primary_replicaset.yml b/test/spec/server-discovery-and-monitoring/rs/discover_primary_replicaset.yml new file mode 100644 index 0000000000..330ed20b51 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_primary_replicaset.yml @@ -0,0 +1,42 @@ +description: "Discover primary with replicaSet URI option" + +uri: "mongodb://a/?replicaSet=rs" + +phases: [ + + { + responses: [ + + ["a:27017", { + + ok: 1, + ismaster: true, + setName: "rs", + hosts: ["a:27017", "b:27017"], + minWireVersion: 0, + maxWireVersion: 6 + }] + ], + + outcome: { + + servers: { + + "a:27017": { + + type: "RSPrimary", + setName: "rs" + }, + + "b:27017": { + + type: "Unknown", + setName: + } + }, + topologyType: "ReplicaSetWithPrimary", + logicalSessionTimeoutMinutes: null, + setName: "rs" + } + } +] diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_rsother.json b/test/spec/server-discovery-and-monitoring/rs/discover_rsother.json new file mode 100644 index 0000000000..2cf5a5a6db --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_rsother.json @@ -0,0 +1,44 @@ +{ + "description": "Discover RSOther with directConnection URI option", + "uri": "mongodb://b/?directConnection=false", + "phases": [ + { + "responses": [ + [ + "b:27017", + { + "ok": 1, + "ismaster": false, + "secondary": false, + "hosts": [ + "c:27017", + "d:27017" + ], + "setName": "rs", + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": { + "b:27017": { + "type": "RSOther", + "setName": "rs" + }, + "c:27017": { + "type": "Unknown", + "setName": null + }, + "d:27017": { + "type": "Unknown", + "setName": null + } + }, + "topologyType": "ReplicaSetNoPrimary", + "logicalSessionTimeoutMinutes": null, + "setName": "rs" + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_rsother.yml b/test/spec/server-discovery-and-monitoring/rs/discover_rsother.yml new file mode 100644 index 0000000000..1f06c78566 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_rsother.yml @@ -0,0 +1,49 @@ +description: "Discover RSOther with directConnection URI option" + +uri: "mongodb://b/?directConnection=false" + +phases: [ + + { + responses: [ + + ["b:27017", { + + ok: 1, + ismaster: false, + secondary: false, + hosts: ["c:27017", "d:27017"], + setName: "rs", + minWireVersion: 0, + maxWireVersion: 6 + }] + ], + + outcome: { + + servers: { + + "b:27017": { + + type: "RSOther", + setName: "rs" + }, + + "c:27017": { + + type: "Unknown", + setName: + }, + + "d:27017": { + + type: "Unknown", + setName: + } + }, + topologyType: "ReplicaSetNoPrimary", + logicalSessionTimeoutMinutes: null, + setName: "rs" + } + } +] diff --git a/test/spec/server-discovery-and-monitoring/rs/rsother_discovered.json b/test/spec/server-discovery-and-monitoring/rs/discover_rsother_replicaset.json similarity index 95% rename from test/spec/server-discovery-and-monitoring/rs/rsother_discovered.json rename to test/spec/server-discovery-and-monitoring/rs/discover_rsother_replicaset.json index c575501d80..d9420ca529 100644 --- a/test/spec/server-discovery-and-monitoring/rs/rsother_discovered.json +++ b/test/spec/server-discovery-and-monitoring/rs/discover_rsother_replicaset.json @@ -1,5 +1,5 @@ { - "description": "RSOther discovered", + "description": "Discover RSOther with replicaSet URI option", "uri": "mongodb://a,b/?replicaSet=rs", "phases": [ { diff --git a/test/spec/server-discovery-and-monitoring/rs/rsother_discovered.yml b/test/spec/server-discovery-and-monitoring/rs/discover_rsother_replicaset.yml similarity index 96% rename from test/spec/server-discovery-and-monitoring/rs/rsother_discovered.yml rename to test/spec/server-discovery-and-monitoring/rs/discover_rsother_replicaset.yml index b84cd00986..24f4e302be 100644 --- a/test/spec/server-discovery-and-monitoring/rs/rsother_discovered.yml +++ b/test/spec/server-discovery-and-monitoring/rs/discover_rsother_replicaset.yml @@ -1,4 +1,4 @@ -description: "RSOther discovered" +description: "Discover RSOther with replicaSet URI option" uri: "mongodb://a,b/?replicaSet=rs" diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_secondary.json b/test/spec/server-discovery-and-monitoring/rs/discover_secondary.json index 7210b3845c..02123625a7 100644 --- a/test/spec/server-discovery-and-monitoring/rs/discover_secondary.json +++ b/test/spec/server-discovery-and-monitoring/rs/discover_secondary.json @@ -1,6 +1,6 @@ { - "description": "Replica set discovery from secondary", - "uri": "mongodb://b/?replicaSet=rs", + "description": "Discover secondary with directConnection URI option", + "uri": "mongodb://b/?directConnection=false", "phases": [ { "responses": [ diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_secondary.yml b/test/spec/server-discovery-and-monitoring/rs/discover_secondary.yml index 221e3693bd..3fdbccb283 100644 --- a/test/spec/server-discovery-and-monitoring/rs/discover_secondary.yml +++ b/test/spec/server-discovery-and-monitoring/rs/discover_secondary.yml @@ -1,6 +1,6 @@ -description: "Replica set discovery from secondary" +description: "Discover secondary with directConnection URI option" -uri: "mongodb://b/?replicaSet=rs" +uri: "mongodb://b/?directConnection=false" phases: [ diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_secondary_replicaset.json b/test/spec/server-discovery-and-monitoring/rs/discover_secondary_replicaset.json new file mode 100644 index 0000000000..3dde3166b4 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_secondary_replicaset.json @@ -0,0 +1,40 @@ +{ + "description": "Discover secondary with replicaSet URI option", + "uri": "mongodb://b/?replicaSet=rs", + "phases": [ + { + "responses": [ + [ + "b:27017", + { + "ok": 1, + "ismaster": false, + "secondary": true, + "setName": "rs", + "hosts": [ + "a:27017", + "b:27017" + ], + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": { + "a:27017": { + "type": "Unknown", + "setName": null + }, + "b:27017": { + "type": "RSSecondary", + "setName": "rs" + } + }, + "topologyType": "ReplicaSetNoPrimary", + "logicalSessionTimeoutMinutes": null, + "setName": "rs" + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/rs/discover_secondary_replicaset.yml b/test/spec/server-discovery-and-monitoring/rs/discover_secondary_replicaset.yml new file mode 100644 index 0000000000..3781d0e42d --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/discover_secondary_replicaset.yml @@ -0,0 +1,43 @@ +description: "Discover secondary with replicaSet URI option" + +uri: "mongodb://b/?replicaSet=rs" + +phases: [ + + { + responses: [ + + ["b:27017", { + + ok: 1, + ismaster: false, + secondary: true, + setName: "rs", + hosts: ["a:27017", "b:27017"], + minWireVersion: 0, + maxWireVersion: 6 + }] + ], + + outcome: { + + servers: { + + "a:27017": { + + type: "Unknown", + setName: + }, + + "b:27017": { + + type: "RSSecondary", + setName: "rs" + } + }, + topologyType: "ReplicaSetNoPrimary", + logicalSessionTimeoutMinutes: null, + setName: "rs" + } + } +] diff --git a/test/spec/server-discovery-and-monitoring/rs/incompatible_arbiter.yml b/test/spec/server-discovery-and-monitoring/rs/incompatible_arbiter.yml index f7a3cdad0e..e41dbcd6fe 100644 --- a/test/spec/server-discovery-and-monitoring/rs/incompatible_arbiter.yml +++ b/test/spec/server-discovery-and-monitoring/rs/incompatible_arbiter.yml @@ -1,5 +1,7 @@ description: "Incompatible arbiter" + uri: "mongodb://a,b/?replicaSet=rs" + phases: - responses: - diff --git a/test/spec/server-discovery-and-monitoring/rs/incompatible_ghost.yml b/test/spec/server-discovery-and-monitoring/rs/incompatible_ghost.yml index e04487cb7d..fa73ec3ddd 100644 --- a/test/spec/server-discovery-and-monitoring/rs/incompatible_ghost.yml +++ b/test/spec/server-discovery-and-monitoring/rs/incompatible_ghost.yml @@ -1,5 +1,7 @@ description: "Incompatible ghost" + uri: "mongodb://a,b/?replicaSet=rs" + phases: - responses: - diff --git a/test/spec/server-discovery-and-monitoring/rs/incompatible_other.yml b/test/spec/server-discovery-and-monitoring/rs/incompatible_other.yml index 9ee452daf9..848b307ab0 100644 --- a/test/spec/server-discovery-and-monitoring/rs/incompatible_other.yml +++ b/test/spec/server-discovery-and-monitoring/rs/incompatible_other.yml @@ -1,5 +1,7 @@ description: "Incompatible other" + uri: "mongodb://a,b/?replicaSet=rs" + phases: - responses: - diff --git a/test/spec/server-discovery-and-monitoring/rs/replicaset_rsnp.json b/test/spec/server-discovery-and-monitoring/rs/replicaset_rsnp.json new file mode 100644 index 0000000000..a0f69de486 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/replicaset_rsnp.json @@ -0,0 +1,25 @@ +{ + "description": "replicaSet URI option causes starting topology to be RSNP", + "uri": "mongodb://a/?replicaSet=rs&directConnection=false", + "phases": [ + { + "responses": [ + [ + "a:27017", + { + "ok": 1, + "ismaster": true, + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": {}, + "topologyType": "ReplicaSetNoPrimary", + "logicalSessionTimeoutMinutes": null, + "setName": "rs" + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/rs/replicaset_rsnp.yml b/test/spec/server-discovery-and-monitoring/rs/replicaset_rsnp.yml new file mode 100644 index 0000000000..cb15fac812 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/replicaset_rsnp.yml @@ -0,0 +1,20 @@ +description: replicaSet URI option causes starting topology to be RSNP + +uri: "mongodb://a/?replicaSet=rs&directConnection=false" + +phases: + # We are connecting to a standalone + - responses: + - + - "a:27017" + - ok: 1 + ismaster: true + minWireVersion: 0 + maxWireVersion: 6 + outcome: + # Server is removed because it's a standalone and the driver + # started in RSNP topology + servers: {} + topologyType: "ReplicaSetNoPrimary" + logicalSessionTimeoutMinutes: ~ + setName: "rs" diff --git a/test/spec/server-discovery-and-monitoring/rs/secondary_mismatched_me.json b/test/spec/server-discovery-and-monitoring/rs/secondary_mismatched_me.json index d2a70f6788..769e272a66 100644 --- a/test/spec/server-discovery-and-monitoring/rs/secondary_mismatched_me.json +++ b/test/spec/server-discovery-and-monitoring/rs/secondary_mismatched_me.json @@ -1,5 +1,6 @@ { "description": "Secondary mismatched me", + "uri": "mongodb://localhost:27017/?replicaSet=rs", "phases": [ { "outcome": { @@ -35,6 +36,5 @@ ] ] } - ], - "uri": "mongodb://localhost:27017/?replicaSet=rs" + ] } diff --git a/test/spec/server-discovery-and-monitoring/rs/secondary_mismatched_me.yml b/test/spec/server-discovery-and-monitoring/rs/secondary_mismatched_me.yml index 7a093c8dcc..be2ace0cf0 100644 --- a/test/spec/server-discovery-and-monitoring/rs/secondary_mismatched_me.yml +++ b/test/spec/server-discovery-and-monitoring/rs/secondary_mismatched_me.yml @@ -1,4 +1,7 @@ description: Secondary mismatched me + +uri: 'mongodb://localhost:27017/?replicaSet=rs' + phases: - outcome: servers: @@ -22,5 +25,3 @@ phases: setName: rs minWireVersion: 0 maxWireVersion: 6 -uri: 'mongodb://localhost:27017/?replicaSet=rs' - diff --git a/test/spec/server-discovery-and-monitoring/rs/too_new.yml b/test/spec/server-discovery-and-monitoring/rs/too_new.yml index a47527af4f..5f185f7a19 100644 --- a/test/spec/server-discovery-and-monitoring/rs/too_new.yml +++ b/test/spec/server-discovery-and-monitoring/rs/too_new.yml @@ -1,5 +1,7 @@ description: "Replica set member with large minWireVersion" + uri: "mongodb://a,b/?replicaSet=rs" + phases: [ { responses: [ diff --git a/test/spec/server-discovery-and-monitoring/sharded/discover_single_mongos.json b/test/spec/server-discovery-and-monitoring/sharded/discover_single_mongos.json new file mode 100644 index 0000000000..427889f8cc --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/sharded/discover_single_mongos.json @@ -0,0 +1,30 @@ +{ + "description": "Discover single mongos", + "uri": "mongodb://a/?directConnection=false", + "phases": [ + { + "responses": [ + [ + "a:27017", + { + "ok": 1, + "ismaster": true, + "msg": "isdbgrid", + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": { + "a:27017": { + "type": "Mongos", + "setName": null + } + }, + "topologyType": "Sharded", + "setName": null + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/sharded/discover_single_mongos.yml b/test/spec/server-discovery-and-monitoring/sharded/discover_single_mongos.yml new file mode 100644 index 0000000000..be12100925 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/sharded/discover_single_mongos.yml @@ -0,0 +1,23 @@ +description: "Discover single mongos" + +uri: "mongodb://a/?directConnection=false" + +phases: + + - responses: + - + - "a:27017" + - + ok: 1 + ismaster: true + msg: "isdbgrid" + minWireVersion: 0 + maxWireVersion: 6 + + outcome: + servers: + "a:27017": + type: "Mongos" + setName: + topologyType: "Sharded" + setName: diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_external_ip.json b/test/spec/server-discovery-and-monitoring/single/direct_connection_external_ip.json index 4458150186..afd5edc1d2 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_external_ip.json +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_external_ip.json @@ -1,6 +1,6 @@ { "description": "Direct connection to RSPrimary via external IP", - "uri": "mongodb://a", + "uri": "mongodb://a/?directConnection=true", "phases": [ { "responses": [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_external_ip.yml b/test/spec/server-discovery-and-monitoring/single/direct_connection_external_ip.yml index bf9b68aeb7..1b3a8db70b 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_external_ip.yml +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_external_ip.yml @@ -1,6 +1,6 @@ description: "Direct connection to RSPrimary via external IP" -uri: "mongodb://a" +uri: "mongodb://a/?directConnection=true" phases: [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_mongos.json b/test/spec/server-discovery-and-monitoring/single/direct_connection_mongos.json index a7fa079490..9175049cc6 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_mongos.json +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_mongos.json @@ -1,6 +1,6 @@ { - "description": "Connect to mongos", - "uri": "mongodb://a", + "description": "Direct connection to mongos", + "uri": "mongodb://a/?directConnection=true", "phases": [ { "responses": [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_mongos.yml b/test/spec/server-discovery-and-monitoring/single/direct_connection_mongos.yml index e039723019..1253bbcc8d 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_mongos.yml +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_mongos.yml @@ -1,6 +1,6 @@ -description: "Connect to mongos" +description: "Direct connection to mongos" -uri: "mongodb://a" +uri: "mongodb://a/?directConnection=true" phases: [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_replicaset.json b/test/spec/server-discovery-and-monitoring/single/direct_connection_replicaset.json new file mode 100644 index 0000000000..c629a709be --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_replicaset.json @@ -0,0 +1,31 @@ +{ + "description": "Direct connection with replicaSet URI option", + "uri": "mongodb://a/?replicaSet=rs&directConnection=true", + "phases": [ + { + "responses": [ + [ + "a:27017", + { + "ok": 1, + "ismaster": true, + "setName": "rs", + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": { + "a:27017": { + "type": "RSPrimary", + "setName": "rs" + } + }, + "topologyType": "Single", + "logicalSessionTimeoutMinutes": null, + "setName": "rs" + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_replicaset.yml b/test/spec/server-discovery-and-monitoring/single/direct_connection_replicaset.yml new file mode 100644 index 0000000000..25418e66e1 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_replicaset.yml @@ -0,0 +1,22 @@ +description: Direct connection with replicaSet URI option + +uri: "mongodb://a/?replicaSet=rs&directConnection=true" + +phases: + # We are connecting to a replica set member + - responses: + - + - "a:27017" + - ok: 1 + ismaster: true + setName: rs + minWireVersion: 0 + maxWireVersion: 6 + outcome: + servers: + "a:27017": + type: "RSPrimary" + setName: "rs" + topologyType: "Single" + logicalSessionTimeoutMinutes: + setName: rs diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_rsarbiter.json b/test/spec/server-discovery-and-monitoring/single/direct_connection_rsarbiter.json index 3ef374d6f1..b07beb31ed 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_rsarbiter.json +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_rsarbiter.json @@ -1,6 +1,6 @@ { - "description": "Connect to RSArbiter", - "uri": "mongodb://a", + "description": "Direct connection to RSArbiter", + "uri": "mongodb://a/?directConnection=true", "phases": [ { "responses": [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_rsarbiter.yml b/test/spec/server-discovery-and-monitoring/single/direct_connection_rsarbiter.yml index 4d03d0baab..c531aab5e5 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_rsarbiter.yml +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_rsarbiter.yml @@ -1,6 +1,6 @@ -description: "Connect to RSArbiter" +description: "Direct connection to RSArbiter" -uri: "mongodb://a" +uri: "mongodb://a/?directConnection=true" phases: [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_rsprimary.json b/test/spec/server-discovery-and-monitoring/single/direct_connection_rsprimary.json index bd5aaf7f04..7216a13345 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_rsprimary.json +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_rsprimary.json @@ -1,6 +1,6 @@ { - "description": "Connect to RSPrimary", - "uri": "mongodb://a", + "description": "Direct connection to RSPrimary", + "uri": "mongodb://a/?directConnection=true", "phases": [ { "responses": [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_rsprimary.yml b/test/spec/server-discovery-and-monitoring/single/direct_connection_rsprimary.yml index c4b2fa0b3a..0aea56e12b 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_rsprimary.yml +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_rsprimary.yml @@ -1,6 +1,6 @@ -description: "Connect to RSPrimary" +description: "Direct connection to RSPrimary" -uri: "mongodb://a" +uri: "mongodb://a/?directConnection=true" phases: [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_rssecondary.json b/test/spec/server-discovery-and-monitoring/single/direct_connection_rssecondary.json index 3b4f3c8c5a..573036f2aa 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_rssecondary.json +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_rssecondary.json @@ -1,6 +1,6 @@ { - "description": "Connect to RSSecondary", - "uri": "mongodb://a", + "description": "Direct connection to RSSecondary", + "uri": "mongodb://a/?directConnection=true", "phases": [ { "responses": [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_rssecondary.yml b/test/spec/server-discovery-and-monitoring/single/direct_connection_rssecondary.yml index a57332f253..6cd3e5909a 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_rssecondary.yml +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_rssecondary.yml @@ -1,6 +1,6 @@ -description: "Connect to RSSecondary" +description: "Direct connection to RSSecondary" -uri: "mongodb://a" +uri: "mongodb://a/?directConnection=true" phases: [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_slave.json b/test/spec/server-discovery-and-monitoring/single/direct_connection_slave.json index a40debd183..720ec3dd82 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_slave.json +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_slave.json @@ -1,6 +1,6 @@ { "description": "Direct connection to slave", - "uri": "mongodb://a", + "uri": "mongodb://a/?directConnection=true", "phases": [ { "responses": [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_slave.yml b/test/spec/server-discovery-and-monitoring/single/direct_connection_slave.yml index 166470cae5..7c2436db16 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_slave.yml +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_slave.yml @@ -1,6 +1,6 @@ description: "Direct connection to slave" -uri: "mongodb://a" +uri: "mongodb://a/?directConnection=true" phases: [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_standalone.json b/test/spec/server-discovery-and-monitoring/single/direct_connection_standalone.json index 2ecff9b9ae..c53d76e76e 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_standalone.json +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_standalone.json @@ -1,6 +1,6 @@ { - "description": "Connect to standalone", - "uri": "mongodb://a", + "description": "Direct connection to standalone", + "uri": "mongodb://a/?directConnection=true", "phases": [ { "responses": [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_standalone.yml b/test/spec/server-discovery-and-monitoring/single/direct_connection_standalone.yml index 8c5bcdef44..7ad5f590b8 100644 --- a/test/spec/server-discovery-and-monitoring/single/direct_connection_standalone.yml +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_standalone.yml @@ -1,6 +1,6 @@ -description: "Connect to standalone" +description: "Direct connection to standalone" -uri: "mongodb://a" +uri: "mongodb://a/?directConnection=true" phases: [ diff --git a/test/spec/server-discovery-and-monitoring/single/unavailable_seed.json b/test/spec/server-discovery-and-monitoring/single/direct_connection_unavailable_seed.json similarity index 78% rename from test/spec/server-discovery-and-monitoring/single/unavailable_seed.json rename to test/spec/server-discovery-and-monitoring/single/direct_connection_unavailable_seed.json index e9cce02ebf..16f2735da5 100644 --- a/test/spec/server-discovery-and-monitoring/single/unavailable_seed.json +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_unavailable_seed.json @@ -1,6 +1,6 @@ { - "description": "Unavailable seed", - "uri": "mongodb://a", + "description": "Direct connection to unavailable seed", + "uri": "mongodb://a/?directConnection=true", "phases": [ { "responses": [ diff --git a/test/spec/server-discovery-and-monitoring/single/unavailable_seed.yml b/test/spec/server-discovery-and-monitoring/single/direct_connection_unavailable_seed.yml similarity index 80% rename from test/spec/server-discovery-and-monitoring/single/unavailable_seed.yml rename to test/spec/server-discovery-and-monitoring/single/direct_connection_unavailable_seed.yml index c4cfbf76cc..46284ded6d 100644 --- a/test/spec/server-discovery-and-monitoring/single/unavailable_seed.yml +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_unavailable_seed.yml @@ -1,6 +1,6 @@ -description: "Unavailable seed" +description: "Direct connection to unavailable seed" -uri: "mongodb://a" +uri: "mongodb://a/?directConnection=true" phases: [ diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_wrong_set_name.json b/test/spec/server-discovery-and-monitoring/single/direct_connection_wrong_set_name.json new file mode 100644 index 0000000000..8cfbd6e28c --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_wrong_set_name.json @@ -0,0 +1,35 @@ +{ + "description": "Direct connection to RSPrimary with wrong set name", + "uri": "mongodb://a/?directConnection=true&replicaSet=wrong", + "phases": [ + { + "responses": [ + [ + "a:27017", + { + "ok": 1, + "ismaster": true, + "hosts": [ + "a:27017", + "b:27017" + ], + "setName": "rs", + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": { + "a:27017": { + "type": "RSPrimary", + "setName": "rs" + } + }, + "topologyType": "Single", + "logicalSessionTimeoutMinutes": null, + "setName": "wrong" + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/single/direct_connection_wrong_set_name.yml b/test/spec/server-discovery-and-monitoring/single/direct_connection_wrong_set_name.yml new file mode 100644 index 0000000000..8a94d95ebe --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/single/direct_connection_wrong_set_name.yml @@ -0,0 +1,36 @@ +description: "Direct connection to RSPrimary with wrong set name" + +uri: "mongodb://a/?directConnection=true&replicaSet=wrong" + +phases: [ + + { + responses: [ + + ["a:27017", { + + ok: 1, + ismaster: true, + hosts: ["a:27017", "b:27017"], + setName: "rs", + minWireVersion: 0, + maxWireVersion: 6 + }] + ], + + outcome: { + + servers: { + + "a:27017": { + + type: "RSPrimary", + setName: "rs" + } + }, + topologyType: "Single", + logicalSessionTimeoutMinutes: null, + setName: wrong + } + } +] diff --git a/test/spec/server-discovery-and-monitoring/single/discover_standalone.json b/test/spec/server-discovery-and-monitoring/single/discover_standalone.json new file mode 100644 index 0000000000..eb6c6ae746 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/single/discover_standalone.json @@ -0,0 +1,30 @@ +{ + "description": "Discover standalone", + "uri": "mongodb://a/?directConnection=false", + "phases": [ + { + "responses": [ + [ + "a:27017", + { + "ok": 1, + "ismaster": true, + "minWireVersion": 0, + "maxWireVersion": 6 + } + ] + ], + "outcome": { + "servers": { + "a:27017": { + "type": "Standalone", + "setName": null + } + }, + "topologyType": "Single", + "logicalSessionTimeoutMinutes": null, + "setName": null + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/single/discover_standalone.yml b/test/spec/server-discovery-and-monitoring/single/discover_standalone.yml new file mode 100644 index 0000000000..5071033b8e --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/single/discover_standalone.yml @@ -0,0 +1,34 @@ +description: "Discover standalone" + +uri: "mongodb://a/?directConnection=false" + +phases: [ + + { + responses: [ + + ["a:27017", { + + ok: 1, + ismaster: true, + minWireVersion: 0, + maxWireVersion: 6 + }] + ], + + outcome: { + + servers: { + + "a:27017": { + + type: "Standalone", + setName: + } + }, + topologyType: "Single", + logicalSessionTimeoutMinutes: null, + setName: + } + } +] diff --git a/test/spec/server-discovery-and-monitoring/single/discover_unavailable_seed.json b/test/spec/server-discovery-and-monitoring/single/discover_unavailable_seed.json new file mode 100644 index 0000000000..b1f306c2be --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/single/discover_unavailable_seed.json @@ -0,0 +1,25 @@ +{ + "description": "Discover unavailable seed", + "uri": "mongodb://a/?directConnection=false", + "phases": [ + { + "responses": [ + [ + "a:27017", + {} + ] + ], + "outcome": { + "servers": { + "a:27017": { + "type": "Unknown", + "setName": null + } + }, + "topologyType": "Unknown", + "logicalSessionTimeoutMinutes": null, + "setName": null + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/single/discover_unavailable_seed.yml b/test/spec/server-discovery-and-monitoring/single/discover_unavailable_seed.yml new file mode 100644 index 0000000000..e451025e8a --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/single/discover_unavailable_seed.yml @@ -0,0 +1,28 @@ +description: "Discover unavailable seed" + +uri: "mongodb://a/?directConnection=false" + +phases: [ + + { + responses: [ + + ["a:27017", {}] + ], + + outcome: { + + servers: { + + "a:27017": { + + type: "Unknown", + setName: + } + }, + topologyType: "Unknown", + logicalSessionTimeoutMinutes: null, + setName: + } + } +] diff --git a/test/spec/uri-options/concern-options.json b/test/spec/uri-options/concern-options.json index 2b3783746c..5a8ef6c272 100644 --- a/test/spec/uri-options/concern-options.json +++ b/test/spec/uri-options/concern-options.json @@ -36,15 +36,6 @@ "w": "arbitraryButStillValid" } }, - { - "description": "Too low w causes a warning", - "uri": "mongodb://example.com/?w=-2", - "valid": true, - "warning": true, - "hosts": null, - "auth": null, - "options": {} - }, { "description": "Non-numeric wTimeoutMS causes a warning", "uri": "mongodb://example.com/?wTimeoutMS=invalid", diff --git a/test/spec/uri-options/connection-options.json b/test/spec/uri-options/connection-options.json index 1e2dccd6e2..1cd7c55f08 100644 --- a/test/spec/uri-options/connection-options.json +++ b/test/spec/uri-options/connection-options.json @@ -117,6 +117,56 @@ "hosts": null, "auth": null, "options": {} + }, + { + "description": "directConnection=true", + "uri": "mongodb://example.com/?directConnection=true", + "valid": true, + "warning": false, + "hosts": null, + "auth": null, + "options": { + "directConnection": true + } + }, + { + "description": "directConnection=true with multiple seeds", + "uri": "mongodb://example1.com,example2.com/?directConnection=true", + "valid": false, + "warning": false, + "hosts": null, + "auth": null + }, + { + "description": "directConnection=false", + "uri": "mongodb://example.com/?directConnection=false", + "valid": true, + "warning": false, + "hosts": null, + "auth": null, + "options": { + "directConnection": false + } + }, + { + "description": "directConnection=false with multiple seeds", + "uri": "mongodb://example1.com,example2.com/?directConnection=false", + "valid": true, + "warning": false, + "hosts": null, + "auth": null, + "options": { + "directConnection": false + } + }, + { + "description": "Invalid directConnection value", + "uri": "mongodb://example.com/?directConnection=invalid", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": {} } ] } diff --git a/test/spec/uri-options/connection-options.yml b/test/spec/uri-options/connection-options.yml index a637dae298..c90b88d743 100644 --- a/test/spec/uri-options/connection-options.yml +++ b/test/spec/uri-options/connection-options.yml @@ -104,3 +104,46 @@ tests: hosts: ~ auth: ~ options: {} + + - + description: directConnection=true + uri: "mongodb://example.com/?directConnection=true" + valid: true + warning: false + hosts: ~ + auth: ~ + options: + directConnection: true + - + description: directConnection=true with multiple seeds + uri: "mongodb://example1.com,example2.com/?directConnection=true" + valid: false + warning: false + hosts: ~ + auth: ~ + - + description: directConnection=false + uri: "mongodb://example.com/?directConnection=false" + valid: true + warning: false + hosts: ~ + auth: ~ + options: + directConnection: false + - + description: directConnection=false with multiple seeds + uri: "mongodb://example1.com,example2.com/?directConnection=false" + valid: true + warning: false + hosts: ~ + auth: ~ + options: + directConnection: false + - + description: Invalid directConnection value + uri: "mongodb://example.com/?directConnection=invalid" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} diff --git a/test/unit/core/mongodb_srv.test.js b/test/unit/core/mongodb_srv.test.js index 6d45fd554c..f4a03b0171 100644 --- a/test/unit/core/mongodb_srv.test.js +++ b/test/unit/core/mongodb_srv.test.js @@ -29,26 +29,18 @@ describe('mongodb+srv', function() { it(test[1].comment, { metadata: { requires: { topology: ['single'] } }, test: function(done) { - parseConnectionString(test[1].uri, { caseTranslate: false }, (err, result) => { + parseConnectionString(test[1].uri, (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; - - if (test[1].options && test[1].options.replicaSet) { - expect(result.options.replicaset).to.equal(test[1].options.replicaSet); - } - - if (test[1].options && test[1].options.ssl) { - expect(result.options.ssl).to.equal(test[1].options.ssl); + if (test[1].options) { + expect(result) + .property('options') + .to.matchMongoSpec(test[1].options); } - - if (test[1].options && test[1].options.authSource) { - expect(result.options.authsource).to.equal(test[1].options.authSource); - } - if ( test[1].parsed_options && test[1].parsed_options.user && @@ -58,7 +50,6 @@ describe('mongodb+srv', function() { expect(result.auth.password).to.equal(test[1].parsed_options.password); } } - done(); }); } diff --git a/test/unit/sdam/spec.test.js b/test/unit/sdam/spec.test.js index fbf619c553..64f036320a 100644 --- a/test/unit/sdam/spec.test.js +++ b/test/unit/sdam/spec.test.js @@ -51,11 +51,22 @@ describe('Server Discovery and Monitoring (spec)', function() { serverConnect.restore(); }); + // DRIVERS-1249 should add directConnection and then update spec, remove skip + const shouldSkip = desc => { + const descriptions = [ + 'Monitoring a standalone connection', + 'Monitoring a standalone connection - suppress update events for equal server descriptions' + ]; + return descriptions.includes(desc); + }; + const specTests = collectTests(); Object.keys(specTests).forEach(specTestName => { describe(specTestName, () => { specTests[specTestName].forEach(testData => { - it(testData.description, { + const skip = shouldSkip(testData.description); + const type = skip ? it.skip : it; + type(testData.description, { metadata: { requires: { topology: 'single' } }, test: function(done) { executeSDAMTest(testData, done);