1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

Add test and fix keeping the offline queue

Use a new delay after reconnecting
This commit is contained in:
Ruben Bridgewater
2015-09-10 19:19:09 +02:00
parent 3c2ba8c373
commit 55d0036eae
4 changed files with 49 additions and 26 deletions

View File

@@ -688,7 +688,7 @@ describe("The node_redis client", function () {
describe('true', function () {
it("does not return an error and enqueues operation", function (done) {
var client = redis.createClient(9999, null, {
max_attempts: 0,
max_attempts: 1,
parser: parser
});
@@ -710,6 +710,34 @@ describe("The node_redis client", function () {
}, 25);
}, 50);
});
it("enqueues operation and keep the queue while trying to reconnect", function (done) {
var client = redis.createClient(9999, null, {
max_attempts: 4,
parser: parser
});
var i = 0;
client.on('error', function(err) {
if (err.message === 'Redis connection in broken state: maximum connection attempts exceeded.') {
assert(i, 3);
assert.strictEqual(client.offline_queue.length, 0);
done();
}
});
client.on('reconnecting', function(params) {
i++;
assert.equal(params.attempt, i);
assert.strictEqual(client.offline_queue.length, 1);
});
client.set('foo', 'bar', function(err, result) {
assert(i, 3);
assert('Redis connection gone from error event', err.message);
assert.strictEqual(client.offline_queue.length, 0);
});
});
});
describe('false', function () {