Skip to content

Commit f75b38a

Browse files
author
Ruben Bridgewater
committed
Make windows tests more robust
1 parent d858bd8 commit f75b38a

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

test/connection.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ describe("connection tests", function () {
211211
describe("when not connected", function () {
212212

213213
it("emit an error after the socket timeout exceeded the connect_timeout time", function (done) {
214-
var connect_timeout = 1000; // in ms
214+
var connect_timeout = 500; // in ms
215215
var time = Date.now();
216216
client = redis.createClient({
217217
parser: parser,
@@ -232,8 +232,9 @@ describe("connection tests", function () {
232232
client.on('error', function(err) {
233233
assert(/Redis connection in broken state: connection timeout.*?exceeded./.test(err.message));
234234
// The code execution on windows is very slow at times
235+
var add = process.platform !== 'win32' ? 25 : 125;
235236
var now = Date.now();
236-
assert(now - time < connect_timeout + 50, 'The real timeout time should be below ' + (connect_timeout + 50) + 'ms but is: ' + (now - time));
237+
assert(now - time < connect_timeout + add, 'The real timeout time should be below ' + (connect_timeout + add) + 'ms but is: ' + (now - time));
237238
// Timers sometimes trigger early (e.g. 1ms to early)
238239
assert(now - time >= connect_timeout - 3, 'The real timeout time should be above ' + connect_timeout + 'ms, but it is: ' + (now - time));
239240
done();

test/multi.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe("The 'multi' method", function () {
7373
describe('pipeline limit', function () {
7474

7575
it('do not exceed maximum string size', function (done) {
76-
this.timeout(25000); // Windows tests are horribly slow
76+
this.timeout(30000); // Windows tests are horribly slow
7777
// Triggers a RangeError: Invalid string length if not handled properly
7878
client = redis.createClient();
7979
var multi = client.multi();

test/node_redis.spec.js

+13-16
Original file line numberDiff line numberDiff line change
@@ -569,28 +569,25 @@ describe("The node_redis client", function () {
569569
});
570570

571571
describe('retry_max_delay', function () {
572-
var args = config.configureClient(parser, ip, {
573-
retry_max_delay: 1 // ms
574-
});
575-
576572
it("sets upper bound on how long client waits before reconnecting", function (done) {
577-
var time = new Date().getTime();
578-
var reconnecting = false;
573+
var time;
574+
var timeout = process.platform !== 'win32' ? 20 : 100;
579575

580-
client = redis.createClient.apply(redis.createClient, args);
576+
client = redis.createClient.apply(null, config.configureClient(parser, ip, {
577+
retry_max_delay: 1 // ms
578+
}));
581579
client.on('ready', function() {
582-
if (!reconnecting) {
583-
reconnecting = true;
584-
client.retry_delay = 1000;
585-
client.retry_backoff = 1;
586-
client.stream.end();
580+
if (this.times_connected === 1) {
581+
this.stream.end();
582+
time = Date.now();
587583
} else {
588-
client.end(true);
589-
var lasted = new Date().getTime() - time;
590-
assert.ok(lasted < 100);
591-
return done();
584+
done();
592585
}
593586
});
587+
client.on('reconnecting', function () {
588+
time = Date.now() - time;
589+
assert(time < timeout, 'The reconnect should not have taken longer than ' + timeout + ' but it took ' + time);
590+
});
594591
client.on('error', function (err) {
595592
// This is rare but it might be triggered.
596593
// So let's have a robust test

0 commit comments

Comments
 (0)