From c5d60fc4619227697ef2102437fe5c8b111909d2 Mon Sep 17 00:00:00 2001 From: Thomas Reggi Date: Thu, 9 Apr 2020 12:00:48 -0400 Subject: [PATCH] feat: directConnection adds unify behavior for replica set discovery 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/core/sdam/topology.js | 12 ++- lib/core/sdam/topology_description.js | 20 ++++- lib/core/uri_parser.js | 32 ++++++-- lib/mongo_client.js | 2 + lib/operations/connect.js | 3 +- test/functional/core/replset_state.test.js | 16 +++- .../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/primary_mismatched_me_not_removed.json | 77 ++++++++++++++++++ .../rs/primary_mismatched_me_not_removed.yml | 73 +++++++++++++++++ .../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 +++++++ .../single/too_old_then_upgraded.json | 54 +++++++++++++ .../single/too_old_then_upgraded.yml | 46 +++++++++++ test/spec/uri-options/concern-options.json | 9 --- test/spec/uri-options/connection-options.json | 50 ++++++++++++ test/spec/uri-options/connection-options.yml | 43 ++++++++++ 81 files changed, 1608 insertions(+), 76 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/primary_mismatched_me_not_removed.json create mode 100644 test/spec/server-discovery-and-monitoring/rs/primary_mismatched_me_not_removed.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 create mode 100644 test/spec/server-discovery-and-monitoring/single/too_old_then_upgraded.json create mode 100644 test/spec/server-discovery-and-monitoring/single/too_old_then_upgraded.yml diff --git a/lib/core/sdam/topology.js b/lib/core/sdam/topology.js index ceb43ddbb4..a5da31626c 100644 --- a/lib/core/sdam/topology.js +++ b/lib/core/sdam/topology.js @@ -813,10 +813,16 @@ function parseStringSeedlist(seedlist) { } function topologyTypeFromSeedlist(seedlist, options) { + if (options.directConnection) { + return TopologyType.Single; + } + const replicaSet = options.replicaSet || options.setName || options.rs_name; - if (seedlist.length === 1 && !replicaSet) return TopologyType.Single; - if (replicaSet) return TopologyType.ReplicaSetNoPrimary; - return TopologyType.Unknown; + if (replicaSet == null) { + return TopologyType.Unknown; + } + + return TopologyType.ReplicaSetNoPrimary; } function randomSelection(array) { diff --git a/lib/core/sdam/topology_description.js b/lib/core/sdam/topology_description.js index d1beb22c7c..87f8e6fab7 100644 --- a/lib/core/sdam/topology_description.js +++ b/lib/core/sdam/topology_description.js @@ -161,7 +161,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); @@ -274,8 +274,22 @@ class TopologyDescription { } function topologyTypeForServerType(serverType) { - if (serverType === ServerType.Mongos) return TopologyType.Sharded; - if (serverType === ServerType.RSPrimary) return TopologyType.ReplicaSetWithPrimary; + if (serverType === ServerType.Standalone) { + return TopologyType.Single; + } + + if (serverType === ServerType.Mongos) { + return TopologyType.Sharded; + } + + if (serverType === ServerType.RSPrimary) { + return TopologyType.ReplicaSetWithPrimary; + } + + if (serverType === ServerType.RSGhost || serverType === ServerType.Unknown) { + return TopologyType.Unknown; + } + return TopologyType.ReplicaSetNoPrimary; } diff --git a/lib/core/uri_parser.js b/lib/core/uri_parser.js index a51a1c3d84..d140d70a2d 100644 --- a/lib/core/uri_parser.js +++ b/lib/core/uri_parser.js @@ -37,6 +37,10 @@ function matchesParentDomain(srvAddress, parentDomain) { function parseSrvConnectionString(uri, options, callback) { const result = URL.parse(uri, true); + if (options.directConnection || 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')); } @@ -215,7 +219,8 @@ const CASE_TRANSLATION = { tlscertificatekeyfile: 'tlsCertificateKeyFile', tlscertificatekeyfilepassword: 'tlsCertificateKeyFilePassword', wtimeout: 'wTimeoutMS', - j: 'journal' + j: 'journal', + directconnection: 'directConnection' }; /** @@ -565,10 +570,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; @@ -581,6 +582,11 @@ function parseConnectionString(uri, options, callback) { } 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` @@ -674,6 +680,22 @@ 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')); + } + + // NOTE: this behavior will go away in v4.0, we will always auto discover there + if ( + parsedOptions.directConnection == null && + hosts.length === 1 && + parsedOptions.replicaSet == null + ) { + parsedOptions.directConnection = true; + } + const result = { hosts: hosts, auth: auth.db || auth.username ? auth : null, diff --git a/lib/mongo_client.js b/lib/mongo_client.js index eea5c4549c..102f4ff820 100644 --- a/lib/mongo_client.js +++ b/lib/mongo_client.js @@ -145,6 +145,7 @@ const validOptions = require('./operations/connect').validOptions; * @param {boolean} [options.useUnifiedTopology] Enables the new unified topology layer * @param {AutoEncrypter~AutoEncryptionOptions} [options.autoEncryption] Optionally enable client side auto encryption * @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] Enable directConnection * @param {MongoClient~connectCallback} [callback] The command result callback * @return {MongoClient} a MongoClient instance */ @@ -406,6 +407,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] Enable directConnection * @param {MongoClient~connectCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ diff --git a/lib/operations/connect.js b/lib/operations/connect.js index 48078d207a..12035fbfbb 100644 --- a/lib/operations/connect.js +++ b/lib/operations/connect.js @@ -153,7 +153,8 @@ const validOptionNames = [ 'tlsCertificateKeyFilePassword', 'minHeartbeatFrequencyMS', 'heartbeatFrequencyMS', - 'waitQueueTimeoutMS' + 'waitQueueTimeoutMS', + 'directConnection' ]; const ignoreOptionNames = ['native_parser']; diff --git a/test/functional/core/replset_state.test.js b/test/functional/core/replset_state.test.js index dcb2dfc3df..1eef3554b2 100644 --- a/test/functional/core/replset_state.test.js +++ b/test/functional/core/replset_state.test.js @@ -12,11 +12,21 @@ describe('ReplicaSet state', function() { fs.readdirSync(path) .filter(x => x.indexOf('.json') !== -1) - .filter(x => !x.includes('repeated')) .forEach(x => { - var testData = require(f('%s/%s', path, x)); + const testData = require(f('%s/%s', path, x)); + const description = testData.description; + it(description, function(done) { + if ( + description.match(/Repeated ismaster response must be processed/) || + description.match(/Primary mismatched me is not removed/) || + description.match(/replicaSet URI option causes starting topology to be RSNP/) || + description.match(/Discover secondary with directConnection URI option/) || + description.match(/Discover ghost with directConnection URI option/) + ) { + this.skip(); + return; + } - it(testData.description, function(done) { executeEntry(testData, done); }); }); 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/primary_mismatched_me_not_removed.json b/test/spec/server-discovery-and-monitoring/rs/primary_mismatched_me_not_removed.json new file mode 100644 index 0000000000..a9e01987c8 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/primary_mismatched_me_not_removed.json @@ -0,0 +1,77 @@ +{ + "description": "Primary mismatched me is not removed", + "uri": "mongodb://localhost:27017,localhost:27018/?replicaSet=rs", + "phases": [ + { + "responses": [ + [ + "localhost:27017", + { + "ok": 1, + "hosts": [ + "localhost:27017", + "localhost:27018" + ], + "ismaster": true, + "setName": "rs", + "primary": "localhost:27017", + "me": "a:27017", + "minWireVersion": 0, + "maxWireVersion": 7 + } + ] + ], + "outcome": { + "servers": { + "localhost:27017": { + "type": "RSPrimary", + "setName": "rs" + }, + "localhost:27018": { + "type": "Unknown", + "setName": null + } + }, + "topologyType": "ReplicaSetWithPrimary", + "logicalSessionTimeoutMinutes": null, + "setName": "rs" + } + }, + { + "responses": [ + [ + "localhost:27018", + { + "ok": 1, + "hosts": [ + "localhost:27017", + "localhost:27018" + ], + "ismaster": false, + "secondary": true, + "setName": "rs", + "primary": "localhost:27017", + "me": "localhost:27018", + "minWireVersion": 0, + "maxWireVersion": 7 + } + ] + ], + "outcome": { + "servers": { + "localhost:27017": { + "type": "RSPrimary", + "setName": "rs" + }, + "localhost:27018": { + "type": "RSSecondary", + "setName": "rs" + } + }, + "topologyType": "ReplicaSetWithPrimary", + "logicalSessionTimeoutMinutes": null, + "setName": "rs" + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/rs/primary_mismatched_me_not_removed.yml b/test/spec/server-discovery-and-monitoring/rs/primary_mismatched_me_not_removed.yml new file mode 100644 index 0000000000..540e206d45 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/rs/primary_mismatched_me_not_removed.yml @@ -0,0 +1,73 @@ +description: Primary mismatched me is not removed +uri: mongodb://localhost:27017,localhost:27018/?replicaSet=rs + +phases: [ + { + responses: [ + ["localhost:27017", { + ok: 1, + hosts: [ + "localhost:27017", + "localhost:27018" + ], + ismaster: true, + setName: "rs", + primary: "localhost:27017", + # me does not match the primary responder's address, but the server + # is still added because we don't me mismatch check the primary and all + # servers from a primary ismaster are added to the working server set + me: "a:27017", + minWireVersion: 0, + maxWireVersion: 7 + }] + ], + outcome: { + servers: { + "localhost:27017": { + type: "RSPrimary", + setName: "rs" + }, + "localhost:27018": { + type: "Unknown", + setName: null + } + }, + topologyType: "ReplicaSetWithPrimary", + logicalSessionTimeoutMinutes: null, + setName: "rs" + } + }, + { + responses: [ + ["localhost:27018", { + ok: 1, + hosts: [ + "localhost:27017", + "localhost:27018" + ], + ismaster: false, + secondary: true, + setName: "rs", + primary: "localhost:27017", + me: "localhost:27018", + minWireVersion: 0, + maxWireVersion: 7 + }] + ], + outcome: { + servers: { + "localhost:27017": { + type: "RSPrimary", + setName: "rs" + }, + "localhost:27018": { + type: "RSSecondary", + setName: "rs" + } + }, + topologyType: "ReplicaSetWithPrimary", + logicalSessionTimeoutMinutes: null, + setName: "rs" + } + } +] 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/server-discovery-and-monitoring/single/too_old_then_upgraded.json b/test/spec/server-discovery-and-monitoring/single/too_old_then_upgraded.json new file mode 100644 index 0000000000..7da46856fb --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/single/too_old_then_upgraded.json @@ -0,0 +1,54 @@ +{ + "description": "Standalone with default maxWireVersion of 0 is upgraded to one with maxWireVersion 6", + "uri": "mongodb://a", + "phases": [ + { + "responses": [ + [ + "a:27017", + { + "ok": 1, + "ismaster": true + } + ] + ], + "outcome": { + "servers": { + "a:27017": { + "type": "Standalone", + "setName": null + } + }, + "topologyType": "Single", + "logicalSessionTimeoutMinutes": null, + "setName": null, + "compatible": false + } + }, + { + "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, + "compatible": true + } + } + ] +} diff --git a/test/spec/server-discovery-and-monitoring/single/too_old_then_upgraded.yml b/test/spec/server-discovery-and-monitoring/single/too_old_then_upgraded.yml new file mode 100644 index 0000000000..ddf8f8fc47 --- /dev/null +++ b/test/spec/server-discovery-and-monitoring/single/too_old_then_upgraded.yml @@ -0,0 +1,46 @@ +description: "Standalone with default maxWireVersion of 0 is upgraded to one with maxWireVersion 6" +uri: "mongodb://a" +phases: [ + { + responses: [ + ["a:27017", { + ok: 1, + ismaster: true + }] + ], + outcome: { + servers: { + "a:27017": { + type: "Standalone", + setName: + } + }, + topologyType: "Single", + logicalSessionTimeoutMinutes: null, + setName: , + compatible: false + } + }, + { + responses: [ + ["a:27017", { + ok: 1, + ismaster: true, + minWireVersion: 0, + maxWireVersion: 6 + }] + ], + outcome: { + servers: { + "a:27017": { + type: "Standalone", + setName: + } + }, + topologyType: "Single", + logicalSessionTimeoutMinutes: null, + setName: , + compatible: true + } + } +] 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: {}