Skip to content

Commit f8fd310

Browse files
author
Thomas Reggi
authored
fix: adds topology discovery for sharded cluster
NODE-2827
1 parent efd906a commit f8fd310

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

lib/core/uri_parser.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -687,15 +687,6 @@ function parseConnectionString(uri, options, callback) {
687687
return callback(new MongoParseError('directConnection option requires exactly one host'));
688688
}
689689

690-
// NOTE: this behavior will go away in v4.0, we will always auto discover there
691-
if (
692-
parsedOptions.directConnection == null &&
693-
hosts.length === 1 &&
694-
parsedOptions.replicaSet == null
695-
) {
696-
parsedOptions.directConnection = true;
697-
}
698-
699690
const result = {
700691
hosts: hosts,
701692
auth: auth.db || auth.username ? auth : null,

test/functional/sharding_connection.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
'use strict';
22

3+
const withClient = require('./shared').withClient;
34
const setupDatabase = require('./shared').setupDatabase;
45
const expect = require('chai').expect;
6+
const TopologyType = require('../../lib/core/sdam/common').TopologyType;
57

68
describe('Sharding (Connection)', function() {
79
before(function() {
810
return setupDatabase(this.configuration);
911
});
1012

13+
it('Should use sharded topology', {
14+
metadata: { requires: { topology: 'sharded' } },
15+
test: function() {
16+
const client = this.configuration.newClient({}, { useUnifiedTopology: true });
17+
return withClient(client, (client, done) => {
18+
expect(client).to.exist;
19+
expect(client)
20+
.nested.property('topology.description.type')
21+
.to.equal(TopologyType.Sharded);
22+
return done();
23+
})();
24+
}
25+
});
26+
1127
/**
1228
* @ignore
1329
*/

0 commit comments

Comments
 (0)