You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
fix(sentinel): Migrated to the new testing framework, fixed issues that were discovered during transition
* [CAE-342] Fix a couple of bugs * Fixed issue with nodes masterauth persistency, changed docker container * [CAE-342] Fixed a couple of sentinel issues, enabled most tests * [CAE-342] Added comment * [CAE-342] Migrate majority of tests to testUtils * [CAE-342] Minor refactor * . * [CAE-342] Using cae containers for sentinel * [CAE-342] Improved resiliency of the legacy tests, added TSdoc comment * [CAE-342] Some extra logging, removed unneeded changes * [CAE-342] Moved docker env as optional part of redisserverdockerconfig * [CAE-342] Move password to serverArguments * [CAE-342] Moved ts-node to devDependencies * [CAE-342] Reverted legacy testing framework improvements
This commit is contained in:
@@ -2,9 +2,10 @@ import TestUtils from '@redis/test-utils';
|
||||
import { SinonSpy } from 'sinon';
|
||||
import { setTimeout } from 'node:timers/promises';
|
||||
import { CredentialsProvider } from './authx';
|
||||
import { Command } from './RESP/types';
|
||||
import { BasicCommandParser } from './client/parser';
|
||||
|
||||
import { Command, NumberReply } from './RESP/types';
|
||||
import { BasicCommandParser, CommandParser } from './client/parser';
|
||||
import { defineScript } from './lua-script';
|
||||
import RedisBloomModules from '@redis/bloom';
|
||||
const utils = TestUtils.createFromConfig({
|
||||
dockerImageName: 'redislabs/client-libs-test',
|
||||
dockerImageVersionArgument: 'redis-version',
|
||||
@@ -42,6 +43,45 @@ const streamingCredentialsProvider: CredentialsProvider =
|
||||
|
||||
} as const;
|
||||
|
||||
const SQUARE_SCRIPT = defineScript({
|
||||
SCRIPT:
|
||||
`local number = redis.call('GET', KEYS[1])
|
||||
return number * number`,
|
||||
NUMBER_OF_KEYS: 1,
|
||||
FIRST_KEY_INDEX: 0,
|
||||
parseCommand(parser: CommandParser, key: string) {
|
||||
parser.pushKey(key);
|
||||
},
|
||||
transformReply: undefined as unknown as () => NumberReply
|
||||
});
|
||||
|
||||
export const MATH_FUNCTION = {
|
||||
name: 'math',
|
||||
engine: 'LUA',
|
||||
code:
|
||||
`#!LUA name=math
|
||||
redis.register_function {
|
||||
function_name = "square",
|
||||
callback = function(keys, args)
|
||||
local number = redis.call('GET', keys[1])
|
||||
return number * number
|
||||
end,
|
||||
flags = { "no-writes" }
|
||||
}`,
|
||||
library: {
|
||||
square: {
|
||||
NAME: 'square',
|
||||
IS_READ_ONLY: true,
|
||||
NUMBER_OF_KEYS: 1,
|
||||
FIRST_KEY_INDEX: 0,
|
||||
parseCommand(parser: CommandParser, key: string) {
|
||||
parser.pushKey(key);
|
||||
},
|
||||
transformReply: undefined as unknown as () => NumberReply
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const GLOBAL = {
|
||||
SERVERS: {
|
||||
OPEN: {
|
||||
@@ -86,6 +126,43 @@ export const GLOBAL = {
|
||||
useReplicas: true
|
||||
}
|
||||
}
|
||||
},
|
||||
SENTINEL: {
|
||||
OPEN: {
|
||||
serverArguments: [...DEBUG_MODE_ARGS],
|
||||
},
|
||||
PASSWORD: {
|
||||
serverArguments: ['--requirepass', 'test_password', ...DEBUG_MODE_ARGS],
|
||||
},
|
||||
WITH_SCRIPT: {
|
||||
serverArguments: [...DEBUG_MODE_ARGS],
|
||||
scripts: {
|
||||
square: SQUARE_SCRIPT,
|
||||
},
|
||||
},
|
||||
WITH_FUNCTION: {
|
||||
serverArguments: [...DEBUG_MODE_ARGS],
|
||||
functions: {
|
||||
math: MATH_FUNCTION.library,
|
||||
},
|
||||
},
|
||||
WITH_MODULE: {
|
||||
serverArguments: [...DEBUG_MODE_ARGS],
|
||||
modules: RedisBloomModules,
|
||||
},
|
||||
WITH_REPLICA_POOL_SIZE_1: {
|
||||
serverArguments: [...DEBUG_MODE_ARGS],
|
||||
replicaPoolSize: 1,
|
||||
},
|
||||
WITH_RESERVE_CLIENT_MASTER_POOL_SIZE_2: {
|
||||
serverArguments: [...DEBUG_MODE_ARGS],
|
||||
masterPoolSize: 2,
|
||||
reserveClient: true,
|
||||
},
|
||||
WITH_MASTER_POOL_SIZE_2: {
|
||||
serverArguments: [...DEBUG_MODE_ARGS],
|
||||
masterPoolSize: 2,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user