You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-10 11:43:01 +03:00
tests: fix CI failures
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -7,3 +7,10 @@ coverage
|
|||||||
stunnel.conf
|
stunnel.conf
|
||||||
stunnel.pid
|
stunnel.pid
|
||||||
*.out
|
*.out
|
||||||
|
package-lock.json
|
||||||
|
|
||||||
|
# IntelliJ IDEs
|
||||||
|
.idea
|
||||||
|
# VisualStudioCode IDEs
|
||||||
|
.vscode
|
||||||
|
.vs
|
||||||
|
14
.travis.yml
14
.travis.yml
@@ -9,12 +9,22 @@ addons:
|
|||||||
packages:
|
packages:
|
||||||
- g++-4.8
|
- g++-4.8
|
||||||
node_js:
|
node_js:
|
||||||
- "0.10"
|
|
||||||
- "0.12"
|
|
||||||
- "4"
|
- "4"
|
||||||
- "6"
|
- "6"
|
||||||
- "8"
|
- "8"
|
||||||
- "12"
|
- "12"
|
||||||
|
- "13"
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- if [[ ! -f stunnel.tar.gz ]]; then wget -O stunnel.tar.gz ftp://ftp.stunnel.org/stunnel/archive/5.x/stunnel-5.54.tar.gz; fi
|
||||||
|
- if [[ ! -f ./stunnel-5.54/configure ]]; then tar -xzf stunnel.tar.gz; fi
|
||||||
|
- if [[ ! -f ./stunnel-5.54/src/stunnel ]]; then cd ./stunnel-5.54; ./configure; make; cd ..; fi
|
||||||
|
- export PATH="$PATH:$(pwd)/stunnel-5.54/src"
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- '$TRAVIS_BUILD_DIR/stunnel-5.54'
|
||||||
|
|
||||||
after_success: npm run coveralls
|
after_success: npm run coveralls
|
||||||
before_script:
|
before_script:
|
||||||
# Add an IPv6 config - see the corresponding Travis issue
|
# Add an IPv6 config - see the corresponding Travis issue
|
||||||
|
@@ -3,12 +3,12 @@
|
|||||||
# Test against these versions of Node.js.
|
# Test against these versions of Node.js.
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- nodejs_version: "0.10"
|
|
||||||
- nodejs_version: "0.12"
|
|
||||||
- nodejs_version: "4"
|
- nodejs_version: "4"
|
||||||
- nodejs_version: "6"
|
- nodejs_version: "6"
|
||||||
- nodejs_version: "8"
|
- nodejs_version: "8"
|
||||||
- nodejs_version: "12"
|
- nodejs_version: "10"
|
||||||
|
# - nodejs_version: "12"
|
||||||
|
# - nodejs_version: "13"
|
||||||
|
|
||||||
pull_requests:
|
pull_requests:
|
||||||
do_not_increment_build_number: true
|
do_not_increment_build_number: true
|
||||||
|
13
index.js
13
index.js
@@ -20,11 +20,6 @@ var SUBSCRIBE_COMMANDS = {
|
|||||||
punsubscribe: true
|
punsubscribe: true
|
||||||
};
|
};
|
||||||
|
|
||||||
// Newer Node.js versions > 0.10 return the EventEmitter right away and using .EventEmitter was deprecated
|
|
||||||
if (typeof EventEmitter !== 'function') {
|
|
||||||
EventEmitter = EventEmitter.EventEmitter;
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop () {}
|
function noop () {}
|
||||||
|
|
||||||
function handle_detect_buffers_reply (reply, command, buffer_args) {
|
function handle_detect_buffers_reply (reply, command, buffer_args) {
|
||||||
@@ -153,7 +148,6 @@ function RedisClient (options, stream) {
|
|||||||
this.server_info = {};
|
this.server_info = {};
|
||||||
this.auth_pass = options.auth_pass || options.password;
|
this.auth_pass = options.auth_pass || options.password;
|
||||||
this.selected_db = options.db; // Save the selected db here, used when reconnecting
|
this.selected_db = options.db; // Save the selected db here, used when reconnecting
|
||||||
this.old_state = null;
|
|
||||||
this.fire_strings = true; // Determine if strings or buffers should be written to the stream
|
this.fire_strings = true; // Determine if strings or buffers should be written to the stream
|
||||||
this.pipeline = false;
|
this.pipeline = false;
|
||||||
this.sub_commands_left = 0;
|
this.sub_commands_left = 0;
|
||||||
@@ -175,12 +169,6 @@ function RedisClient (options, stream) {
|
|||||||
'If you want to keep on listening to this event please listen to the stream drain event directly.'
|
'If you want to keep on listening to this event please listen to the stream drain event directly.'
|
||||||
);
|
);
|
||||||
} else if ((event === 'message_buffer' || event === 'pmessage_buffer' || event === 'messageBuffer' || event === 'pmessageBuffer') && !this.buffers && !this.message_buffers) {
|
} else if ((event === 'message_buffer' || event === 'pmessage_buffer' || event === 'messageBuffer' || event === 'pmessageBuffer') && !this.buffers && !this.message_buffers) {
|
||||||
if (this.reply_parser.name !== 'javascript') {
|
|
||||||
return this.warn(
|
|
||||||
'You attached the "' + event + '" listener without the returnBuffers option set to true.\n' +
|
|
||||||
'Please use the JavaScript parser or set the returnBuffers option to true to return buffers.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
this.reply_parser.optionReturnBuffers = true;
|
this.reply_parser.optionReturnBuffers = true;
|
||||||
this.message_buffers = true;
|
this.message_buffers = true;
|
||||||
this.handle_reply = handle_detect_buffers_reply;
|
this.handle_reply = handle_detect_buffers_reply;
|
||||||
@@ -216,7 +204,6 @@ function create_parser (self) {
|
|||||||
self.create_stream();
|
self.create_stream();
|
||||||
},
|
},
|
||||||
returnBuffers: self.buffers || self.message_buffers,
|
returnBuffers: self.buffers || self.message_buffers,
|
||||||
name: self.options.parser || 'javascript',
|
|
||||||
stringNumbers: self.options.string_numbers || false
|
stringNumbers: self.options.string_numbers || false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -4,18 +4,6 @@ var commands = require('redis-commands');
|
|||||||
var Multi = require('./multi');
|
var Multi = require('./multi');
|
||||||
var RedisClient = require('../').RedisClient;
|
var RedisClient = require('../').RedisClient;
|
||||||
var Command = require('./command');
|
var Command = require('./command');
|
||||||
// Feature detect if a function may change it's name
|
|
||||||
var changeFunctionName = (function () {
|
|
||||||
var fn = function abc () {};
|
|
||||||
try {
|
|
||||||
Object.defineProperty(fn, 'name', {
|
|
||||||
value: 'foobar'
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}());
|
|
||||||
|
|
||||||
var addCommand = function (command) {
|
var addCommand = function (command) {
|
||||||
// Some rare Redis commands use special characters in their command name
|
// Some rare Redis commands use special characters in their command name
|
||||||
@@ -61,11 +49,9 @@ var addCommand = function (command) {
|
|||||||
if (commandName !== command) {
|
if (commandName !== command) {
|
||||||
RedisClient.prototype[commandName.toUpperCase()] = RedisClient.prototype[commandName] = RedisClient.prototype[command];
|
RedisClient.prototype[commandName.toUpperCase()] = RedisClient.prototype[commandName] = RedisClient.prototype[command];
|
||||||
}
|
}
|
||||||
if (changeFunctionName) {
|
Object.defineProperty(RedisClient.prototype[command], 'name', {
|
||||||
Object.defineProperty(RedisClient.prototype[command], 'name', {
|
value: commandName
|
||||||
value: commandName
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not override existing functions
|
// Do not override existing functions
|
||||||
@@ -108,11 +94,9 @@ var addCommand = function (command) {
|
|||||||
if (commandName !== command) {
|
if (commandName !== command) {
|
||||||
Multi.prototype[commandName.toUpperCase()] = Multi.prototype[commandName] = Multi.prototype[command];
|
Multi.prototype[commandName.toUpperCase()] = Multi.prototype[commandName] = Multi.prototype[command];
|
||||||
}
|
}
|
||||||
if (changeFunctionName) {
|
Object.defineProperty(Multi.prototype[command], 'name', {
|
||||||
Object.defineProperty(Multi.prototype[command], 'name', {
|
value: commandName
|
||||||
value: commandName
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -25,13 +25,13 @@
|
|||||||
"compare": "node benchmarks/diff_multi_bench_output.js beforeBench.txt afterBench.txt"
|
"compare": "node benchmarks/diff_multi_bench_output.js beforeBench.txt afterBench.txt"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"denque": "^1.2.3",
|
"denque": "^1.4.1",
|
||||||
"redis-commands": "^1.5.0",
|
"redis-commands": "^1.5.0",
|
||||||
"redis-errors": "^1.2.0",
|
"redis-errors": "^1.2.0",
|
||||||
"redis-parser": "^3.0.0"
|
"redis-parser": "^3.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=4.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bluebird": "^3.0.2",
|
"bluebird": "^3.0.2",
|
||||||
|
@@ -401,10 +401,22 @@ describe('connection tests', function () {
|
|||||||
connect_timeout: 1000
|
connect_timeout: 1000
|
||||||
});
|
});
|
||||||
process.nextTick(function () {
|
process.nextTick(function () {
|
||||||
assert.strictEqual(client.stream._idleTimeout, 1000);
|
// node > 4
|
||||||
|
var timeout = client.stream.timeout;
|
||||||
|
// node <= 4
|
||||||
|
if (timeout === undefined) timeout = client.stream._idleTimeout;
|
||||||
|
assert.strictEqual(timeout, 1000);
|
||||||
});
|
});
|
||||||
client.on('connect', function () {
|
client.on('connect', function () {
|
||||||
assert.strictEqual(client.stream._idleTimeout, -1);
|
// node > 4
|
||||||
|
var expected = 0;
|
||||||
|
var timeout = client.stream.timeout;
|
||||||
|
// node <= 4
|
||||||
|
if (timeout === undefined) {
|
||||||
|
timeout = client.stream._idleTimeout;
|
||||||
|
expected = -1;
|
||||||
|
}
|
||||||
|
assert.strictEqual(timeout, expected);
|
||||||
assert.strictEqual(client.stream.listeners('timeout').length, 0);
|
assert.strictEqual(client.stream.listeners('timeout').length, 0);
|
||||||
client.on('ready', done);
|
client.on('ready', done);
|
||||||
});
|
});
|
||||||
|
@@ -163,11 +163,6 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
var parsers = ['javascript'];
|
var parsers = ['javascript'];
|
||||||
var protocols = ['IPv4'];
|
var protocols = ['IPv4'];
|
||||||
// The js parser works the same as the hiredis parser, just activate this if you want to be on the safe side
|
|
||||||
// try {
|
|
||||||
// require('hiredis');
|
|
||||||
// parsers.push('hiredis');
|
|
||||||
// } catch (e) {/* ignore eslint */}
|
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') {
|
||||||
protocols.push('IPv6', '/tmp/redis.sock');
|
protocols.push('IPv6', '/tmp/redis.sock');
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
var util = require('util');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var intercept = require('intercept-stdout');
|
var intercept = require('intercept-stdout');
|
||||||
var config = require('./lib/config');
|
var config = require('./lib/config');
|
||||||
@@ -359,7 +360,11 @@ describe('The node_redis client', function () {
|
|||||||
|
|
||||||
it('send_command with callback as args', function (done) {
|
it('send_command with callback as args', function (done) {
|
||||||
client.send_command('abcdef', function (err, res) {
|
client.send_command('abcdef', function (err, res) {
|
||||||
assert.strictEqual(err.message, 'ERR unknown command `abcdef`, with args beginning with: ');
|
if (process.platform === 'win32') {
|
||||||
|
assert.strictEqual(err.message, 'ERR unknown command `abcdef`');
|
||||||
|
} else {
|
||||||
|
assert.strictEqual(err.message, 'ERR unknown command `abcdef`, with args beginning with: ');
|
||||||
|
}
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -675,15 +680,21 @@ describe('The node_redis client', function () {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
require('domain').create();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('catches all errors from within the domain', function (done) {
|
it('catches all errors from within the domain', function (done) {
|
||||||
var domain = require('domain').create();
|
var domain = require('domain').create();
|
||||||
|
|
||||||
domain.run(function () {
|
domain.run(function () {
|
||||||
// Trigger an error within the domain
|
if (process.versions.node.split('.')[0] >= 13) {
|
||||||
|
// Node >= 13
|
||||||
|
// Recreate client in domain so error handlers run this domain
|
||||||
|
// Changed in: "error handler runs outside of its domain"
|
||||||
|
// https://github.com/nodejs/node/pull/26211
|
||||||
|
client = redis.createClient();
|
||||||
|
}
|
||||||
client.end(true);
|
client.end(true);
|
||||||
|
// Trigger an error within the domain
|
||||||
client.set('domain', 'value');
|
client.set('domain', 'value');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -986,7 +997,14 @@ describe('The node_redis client', function () {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert.equal(err.code, 'ECONNREFUSED');
|
assert.equal(err.code, 'ECONNREFUSED');
|
||||||
assert.equal(err.errno, 'ECONNREFUSED');
|
|
||||||
|
if (typeof err.errno === 'number') {
|
||||||
|
// >= Node 13
|
||||||
|
assert.equal(util.getSystemErrorName(err.errno), 'ECONNREFUSED');
|
||||||
|
} else {
|
||||||
|
// < Node 13
|
||||||
|
assert.equal(err.errno, 'ECONNREFUSED');
|
||||||
|
}
|
||||||
assert.equal(err.syscall, 'connect');
|
assert.equal(err.syscall, 'connect');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1046,7 +1064,13 @@ describe('The node_redis client', function () {
|
|||||||
end();
|
end();
|
||||||
} else {
|
} else {
|
||||||
assert.equal(err.code, 'ECONNREFUSED');
|
assert.equal(err.code, 'ECONNREFUSED');
|
||||||
assert.equal(err.errno, 'ECONNREFUSED');
|
if (typeof err.errno === 'number') {
|
||||||
|
// >= Node 13
|
||||||
|
assert.equal(util.getSystemErrorName(err.errno), 'ECONNREFUSED');
|
||||||
|
} else {
|
||||||
|
// < Node 13
|
||||||
|
assert.equal(err.errno, 'ECONNREFUSED');
|
||||||
|
}
|
||||||
assert.equal(err.syscall, 'connect');
|
assert.equal(err.syscall, 'connect');
|
||||||
end();
|
end();
|
||||||
}
|
}
|
||||||
@@ -1132,7 +1156,13 @@ describe('The node_redis client', function () {
|
|||||||
end();
|
end();
|
||||||
} else {
|
} else {
|
||||||
assert.equal(err.code, 'ECONNREFUSED');
|
assert.equal(err.code, 'ECONNREFUSED');
|
||||||
assert.equal(err.errno, 'ECONNREFUSED');
|
if (typeof err.errno === 'number') {
|
||||||
|
// >= Node 13
|
||||||
|
assert.equal(util.getSystemErrorName(err.errno), 'ECONNREFUSED');
|
||||||
|
} else {
|
||||||
|
// < Node 13
|
||||||
|
assert.equal(err.errno, 'ECONNREFUSED');
|
||||||
|
}
|
||||||
assert.equal(err.syscall, 'connect');
|
assert.equal(err.syscall, 'connect');
|
||||||
redis.debug_mode = false;
|
redis.debug_mode = false;
|
||||||
client.end(true);
|
client.end(true);
|
||||||
|
@@ -515,8 +515,8 @@ describe('publish/subscribe', function () {
|
|||||||
sub.stream.once('data', function () {
|
sub.stream.once('data', function () {
|
||||||
assert.strictEqual(sub.message_buffers, false);
|
assert.strictEqual(sub.message_buffers, false);
|
||||||
assert.strictEqual(sub.shouldBuffer, false);
|
assert.strictEqual(sub.shouldBuffer, false);
|
||||||
sub.on('pmessageBuffer', function (pattern, channel, message) {
|
sub.on('pmessageBuffer', function (pattern, channel) {
|
||||||
if (parser !== 'javascript' && typeof pattern === 'string') {
|
if (typeof pattern === 'string') {
|
||||||
pattern = new Buffer(pattern);
|
pattern = new Buffer(pattern);
|
||||||
channel = new Buffer(channel);
|
channel = new Buffer(channel);
|
||||||
}
|
}
|
||||||
@@ -524,10 +524,8 @@ describe('publish/subscribe', function () {
|
|||||||
assert.strictEqual(channel.inspect(), new Buffer('/foo').inspect());
|
assert.strictEqual(channel.inspect(), new Buffer('/foo').inspect());
|
||||||
sub.quit(end);
|
sub.quit(end);
|
||||||
});
|
});
|
||||||
if (parser === 'javascript') {
|
// Either message_buffers or buffers has to be true, but not both at the same time
|
||||||
assert.notStrictEqual(sub.message_buffers, sub.buffers);
|
assert.notStrictEqual(sub.message_buffers, sub.buffers);
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
var batch = sub.batch();
|
var batch = sub.batch();
|
||||||
batch.psubscribe('*');
|
batch.psubscribe('*');
|
||||||
|
@@ -19,9 +19,6 @@ var tls_port = 6380;
|
|||||||
// Use skip instead of returning to indicate what tests really got skipped
|
// Use skip instead of returning to indicate what tests really got skipped
|
||||||
var skip = false;
|
var skip = false;
|
||||||
|
|
||||||
// Wait until stunnel4 is in the travis whitelist
|
|
||||||
// Check: https://github.com/travis-ci/apt-package-whitelist/issues/403
|
|
||||||
// If this is merged, remove the travis env checks
|
|
||||||
describe('TLS connection tests', function () {
|
describe('TLS connection tests', function () {
|
||||||
|
|
||||||
before(function (done) {
|
before(function (done) {
|
||||||
@@ -29,9 +26,6 @@ describe('TLS connection tests', function () {
|
|||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
skip = true;
|
skip = true;
|
||||||
console.warn('\nStunnel tests do not work on windows atm. If you think you can fix that, it would be warmly welcome.\n');
|
console.warn('\nStunnel tests do not work on windows atm. If you think you can fix that, it would be warmly welcome.\n');
|
||||||
} else if (process.env.TRAVIS === 'true') {
|
|
||||||
skip = true;
|
|
||||||
console.warn('\nTravis does not support stunnel right now. Skipping tests.\nCheck: https://github.com/travis-ci/apt-package-whitelist/issues/403\n');
|
|
||||||
}
|
}
|
||||||
if (skip) return done();
|
if (skip) return done();
|
||||||
helper.stopStunnel(function () {
|
helper.stopStunnel(function () {
|
||||||
@@ -58,7 +52,7 @@ describe('TLS connection tests', function () {
|
|||||||
client = redis.createClient({
|
client = redis.createClient({
|
||||||
connect_timeout: connect_timeout,
|
connect_timeout: connect_timeout,
|
||||||
port: tls_port,
|
port: tls_port,
|
||||||
tls: tls_options
|
tls: utils.clone(tls_options)
|
||||||
});
|
});
|
||||||
var time = 0;
|
var time = 0;
|
||||||
assert.strictEqual(client.address, '127.0.0.1:' + tls_port);
|
assert.strictEqual(client.address, '127.0.0.1:' + tls_port);
|
||||||
@@ -109,12 +103,14 @@ describe('TLS connection tests', function () {
|
|||||||
client.get('foo', helper.isString('bar', done));
|
client.get('foo', helper.isString('bar', done));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('using rediss as url protocol', function (done) {
|
describe('using rediss as url protocol', function () {
|
||||||
var tls_connect = tls.connect;
|
var tls_connect = tls.connect;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
tls.connect = function (options) {
|
tls.connect = function (options) {
|
||||||
options = utils.clone(options);
|
options = utils.clone(options);
|
||||||
options.ca = tls_options.ca;
|
options.ca = tls_options.ca;
|
||||||
|
options.servername = 'redis.js.org';
|
||||||
|
options.rejectUnauthorized = true;
|
||||||
return tls_connect.call(tls, options);
|
return tls_connect.call(tls, options);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user