diff --git a/test/connection.spec.js b/test/connection.spec.js index 59fc8213cf..65bcd0b6c8 100644 --- a/test/connection.spec.js +++ b/test/connection.spec.js @@ -211,7 +211,7 @@ describe("connection tests", function () { describe("when not connected", function () { it("emit an error after the socket timeout exceeded the connect_timeout time", function (done) { - var connect_timeout = 1000; // in ms + var connect_timeout = 500; // in ms var time = Date.now(); client = redis.createClient({ parser: parser, @@ -232,8 +232,9 @@ describe("connection tests", function () { client.on('error', function(err) { assert(/Redis connection in broken state: connection timeout.*?exceeded./.test(err.message)); // The code execution on windows is very slow at times + var add = process.platform !== 'win32' ? 25 : 125; var now = Date.now(); - assert(now - time < connect_timeout + 50, 'The real timeout time should be below ' + (connect_timeout + 50) + 'ms but is: ' + (now - time)); + assert(now - time < connect_timeout + add, 'The real timeout time should be below ' + (connect_timeout + add) + 'ms but is: ' + (now - time)); // Timers sometimes trigger early (e.g. 1ms to early) assert(now - time >= connect_timeout - 3, 'The real timeout time should be above ' + connect_timeout + 'ms, but it is: ' + (now - time)); done(); diff --git a/test/multi.spec.js b/test/multi.spec.js index bd6f498abe..849071a723 100644 --- a/test/multi.spec.js +++ b/test/multi.spec.js @@ -73,7 +73,7 @@ describe("The 'multi' method", function () { describe('pipeline limit', function () { it('do not exceed maximum string size', function (done) { - this.timeout(25000); // Windows tests are horribly slow + this.timeout(30000); // Windows tests are horribly slow // Triggers a RangeError: Invalid string length if not handled properly client = redis.createClient(); var multi = client.multi(); diff --git a/test/node_redis.spec.js b/test/node_redis.spec.js index 5bed67d40b..09d64a8d02 100644 --- a/test/node_redis.spec.js +++ b/test/node_redis.spec.js @@ -569,28 +569,25 @@ describe("The node_redis client", function () { }); describe('retry_max_delay', function () { - var args = config.configureClient(parser, ip, { - retry_max_delay: 1 // ms - }); - it("sets upper bound on how long client waits before reconnecting", function (done) { - var time = new Date().getTime(); - var reconnecting = false; + var time; + var timeout = process.platform !== 'win32' ? 20 : 100; - client = redis.createClient.apply(redis.createClient, args); + client = redis.createClient.apply(null, config.configureClient(parser, ip, { + retry_max_delay: 1 // ms + })); client.on('ready', function() { - if (!reconnecting) { - reconnecting = true; - client.retry_delay = 1000; - client.retry_backoff = 1; - client.stream.end(); + if (this.times_connected === 1) { + this.stream.end(); + time = Date.now(); } else { - client.end(true); - var lasted = new Date().getTime() - time; - assert.ok(lasted < 100); - return done(); + done(); } }); + client.on('reconnecting', function () { + time = Date.now() - time; + assert(time < timeout, 'The reconnect should not have taken longer than ' + timeout + ' but it took ' + time); + }); client.on('error', function (err) { // This is rare but it might be triggered. // So let's have a robust test