This repository has been archived by the owner on Feb 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mongos-replset): pass connect options to child server instances
This allows for options determined during uri parsing to make it down to the creation of child Server instances using the legacy SDAM topology classes. NODE-1798
- Loading branch information
Showing
3 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
const ReplSet = require('../../../../lib/topologies/replset'); | ||
const mock = require('mongodb-mock-server'); | ||
const ReplSetFixture = require('../common').ReplSetFixture; | ||
const expect = require('chai').expect; | ||
|
||
describe('Compression (ReplSet)', function() { | ||
let test; | ||
before(() => (test = new ReplSetFixture())); | ||
afterEach(() => mock.cleanup()); | ||
beforeEach(() => test.setup()); | ||
|
||
it('should pass compression information to child server instances on connect', function(done) { | ||
const compressionData = []; | ||
test.primaryServer.setMessageHandler(request => { | ||
const doc = request.document; | ||
if (doc.ismaster) { | ||
compressionData.push(doc.compression); | ||
request.reply(test.primaryStates[0]); | ||
} | ||
}); | ||
|
||
test.firstSecondaryServer.setMessageHandler(request => { | ||
const doc = request.document; | ||
if (doc.ismaster) { | ||
compressionData.push(doc.compression); | ||
request.reply(test.firstSecondaryStates[0]); | ||
} | ||
}); | ||
|
||
const replSet = new ReplSet( | ||
[test.primaryServer.address(), test.firstSecondaryServer.address()], | ||
{ | ||
setName: 'rs', | ||
haInterval: 10000, | ||
connectionTimeout: 3000, | ||
secondaryOnlyConnectionAllowed: true, | ||
size: 1 | ||
} | ||
); | ||
|
||
replSet.on('fullsetup', () => { | ||
compressionData.forEach(data => { | ||
expect(data).to.eql(['zlib']); | ||
}); | ||
|
||
done(); | ||
}); | ||
|
||
replSet.connect({ compression: { compressors: ['zlib'] } }); | ||
}); | ||
}); |