diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e9c7e7..f07699d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Update guidesmiths references to onebeyond. - Dedupe channel poole ready check - Remove unnecessary subscription config from busy publisher example +- Fixed bug where hostname connection order was not properly randomised ## 17.0.1 diff --git a/lib/config/configure.js b/lib/config/configure.js index 30107e8..5386a7e 100644 --- a/lib/config/configure.js +++ b/lib/config/configure.js @@ -132,7 +132,7 @@ module.exports = _.curry((rascalConfig, next) => { } function setConnectionIndex(connection, strategy, index) { - connection.index = strategy === 'fixed' ? index : getConnectionIndex(strategy, `${connection.host}:${connection.port}`); + connection.index = strategy === 'fixed' ? index : getConnectionIndex(strategy, `${connection.hostname}:${connection.port}`); } function getConnectionIndex(strategy, hostname) { diff --git a/test/config.tests.js b/test/config.tests.js index 6f73399..4ec4bec 100644 --- a/test/config.tests.js +++ b/test/config.tests.js @@ -233,7 +233,7 @@ describe('Configuration', () => { it('should randomise the order of connections, but maintain order across vhosts by host', () => { const results = []; - for (let i = 0; i < 10; i++) { + for (let i = 0; i < 100; i++) { configure( { vhosts: { @@ -336,7 +336,7 @@ describe('Configuration', () => { }, ); } - assert.ok(_.uniq(results).length > 1); + assert.ok(_.uniq(results).length > 10); }); it('should honour the order of connections with fixed connection strategy', () => {