Skip to content

Commit aa61cbf

Browse files
committed
Fix hostname randomisation bug
1 parent ecbd658 commit aa61cbf

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Update guidesmiths references to onebeyond.
66
- Dedupe channel poole ready check
77
- Remove unnecessary subscription config from busy publisher example
8+
- Fixed bug where hostname connection order was not properly randomised
89

910
## 17.0.1
1011

lib/config/configure.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ module.exports = _.curry((rascalConfig, next) => {
132132
}
133133

134134
function setConnectionIndex(connection, strategy, index) {
135-
connection.index = strategy === 'fixed' ? index : getConnectionIndex(strategy, `${connection.host}:${connection.port}`);
135+
connection.index = strategy === 'fixed' ? index : getConnectionIndex(strategy, `${connection.hostname}:${connection.port}`);
136136
}
137137

138138
function getConnectionIndex(strategy, hostname) {

test/config.tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ describe('Configuration', () => {
233233

234234
it('should randomise the order of connections, but maintain order across vhosts by host', () => {
235235
const results = [];
236-
for (let i = 0; i < 10; i++) {
236+
for (let i = 0; i < 100; i++) {
237237
configure(
238238
{
239239
vhosts: {
@@ -336,7 +336,7 @@ describe('Configuration', () => {
336336
},
337337
);
338338
}
339-
assert.ok(_.uniq(results).length > 1);
339+
assert.ok(_.uniq(results).length > 10);
340340
});
341341

342342
it('should honour the order of connections with fixed connection strategy', () => {

0 commit comments

Comments
 (0)