(
title: string,
fn: (
cluster: RedisClusterType<M, F, S, RESP, TYPE_MAPPING>,
faultInjectorClient: IFaultInjectorClient
) => unknown,
options: REClusterTestOptions<M, F, S, RESP, TYPE_MAPPING>
)
| 935 | } |
| 936 | |
| 937 | testWithRECluster< |
| 938 | M extends RedisModules = {}, |
| 939 | F extends RedisFunctions = {}, |
| 940 | S extends RedisScripts = {}, |
| 941 | RESP extends RespVersions = 2, |
| 942 | TYPE_MAPPING extends TypeMapping = {} |
| 943 | >( |
| 944 | title: string, |
| 945 | fn: ( |
| 946 | cluster: RedisClusterType<M, F, S, RESP, TYPE_MAPPING>, |
| 947 | faultInjectorClient: IFaultInjectorClient |
| 948 | ) => unknown, |
| 949 | options: REClusterTestOptions<M, F, S, RESP, TYPE_MAPPING> |
| 950 | ) { |
| 951 | describe(title, function () { |
| 952 | let faultInjectorClient: FaultInjectorClient; |
| 953 | let dbConfig: DatabaseConfig; |
| 954 | |
| 955 | before(async function () { |
| 956 | this.timeout(options.testTimeout ?? 300000); |
| 957 | |
| 958 | const baseUrl = process.env.RE_FAULT_INJECTOR_URL; |
| 959 | |
| 960 | if (!baseUrl) { |
| 961 | throw new Error("RE_FAULT_INJECTOR_URL environment variable must be set"); |
| 962 | } |
| 963 | |
| 964 | faultInjectorClient = new FaultInjectorClient(baseUrl); |
| 965 | |
| 966 | await faultInjectorClient.triggerAction({ |
| 967 | type: 'reset_cluster', |
| 968 | parameters: { |
| 969 | "clean_all_dbs": true, |
| 970 | "clean_maintenance_mode": true |
| 971 | } |
| 972 | }) |
| 973 | |
| 974 | const db = options.dbConfig || |
| 975 | getCreateDatabaseConfig( |
| 976 | CreateDatabaseConfigType.CLUSTER, |
| 977 | options.dbName ?? `test-db-${Date.now()}` |
| 978 | ); |
| 979 | |
| 980 | dbConfig = await faultInjectorClient.createAndSelectDatabase(db, 0); |
| 981 | }); |
| 982 | |
| 983 | it(title, async function () { |
| 984 | if (options.skipTest) return this.skip(); |
| 985 | if (options.testTimeout) { |
| 986 | this.timeout(options.testTimeout); |
| 987 | } |
| 988 | |
| 989 | const RESP = (options.clusterConfiguration?.RESP ?? DEFAULT_RESP) as RESP; |
| 990 | const { defaults, RESP: _RESP, ...rest } = options.clusterConfiguration ?? {}; |
| 991 | |
| 992 | // Wait for database to be fully ready before connecting |
| 993 | await new Promise(resolve => setTimeout(resolve, 1000)); |
| 994 |
no test coverage detected