Created
September 18, 2012 10:26
-
-
Save d3m3vilurr/3742487 to your computer and use it in GitHub Desktop.
node_redis mset broken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ node mset_test.js | |
Connected to 127.0.0.1:6379, Redis server version 2.5.12 | |
Using reply parser faster | |
- mget_2:Uncaught exception: AssertionError: MGET_2 | |
at tests.MGET_2 (/home/sulee/works/repos/node_redis/mset_test.js:41:16) | |
at try_callback (/home/sulee/works/repos/node_redis/index.js:520:9) | |
at RedisClient.return_reply (/home/sulee/works/repos/node_redis/index.js:590:13) | |
at ReplyParser.RedisClient.init_parser (/home/sulee/works/repos/node_redis/index.js:263:14) | |
at ReplyParser.EventEmitter.emit (events.js:88:17) | |
at ReplyParser.send_reply (/home/sulee/works/repos/node_redis/lib/parser/javascript.js:283:10) | |
at ReplyParser.execute (/home/sulee/works/repos/node_redis/lib/parser/javascript.js:197:22) | |
at RedisClient.on_data (/home/sulee/works/repos/node_redis/index.js:476:27) | |
at Socket.<anonymous> (/home/sulee/works/repos/node_redis/index.js:79:14) | |
at Socket.EventEmitter.emit (events.js:88:17) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global require console setTimeout process Buffer */ | |
var redis = require("./index"), | |
client = redis.createClient(), | |
assert = require("assert"), | |
crypto = require("crypto"), | |
util = require("./lib/util"), | |
test_db_num = 15, // this DB will be flushed and used for testing | |
tests = {}, | |
connected = false, | |
ended = false, | |
next, cur_start, run_next_test, all_tests, all_start, test_count; | |
// Set this to truthy to see the wire protocol and other debugging info | |
redis.debug_mode = process.argv[2]; | |
function require_string(str, label) { | |
return function (err, results) { | |
assert.strictEqual(null, err, label + " expected string '" + str + "', got error: " + err); | |
assert.equal(str, results, label + " " + str + " does not match " + results); | |
return true; | |
}; | |
} | |
next = function next(name) { | |
console.log(" \x1b[33m" + (Date.now() - cur_start) + "\x1b[0m ms"); | |
run_next_test(); | |
}; | |
// Tests are run in the order they are defined. So FLUSHDB should be stay first. | |
tests.MGET_2 = function() { | |
var name = "MGET_2"; | |
var bigstring1 = Array(48 * 1024 + 1).join('-'); // 48KB data | |
var bigstring2 = Array(49 * 1024 + 1).join('-'); // 49KB data | |
client.mset(["mget_2 keys 1", bigstring1, "mget_2 keys 2", bigstring2], require_string("OK", name)); | |
client.MGET("mget_2 keys 1", "mget_2 keys 2", function (err, results) { | |
assert.strictEqual(null, err, "result sent back unexpected error: " + err); | |
assert.strictEqual(2, results.length, name); | |
assert.notStrictEqual(null, results[0], name); | |
assert.strictEqual(bigstring1, results[0], name); | |
assert.notStrictEqual(null, results[1], name); | |
assert.strictEqual(bigstring2, results[1], name); | |
next(name); | |
}); | |
}; | |
all_tests = Object.keys(tests); | |
all_start = new Date(); | |
test_count = 0; | |
run_next_test = function run_next_test() { | |
var test_name = all_tests.shift(); | |
if (typeof tests[test_name] === "function") { | |
util.print('- \x1b[1m' + test_name.toLowerCase() + '\x1b[0m:'); | |
cur_start = new Date(); | |
test_count += 1; | |
tests[test_name](); | |
} else { | |
console.log('\n completed \x1b[32m%d\x1b[0m tests in \x1b[33m%d\x1b[0m ms\n', test_count, new Date() - all_start); | |
client.quit(); | |
} | |
}; | |
client.once("ready", function start_tests() { | |
console.log("Connected to " + client.host + ":" + client.port + ", Redis server version " + client.server_info.redis_version + "\n"); | |
console.log("Using reply parser " + client.reply_parser.name); | |
run_next_test(); | |
connected = true; | |
}); | |
// Exit immediately on connection failure, which triggers "exit", below, which fails the test | |
client.on("error", function (err) { | |
console.error("client: " + err.stack); | |
process.exit(); | |
}); | |
client.on("reconnecting", function (params) { | |
console.log("reconnecting: " + util.inspect(params)); | |
}); | |
process.on('uncaughtException', function (err) { | |
console.error("Uncaught exception: " + err.stack); | |
process.exit(1); | |
}); | |
process.on('exit', function (code) { | |
assert.equal(true, connected); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment