diff --git a/packages/client/lib/client/index.spec.ts b/packages/client/lib/client/index.spec.ts index 2fd689b9d7..d7b91294ea 100644 --- a/packages/client/lib/client/index.spec.ts +++ b/packages/client/lib/client/index.spec.ts @@ -100,7 +100,8 @@ describe('Client', () => { ...GLOBAL.SERVERS.PASSWORD.clientOptions, database: 2 }, - minimumDockerVersion: [6, 2] + minimumDockerVersion: [6, 2], + redisEnterpriseNotSupported: true, }); }); @@ -278,7 +279,8 @@ describe('Client', () => { ); }, { ...GLOBAL.SERVERS.OPEN, - minimumDockerVersion: [6, 2] // CLIENT INFO + minimumDockerVersion: [6, 2], // CLIENT INFO + redisEnterpriseNotSupported: true, }); testUtils.testWithClient('should handle error replies (#2665)', async client => { @@ -407,7 +409,8 @@ describe('Client', () => { ); }, { ...GLOBAL.SERVERS.OPEN, - minimumDockerVersion: [6, 2] // CLIENT INFO + minimumDockerVersion: [6, 2], // CLIENT INFO + redisEnterpriseNotSupported: true, }); testUtils.testWithClient('scanIterator', async client => { @@ -750,7 +753,9 @@ describe('Client', () => { client.reset() ]); await assert.doesNotReject(client.ping()); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + }); testUtils.testWithClient('should respect type mapping', async client => { const duplicate = await client.duplicate().connect(), diff --git a/packages/client/lib/client/index.ts b/packages/client/lib/client/index.ts index 3efa793eeb..74b460c272 100644 --- a/packages/client/lib/client/index.ts +++ b/packages/client/lib/client/index.ts @@ -942,22 +942,15 @@ export default class RedisClient< * Reset the client to its default state (i.e. stop PubSub, stop monitoring, select default DB, etc.) */ async reset() { - const chainId = Symbol('Reset Chain'), - promises = [this._self.#queue.reset(chainId)], - selectedDB = this._self.#options?.database ?? 0; - for (const command of this._self.#handshake(selectedDB)) { - promises.push( - this._self.#queue.addCommand(command, { - chainId - }) - ); - } - this._self.#scheduleWrite(); - await Promise.all(promises); + const selectedDB = this._self.#options?.database ?? 0; + this.destroy(); + this._self.#selectedDB = selectedDB; this._self.#monitorCallback = undefined; this._self.#dirtyWatch = undefined; this._self.#watchEpoch = undefined; + + await this.connect(); } /** diff --git a/packages/client/lib/commands/ACL_DELUSER.spec.ts b/packages/client/lib/commands/ACL_DELUSER.spec.ts index d6acbb2223..1b30d2b559 100644 --- a/packages/client/lib/commands/ACL_DELUSER.spec.ts +++ b/packages/client/lib/commands/ACL_DELUSER.spec.ts @@ -26,5 +26,8 @@ describe('ACL DELUSER', () => { typeof await client.aclDelUser('user'), 'number' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/ACL_GENPASS.spec.ts b/packages/client/lib/commands/ACL_GENPASS.spec.ts index 44c1e167eb..5e0301bc5d 100644 --- a/packages/client/lib/commands/ACL_GENPASS.spec.ts +++ b/packages/client/lib/commands/ACL_GENPASS.spec.ts @@ -26,5 +26,8 @@ describe('ACL GENPASS', () => { typeof await client.aclGenPass(), 'string' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/ACL_LOG.spec.ts b/packages/client/lib/commands/ACL_LOG.spec.ts index b85a7076f4..9d399bf78b 100644 --- a/packages/client/lib/commands/ACL_LOG.spec.ts +++ b/packages/client/lib/commands/ACL_LOG.spec.ts @@ -46,5 +46,8 @@ describe('ACL LOG', () => { assert.equal(typeof log['timestamp-last-updated'], 'number'); } } - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/ACL_LOG_RESET.spec.ts b/packages/client/lib/commands/ACL_LOG_RESET.spec.ts index 8849440c1a..0582e40435 100644 --- a/packages/client/lib/commands/ACL_LOG_RESET.spec.ts +++ b/packages/client/lib/commands/ACL_LOG_RESET.spec.ts @@ -17,5 +17,8 @@ describe('ACL LOG RESET', () => { await client.aclLogReset(), 'OK' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/BGREWRITEAOF.spec.ts b/packages/client/lib/commands/BGREWRITEAOF.spec.ts index 5447fc70a7..a269c29d9e 100644 --- a/packages/client/lib/commands/BGREWRITEAOF.spec.ts +++ b/packages/client/lib/commands/BGREWRITEAOF.spec.ts @@ -15,5 +15,8 @@ describe('BGREWRITEAOF', () => { typeof await client.bgRewriteAof(), 'string' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/BGSAVE.spec.ts b/packages/client/lib/commands/BGSAVE.spec.ts index 7944722dd5..685ebcb686 100644 --- a/packages/client/lib/commands/BGSAVE.spec.ts +++ b/packages/client/lib/commands/BGSAVE.spec.ts @@ -28,5 +28,8 @@ describe('BGSAVE', () => { }), 'string' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/CLIENT_INFO.spec.ts b/packages/client/lib/commands/CLIENT_INFO.spec.ts index 0aba384aa3..f8e7d017c2 100644 --- a/packages/client/lib/commands/CLIENT_INFO.spec.ts +++ b/packages/client/lib/commands/CLIENT_INFO.spec.ts @@ -13,6 +13,9 @@ describe('CLIENT INFO', () => { }); testUtils.testWithClient('client.clientInfo', async client => { + //id=6463001000 addr=5.29.235.17:51462 laddr=10.0.1.6:19664 fd=171 name= age=3 idle=0 flags=N db=0 sub=0 psub=0 + //ssub=0 multi=-1 watch=0 obl=0 events=r cmd=client|list user=default resp=2 lib-name= lib-ver= + const reply = await client.clientInfo(); assert.equal(typeof reply.id, 'number'); assert.equal(typeof reply.addr, 'string'); @@ -25,21 +28,25 @@ describe('CLIENT INFO', () => { assert.equal(typeof reply.db, 'number'); assert.equal(typeof reply.sub, 'number'); assert.equal(typeof reply.psub, 'number'); - assert.equal(typeof reply.multi, 'number'); - assert.equal(typeof reply.qbuf, 'number'); - assert.equal(typeof reply.qbufFree, 'number'); - assert.equal(typeof reply.argvMem, 'number'); + assert.equal(typeof reply.multi, 'number'); assert.equal(typeof reply.obl, 'number'); - assert.equal(typeof reply.oll, 'number'); - assert.equal(typeof reply.omem, 'number'); - assert.equal(typeof reply.totMem, 'number'); assert.equal(typeof reply.events, 'string'); assert.equal(typeof reply.cmd, 'string'); assert.equal(typeof reply.user, 'string'); - assert.equal(typeof reply.redir, 'number'); + if (process.env.REDIS_ENTERPRISE === undefined) { + assert.equal(typeof reply.qbuf, 'number'); + assert.equal(typeof reply.qbufFree, 'number'); + assert.equal(typeof reply.argvMem, 'number'); + assert.equal(typeof reply.oll, 'number'); + assert.equal(typeof reply.omem, 'number'); + assert.equal(typeof reply.totMem, 'number'); + assert.equal(typeof reply.redir, 'number'); + } if (testUtils.isVersionGreaterThan([7, 0])) { - assert.equal(typeof reply.multiMem, 'number'); + if (process.env.REDIS_ENTERPRISE === undefined) { + assert.equal(typeof reply.multiMem, 'number'); + } assert.equal(typeof reply.resp, 'number'); if (testUtils.isVersionGreaterThan([7, 0, 3])) { diff --git a/packages/client/lib/commands/CLIENT_LIST.spec.ts b/packages/client/lib/commands/CLIENT_LIST.spec.ts index e967a8dc0f..0183fa5beb 100644 --- a/packages/client/lib/commands/CLIENT_LIST.spec.ts +++ b/packages/client/lib/commands/CLIENT_LIST.spec.ts @@ -45,25 +45,33 @@ describe('CLIENT LIST', () => { assert.equal(typeof item.sub, 'number'); assert.equal(typeof item.psub, 'number'); assert.equal(typeof item.multi, 'number'); - assert.equal(typeof item.qbuf, 'number'); - assert.equal(typeof item.qbufFree, 'number'); assert.equal(typeof item.obl, 'number'); - assert.equal(typeof item.oll, 'number'); - assert.equal(typeof item.omem, 'number'); assert.equal(typeof item.events, 'string'); assert.equal(typeof item.cmd, 'string'); - + if (process.env.REDIS_ENTERPRISE === undefined) { + assert.equal(typeof item.qbuf, 'number'); + assert.equal(typeof item.qbufFree, 'number'); + assert.equal(typeof item.oll, 'number'); + assert.equal(typeof item.omem, 'number'); + } + if (testUtils.isVersionGreaterThan([6, 0])) { - assert.equal(typeof item.argvMem, 'number'); - assert.equal(typeof item.totMem, 'number'); + if (process.env.REDIS_ENTERPRISE === undefined) { + assert.equal(typeof item.argvMem, 'number'); + assert.equal(typeof item.totMem, 'number'); + } assert.equal(typeof item.user, 'string'); if (testUtils.isVersionGreaterThan([6, 2])) { - assert.equal(typeof item.redir, 'number'); + if (process.env.REDIS_ENTERPRISE === undefined) { + assert.equal(typeof item.redir, 'number'); + } assert.equal(typeof item.laddr, 'string'); if (testUtils.isVersionGreaterThan([7, 0])) { - assert.equal(typeof item.multiMem, 'number'); + if (process.env.REDIS_ENTERPRISE === undefined) { + assert.equal(typeof item.multiMem, 'number'); + } assert.equal(typeof item.resp, 'number'); if (testUtils.isVersionGreaterThan([7, 0, 3])) { diff --git a/packages/client/lib/commands/CLIENT_NO-EVICT.spec.ts b/packages/client/lib/commands/CLIENT_NO-EVICT.spec.ts index 5de4dfd760..885a159709 100644 --- a/packages/client/lib/commands/CLIENT_NO-EVICT.spec.ts +++ b/packages/client/lib/commands/CLIENT_NO-EVICT.spec.ts @@ -26,5 +26,8 @@ describe('CLIENT NO-EVICT', () => { await client.clientNoEvict(true), 'OK' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/CLIENT_PAUSE.spec.ts b/packages/client/lib/commands/CLIENT_PAUSE.spec.ts index a30f907507..bce2c02c6b 100644 --- a/packages/client/lib/commands/CLIENT_PAUSE.spec.ts +++ b/packages/client/lib/commands/CLIENT_PAUSE.spec.ts @@ -24,5 +24,8 @@ describe('CLIENT PAUSE', () => { await client.clientPause(0), 'OK' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/CLIENT_TRACKING.spec.ts b/packages/client/lib/commands/CLIENT_TRACKING.spec.ts index 98fe091fb1..0462841d8c 100644 --- a/packages/client/lib/commands/CLIENT_TRACKING.spec.ts +++ b/packages/client/lib/commands/CLIENT_TRACKING.spec.ts @@ -97,5 +97,10 @@ describe('CLIENT TRACKING', () => { await client.clientTracking(false), 'OK' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + clientOptions: { + RESP: 3 + } + }); }); diff --git a/packages/client/lib/commands/CLIENT_UNPAUSE.spec.ts b/packages/client/lib/commands/CLIENT_UNPAUSE.spec.ts index bddf3ca0f0..5a71f11855 100644 --- a/packages/client/lib/commands/CLIENT_UNPAUSE.spec.ts +++ b/packages/client/lib/commands/CLIENT_UNPAUSE.spec.ts @@ -17,5 +17,8 @@ describe('CLIENT UNPAUSE', () => { await client.clientUnpause(), 'OK' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/CONFIG_SET.spec.ts b/packages/client/lib/commands/CONFIG_SET.spec.ts index 060183f58d..68068752e4 100644 --- a/packages/client/lib/commands/CONFIG_SET.spec.ts +++ b/packages/client/lib/commands/CONFIG_SET.spec.ts @@ -25,7 +25,7 @@ describe('CONFIG SET', () => { testUtils.testWithClient('client.configSet', async client => { assert.equal( - await client.configSet('maxmemory', '0'), + await client.configSet('lua-time-limit', '5000'), 'OK' ); }, GLOBAL.SERVERS.OPEN); diff --git a/packages/client/lib/commands/HELLO.spec.ts b/packages/client/lib/commands/HELLO.spec.ts index a0f088a4ba..f8949084c2 100644 --- a/packages/client/lib/commands/HELLO.spec.ts +++ b/packages/client/lib/commands/HELLO.spec.ts @@ -61,11 +61,15 @@ describe('HELLO', () => { assert.equal(typeof reply.version, 'string'); assert.equal(reply.proto, 2); assert.equal(typeof reply.id, 'number'); - assert.equal(reply.mode, 'standalone'); + if (process.env.REDIS_ENTERPRISE === undefined) { + assert.equal(reply.mode, 'standalone'); + } else { + assert.equal(reply.mode, 'cluster'); + } assert.equal(reply.role, 'master'); assert.deepEqual(reply.modules, []); }, { ...GLOBAL.SERVERS.OPEN, - minimumDockerVersion: [6, 2] + minimumDockerVersion: [6, 2], }); }); diff --git a/packages/client/lib/commands/LASTSAVE.spec.ts b/packages/client/lib/commands/LASTSAVE.spec.ts index 74cf30705f..f5151fb0b1 100644 --- a/packages/client/lib/commands/LASTSAVE.spec.ts +++ b/packages/client/lib/commands/LASTSAVE.spec.ts @@ -15,5 +15,8 @@ describe('LASTSAVE', () => { typeof await client.lastSave(), 'number' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/LATENCY_DOCTOR.spec.ts b/packages/client/lib/commands/LATENCY_DOCTOR.spec.ts index 00eabfb4cb..7c38db14bf 100644 --- a/packages/client/lib/commands/LATENCY_DOCTOR.spec.ts +++ b/packages/client/lib/commands/LATENCY_DOCTOR.spec.ts @@ -15,5 +15,8 @@ describe('LATENCY DOCTOR', () => { typeof await client.latencyDoctor(), 'string' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/LATENCY_GRAPH.spec.ts b/packages/client/lib/commands/LATENCY_GRAPH.spec.ts index 03ad8e2c88..ae352aa115 100644 --- a/packages/client/lib/commands/LATENCY_GRAPH.spec.ts +++ b/packages/client/lib/commands/LATENCY_GRAPH.spec.ts @@ -22,5 +22,8 @@ describe('LATENCY GRAPH', () => { ]); assert.equal(typeof reply, 'string'); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/LATENCY_HISTORY.spec.ts b/packages/client/lib/commands/LATENCY_HISTORY.spec.ts index 509c856e28..78a0f9274e 100644 --- a/packages/client/lib/commands/LATENCY_HISTORY.spec.ts +++ b/packages/client/lib/commands/LATENCY_HISTORY.spec.ts @@ -22,5 +22,8 @@ describe('LATENCY HISTORY', () => { assert.equal(typeof timestamp, 'number'); assert.equal(typeof latency, 'number'); } - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/LATENCY_LATEST.spec.ts b/packages/client/lib/commands/LATENCY_LATEST.spec.ts index f85a3ccc8b..4214d99ef9 100644 --- a/packages/client/lib/commands/LATENCY_LATEST.spec.ts +++ b/packages/client/lib/commands/LATENCY_LATEST.spec.ts @@ -23,5 +23,8 @@ describe('LATENCY LATEST', () => { assert.equal(typeof latestLatency, 'number'); assert.equal(typeof allTimeLatency, 'number'); } - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/MEMORY_DOCTOR.spec.ts b/packages/client/lib/commands/MEMORY_DOCTOR.spec.ts index e1d718d7aa..37fe799fa8 100644 --- a/packages/client/lib/commands/MEMORY_DOCTOR.spec.ts +++ b/packages/client/lib/commands/MEMORY_DOCTOR.spec.ts @@ -15,5 +15,8 @@ describe('MEMORY DOCTOR', () => { typeof (await client.memoryDoctor()), 'string' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/MEMORY_MALLOC-STATS.spec.ts b/packages/client/lib/commands/MEMORY_MALLOC-STATS.spec.ts index 8484fcbf0b..ca1c1f169c 100644 --- a/packages/client/lib/commands/MEMORY_MALLOC-STATS.spec.ts +++ b/packages/client/lib/commands/MEMORY_MALLOC-STATS.spec.ts @@ -15,5 +15,8 @@ describe('MEMORY MALLOC-STATS', () => { typeof (await client.memoryMallocStats()), 'string' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/MEMORY_PURGE.spec.ts b/packages/client/lib/commands/MEMORY_PURGE.spec.ts index 41b01f87c4..0a4657d254 100644 --- a/packages/client/lib/commands/MEMORY_PURGE.spec.ts +++ b/packages/client/lib/commands/MEMORY_PURGE.spec.ts @@ -15,5 +15,8 @@ describe('MEMORY PURGE', () => { await client.memoryPurge(), 'OK' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/MEMORY_STATS.spec.ts b/packages/client/lib/commands/MEMORY_STATS.spec.ts index 4fc823c3e6..67e844ab45 100644 --- a/packages/client/lib/commands/MEMORY_STATS.spec.ts +++ b/packages/client/lib/commands/MEMORY_STATS.spec.ts @@ -42,5 +42,8 @@ describe('MEMORY STATS', () => { assert.equal(typeof memoryStats['cluster.links'], 'number'); assert.equal(typeof memoryStats['functions.caches'], 'number'); } - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/MOVE.spec.ts b/packages/client/lib/commands/MOVE.spec.ts index e767568e72..477c3c94d7 100644 --- a/packages/client/lib/commands/MOVE.spec.ts +++ b/packages/client/lib/commands/MOVE.spec.ts @@ -15,5 +15,8 @@ describe('MOVE', () => { await client.move('key', 1), 0 ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/ROLE.spec.ts b/packages/client/lib/commands/ROLE.spec.ts index c57ba5ba1f..737d1f79a8 100644 --- a/packages/client/lib/commands/ROLE.spec.ts +++ b/packages/client/lib/commands/ROLE.spec.ts @@ -57,13 +57,13 @@ describe('ROLE', () => { }); testUtils.testWithClient('client.role', async client => { - assert.deepEqual( - await client.role(), - { - role: 'master', - replicationOffest: 0, - replicas: [] - } - ); + const ret = await client.role(); + assert.equal(ret!.role, 'master'); + assert.equal(ret!.replicationOffest, 0); + if (process.env.REDIS_ENTERPRISE === undefined) { + assert.deepEqual(ret!.replicas, []); + } else { + assert(ret!.replicas.length > 0); + } }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/SCRIPT_DEBUG.spec.ts b/packages/client/lib/commands/SCRIPT_DEBUG.spec.ts index 4e07f2c250..8240257195 100644 --- a/packages/client/lib/commands/SCRIPT_DEBUG.spec.ts +++ b/packages/client/lib/commands/SCRIPT_DEBUG.spec.ts @@ -15,5 +15,8 @@ describe('SCRIPT DEBUG', () => { await client.scriptDebug('NO'), 'OK' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/commands/SWAPDB.spec.ts b/packages/client/lib/commands/SWAPDB.spec.ts index 9331854c13..9ef7613dd5 100644 --- a/packages/client/lib/commands/SWAPDB.spec.ts +++ b/packages/client/lib/commands/SWAPDB.spec.ts @@ -15,5 +15,8 @@ describe('SWAPDB', () => { await client.swapDb(0, 1), 'OK' ); - }, GLOBAL.SERVERS.OPEN); + }, { + ...GLOBAL.SERVERS.OPEN, + redisEnterpriseNotSupported: true, + }); }); diff --git a/packages/client/lib/sentinel/index.spec.ts b/packages/client/lib/sentinel/index.spec.ts index e62acc181f..e4cd0b1aa5 100644 --- a/packages/client/lib/sentinel/index.spec.ts +++ b/packages/client/lib/sentinel/index.spec.ts @@ -88,7 +88,10 @@ async function steadyState(frame: SentinelFramework) { } ["redis-sentinel-test-password", undefined].forEach(function (password) { - describe.skip(`Sentinel - password = ${password}`, () => { + describe(`Sentinel - password = ${password}`, () => { + if (process.env.REDIS_HOST !== undefined) this.skip(); + if (process.env.REDIS_SENTINEL === undefined) this.skip(); + const config: RedisSentinelConfig = { sentinelName: "test", numberOfNodes: 3, password: password }; const frame = new SentinelFramework(config); let tracer = new Array(); diff --git a/packages/test-utils/lib/dockers.ts b/packages/test-utils/lib/dockers.ts index d282005e11..2b157502cd 100644 --- a/packages/test-utils/lib/dockers.ts +++ b/packages/test-utils/lib/dockers.ts @@ -94,11 +94,13 @@ async function dockerRemove(dockerId: string): Promise { } after(() => { - return Promise.all( - [...RUNNING_SERVERS.values()].map(async dockerPromise => - await dockerRemove((await dockerPromise).dockerId) - ) - ); + if (RUNNING_SERVERS.size != 0) { + return Promise.all( + [...RUNNING_SERVERS.values()].map(async dockerPromise => + await dockerRemove((await dockerPromise).dockerId) + ) + ); + } }); export interface RedisClusterDockersConfig extends RedisServerDockerConfig { @@ -254,11 +256,13 @@ export function spawnRedisCluster(dockersConfig: RedisClusterDockersConfig, serv } after(() => { - return Promise.all( - [...RUNNING_CLUSTERS.values()].map(async dockersPromise => { - return Promise.all( - (await dockersPromise).map(({ dockerId }) => dockerRemove(dockerId)) - ); - }) - ); + if (RUNNING_CLUSTERS.size != 0) { + return Promise.all( + [...RUNNING_CLUSTERS.values()].map(async dockersPromise => { + return Promise.all( + (await dockersPromise).map(({ dockerId }) => dockerRemove(dockerId)) + ); + }) + ); + } }); diff --git a/packages/test-utils/lib/index.ts b/packages/test-utils/lib/index.ts index 87ba34db7e..456730aae2 100644 --- a/packages/test-utils/lib/index.ts +++ b/packages/test-utils/lib/index.ts @@ -28,6 +28,8 @@ interface TestUtilsConfig { interface CommonTestOptions { serverArguments: Array; minimumDockerVersion?: Array; + debugRequired?: boolean; + redisEnterpriseNotSupported?: boolean; } interface ClientTestOptions< @@ -163,28 +165,52 @@ export default class TestUtils { options: ClientTestOptions ): void { let dockerPromise: ReturnType; - if (this.isVersionGreaterThan(options.minimumDockerVersion)) { - const dockerImage = this.#DOCKER_IMAGE; - before(function () { - this.timeout(30000); - dockerPromise = spawnRedisServer(dockerImage, options.serverArguments); - return dockerPromise; - }); + if (process.env.REDIS_HOST === undefined) { + if (this.isVersionGreaterThan(options.minimumDockerVersion)) { + const dockerImage = this.#DOCKER_IMAGE; + before(function () { + this.timeout(30000); + + dockerPromise = spawnRedisServer(dockerImage, options.serverArguments); + return dockerPromise; + }); + } } it(title, async function () { - if (!dockerPromise) return this.skip(); - - const client = createClient({ - ...options.clientOptions, - socket: { - ...options.clientOptions?.socket, - // TODO - // @ts-ignore - port: (await dockerPromise).port + let client: RedisClientType | undefined; + + if (process.env.REDIS_HOST === undefined) { + if (!dockerPromise) return this.skip(); + + client = createClient({ + ...options.clientOptions, + socket: { + ...options.clientOptions?.socket, + // TODO + // @ts-ignore + port: (await dockerPromise).port + } + }); + } else { + if (options.debugRequired) return this.skip(); + if (process.env.REDIS_ENTERPRISE !== undefined) { + if (options.redisEnterpriseNotSupported) return this.skip(); } - }); + + client = createClient({ + ...options.clientOptions, + password: process.env.REDIS_PASSWORD, + socket: { + ...options.clientOptions?.socket, + // TODO + // @ts-ignore + host: process.env.REDIS_HOST, + port: Number(process.env.REDIS_PORT!) + } + }); + } if (options.disableClientSetup) { return fn(client); @@ -216,28 +242,52 @@ export default class TestUtils { options: ClientPoolTestOptions ): void { let dockerPromise: ReturnType; - if (this.isVersionGreaterThan(options.minimumDockerVersion)) { - const dockerImage = this.#DOCKER_IMAGE; - before(function () { - this.timeout(30000); - dockerPromise = spawnRedisServer(dockerImage, options.serverArguments); - return dockerPromise; - }); + if (process.env.REDIS_HOST === undefined) { + if (this.isVersionGreaterThan(options.minimumDockerVersion)) { + const dockerImage = this.#DOCKER_IMAGE; + before(function () { + this.timeout(30000); + + dockerPromise = spawnRedisServer(dockerImage, options.serverArguments); + return dockerPromise; + }); + } } it(title, async function () { - if (!dockerPromise) return this.skip(); - - const pool = createClientPool({ - ...options.clientOptions, - socket: { - ...options.clientOptions?.socket, - // TODO - // @ts-ignore - port: (await dockerPromise).port + let pool: RedisClientPoolType | undefined; + + if (process.env.REDIS_HOST === undefined) { + if (!dockerPromise) return this.skip(); + + pool = createClientPool({ + ...options.clientOptions, + socket: { + ...options.clientOptions?.socket, + // TODO + // @ts-ignore + port: (await dockerPromise).port + } + }, options.poolOptions); + } else { + if (options.debugRequired) return this.skip(); + if (process.env.REDIS_ENTERPRISE !== undefined) { + if (options.redisEnterpriseNotSupported) return this.skip(); } - }, options.poolOptions); + + pool = createClientPool({ + ...options.clientOptions, + password: process.env.REDIS_PASSWORD, + socket: { + ...options.clientOptions?.socket, + // TODO + // @ts-ignore + host: process.env.REDIS_HOST, + port: Number(process.env.REDIS_PORT!) + } + }, options.poolOptions); + } await pool.connect(); @@ -280,6 +330,12 @@ export default class TestUtils { fn: (cluster: RedisClusterType) => unknown, options: ClusterTestOptions ): void { + if (process.env.REDIS_HOST !== undefined) { + it(title, async function () { + return this.skip(); + }); + } + let dockersPromise: ReturnType; if (this.isVersionGreaterThan(options.minimumDockerVersion)) { const dockerImage = this.#DOCKER_IMAGE;