MCPcopy
hub / github.com/redis/node-redis / testWithRECluster

Method testWithRECluster

packages/test-utils/lib/index.ts:937–1023  ·  view source on GitHub ↗
(
    title: string,
    fn: (
      cluster: RedisClusterType<M, F, S, RESP, TYPE_MAPPING>,
      faultInjectorClient: IFaultInjectorClient
    ) => unknown,
    options: REClusterTestOptions<M, F, S, RESP, TYPE_MAPPING>
  )

Source from the content-addressed store, hash-verified

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

Callers 2

spubsub.e2e.tsFile · 0.80

Calls 7

getCreateDatabaseConfigFunction · 0.90
createClusterFunction · 0.90
#clusterFlushAllMethod · 0.80
triggerActionMethod · 0.65
destroyMethod · 0.65
connectMethod · 0.45

Tested by

no test coverage detected