1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

Make windows tests more robust

This commit is contained in:
Ruben Bridgewater
2016-03-14 22:06:42 +01:00
parent d858bd8383
commit f75b38a3e2
3 changed files with 17 additions and 19 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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