From 41677c4710dd66ad48eeca7de09e5345f784d5af Mon Sep 17 00:00:00 2001 From: emadum Date: Wed, 27 Jan 2021 08:37:15 -0500 Subject: [PATCH] fix test and add deprecation warning --- lib/core/uri_parser.js | 4 ++++ test/functional/sharding_connection.test.js | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/core/uri_parser.js b/lib/core/uri_parser.js index 57925d400eb..c40baced6ef 100644 --- a/lib/core/uri_parser.js +++ b/lib/core/uri_parser.js @@ -693,6 +693,10 @@ function parseConnectionString(uri, options, callback) { hosts.length === 1 && parsedOptions.replicaSet == null ) { + console.warn( + 'Automatic direct connection to single hosts is deprecated, please provide the `replicaSet` option' + + ' or explicitly set the `directConnection` option' + ); parsedOptions.directConnection = true; } diff --git a/test/functional/sharding_connection.test.js b/test/functional/sharding_connection.test.js index 8d3b5ed5d8f..851bc9c0ecd 100644 --- a/test/functional/sharding_connection.test.js +++ b/test/functional/sharding_connection.test.js @@ -13,7 +13,11 @@ describe('Sharding (Connection)', function() { it('Should use sharded topology', { metadata: { requires: { topology: 'sharded' } }, test: function() { - const client = this.configuration.newClient({}, { useUnifiedTopology: true }); + const client = this.configuration.newClient( + {}, + // note: directConnection: false will be the default behavior in 4.0 + { useUnifiedTopology: true, directConnection: false } + ); return withClient(client, (client, done) => { expect(client).to.exist; expect(client)