Comparing version 1.5.3 to 1.5.4
@@ -5,2 +5,6 @@ ## Changelog | ||
### v1.5.4 - June 25, 2015 | ||
* Fix masterNodes not being removed correctly. | ||
### v1.5.3 - June 24, 2015 | ||
@@ -7,0 +11,0 @@ |
@@ -176,2 +176,3 @@ 'use strict'; | ||
delete _this.nodes[key]; | ||
delete _this.masterNodes[key]; | ||
if (_this.subscriber === deadNode) { | ||
@@ -425,2 +426,3 @@ _this.selectSubscriber(); | ||
} | ||
_this.masterNodes = {}; | ||
for (i = 0; i < result.length; ++i) { | ||
@@ -427,0 +429,0 @@ var items = result[i]; |
{ | ||
"name": "ioredis", | ||
"version": "1.5.3", | ||
"version": "1.5.4", | ||
"description": "A delightful, performance-focused Redis client for Node and io.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -787,4 +787,4 @@ 'use strict'; | ||
var cluster = new Redis.Cluster([ | ||
{ host: '127.0.0.1', port: '30001'}], | ||
var cluster = new Redis.Cluster( | ||
[{ host: '127.0.0.1', port: '30001'}], | ||
{ readOnly: true } | ||
@@ -801,2 +801,78 @@ ); | ||
describe('#masterNodes', function () { | ||
it('should contains master nodes', function (done) { | ||
var slotTable = [ | ||
[0, 5460, ['127.0.0.1', 30001], ['127.0.0.1', 30003]], | ||
[5461, 10922, ['127.0.0.1', 30002]] | ||
]; | ||
var node1 = new MockServer(30001, function (argv) { | ||
if (argv[0] === 'cluster' && argv[1] === 'slots') { | ||
return slotTable; | ||
} | ||
}); | ||
var node2 = new MockServer(30002, function (argv) { | ||
if (argv[0] === 'cluster' && argv[1] === 'slots') { | ||
return slotTable; | ||
} | ||
}); | ||
var node3 = new MockServer(30003, function (argv) { | ||
if (argv[0] === 'cluster' && argv[1] === 'slots') { | ||
return slotTable; | ||
} | ||
}); | ||
var cluster = new Redis.Cluster([{ host: '127.0.0.1', port: '30001'}]); | ||
cluster.on('ready', function() { | ||
cluster.nodes['127.0.0.1:30001'].on('end', function () { | ||
expect(Object.keys(cluster.masterNodes).length).to.eql(1); | ||
cluster.disconnect(); | ||
disconnect([node1, node2, node3], done); | ||
}); | ||
disconnect([node1]); | ||
}); | ||
}); | ||
}); | ||
describe('#getInfoFromNode', function () { | ||
it('should refresh master nodes', function (done) { | ||
var slotTable = [ | ||
[0, 5460, ['127.0.0.1', 30001], ['127.0.0.1', 30003]], | ||
[5461, 10922, ['127.0.0.1', 30002]] | ||
]; | ||
var node1 = new MockServer(30001, function (argv) { | ||
if (argv[0] === 'cluster' && argv[1] === 'slots') { | ||
return slotTable; | ||
} | ||
}); | ||
var node2 = new MockServer(30002, function (argv) { | ||
if (argv[0] === 'cluster' && argv[1] === 'slots') { | ||
return slotTable; | ||
} | ||
}); | ||
var node3 = new MockServer(30003, function (argv) { | ||
if (argv[0] === 'cluster' && argv[1] === 'slots') { | ||
return slotTable; | ||
} | ||
}); | ||
var cluster = new Redis.Cluster([{ host: '127.0.0.1', port: '30001'}]); | ||
cluster.on('ready', function() { | ||
expect(Object.keys(cluster.masterNodes).length).to.eql(2); | ||
slotTable = [ | ||
[0, 5460, ['127.0.0.1', 30003]], | ||
[5461, 10922, ['127.0.0.1', 30002]] | ||
]; | ||
cluster.refreshSlotsCache(function () { | ||
expect(Object.keys(cluster.masterNodes).length).to.eql(2); | ||
expect(cluster.masterNodes).to.have.property('127.0.0.1:30003'); | ||
expect(cluster.masterNodes).to.have.property('127.0.0.1:30002'); | ||
disconnect([node1, node2, node3], done); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -813,3 +889,3 @@ | ||
function check () { | ||
if (!--pending) { | ||
if (!--pending && callback) { | ||
callback(); | ||
@@ -816,0 +892,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
274227
7293