You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-12-14 09:42:12 +03:00
test fixup
This commit is contained in:
@@ -1,36 +1,36 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var config = require('./lib/config')
|
||||
var helper = require('./helper')
|
||||
var RedisProcess = require('./lib/redis-process')
|
||||
var rp
|
||||
var path = require('path')
|
||||
var redis = config.redis
|
||||
const assert = require('assert')
|
||||
const config = require('./lib/config')
|
||||
const helper = require('./helper')
|
||||
const RedisProcess = require('./lib/redis-process')
|
||||
let rp
|
||||
const path = require('path')
|
||||
const redis = config.redis
|
||||
|
||||
// TODO: Fix redis process spawn on windows
|
||||
if (process.platform !== 'win32') {
|
||||
describe('master slave sync', function () {
|
||||
var master = null
|
||||
var slave = null
|
||||
describe('master slave sync', () => {
|
||||
let master = null
|
||||
let slave = null
|
||||
|
||||
before(function (done) {
|
||||
helper.stopRedis(function () {
|
||||
before((done) => {
|
||||
helper.stopRedis(() => {
|
||||
helper.startRedis('./conf/password.conf', done)
|
||||
})
|
||||
})
|
||||
|
||||
before(function (done) {
|
||||
before((done) => {
|
||||
if (helper.redisProcess().spawnFailed()) return done()
|
||||
master = redis.createClient({
|
||||
password: 'porkchopsandwiches'
|
||||
})
|
||||
var multi = master.multi()
|
||||
var i = 0
|
||||
const multi = master.multi()
|
||||
let i = 0
|
||||
while (i < 1000) {
|
||||
i++
|
||||
// Write some data in the redis instance, so there's something to sync
|
||||
multi.set('foo' + i, 'bar' + new Array(500).join(Math.random()))
|
||||
multi.set(`foo${i}`, `bar${new Array(500).join(Math.random())}`)
|
||||
}
|
||||
multi.exec(done)
|
||||
})
|
||||
@@ -38,18 +38,18 @@ if (process.platform !== 'win32') {
|
||||
it('sync process and no master should delay ready being emitted for slaves', function (done) {
|
||||
if (helper.redisProcess().spawnFailed()) this.skip()
|
||||
|
||||
var port = 6381
|
||||
var firstInfo
|
||||
const port = 6381
|
||||
let firstInfo
|
||||
slave = redis.createClient({
|
||||
port: port,
|
||||
retryStrategy: function (options) {
|
||||
port,
|
||||
retryStrategy (options) {
|
||||
// Try to reconnect in very small intervals to catch the master_link_status down before the sync completes
|
||||
return 10
|
||||
}
|
||||
})
|
||||
|
||||
var tmp = slave.info.bind(slave)
|
||||
var i = 0
|
||||
const tmp = slave.info.bind(slave)
|
||||
let i = 0
|
||||
slave.info = function (err, res) {
|
||||
i++
|
||||
tmp(err, res)
|
||||
@@ -58,38 +58,38 @@ if (process.platform !== 'win32') {
|
||||
}
|
||||
}
|
||||
|
||||
slave.on('connect', function () {
|
||||
slave.on('connect', () => {
|
||||
assert.strictEqual(i, 0)
|
||||
})
|
||||
|
||||
var end = helper.callFuncAfter(done, 2)
|
||||
const end = helper.callFuncAfter(done, 2)
|
||||
|
||||
slave.on('ready', function () {
|
||||
assert.strictEqual(this.serverInfo.master_link_status, 'up')
|
||||
assert.strictEqual(firstInfo.master_link_status, 'down')
|
||||
assert(i > 1)
|
||||
this.get('foo300', function (err, res) {
|
||||
this.get('foo300', (err, res) => {
|
||||
assert.strictEqual(res.substr(0, 3), 'bar')
|
||||
end(err)
|
||||
})
|
||||
})
|
||||
|
||||
RedisProcess.start(function (err, _rp) {
|
||||
RedisProcess.start((err, _rp) => {
|
||||
rp = _rp
|
||||
end(err)
|
||||
}, path.resolve(__dirname, './conf/slave.conf'), port)
|
||||
})
|
||||
|
||||
after(function (done) {
|
||||
after((done) => {
|
||||
if (helper.redisProcess().spawnFailed()) return done()
|
||||
var end = helper.callFuncAfter(done, 3)
|
||||
const end = helper.callFuncAfter(done, 3)
|
||||
rp.stop(end)
|
||||
slave.end(true)
|
||||
master.flushdb(function (err) {
|
||||
master.flushdb((err) => {
|
||||
end(err)
|
||||
master.end(true)
|
||||
})
|
||||
helper.stopRedis(function () {
|
||||
helper.stopRedis(() => {
|
||||
helper.startRedis('./conf/redis.conf', end)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user