diff --git a/config/test.cjs b/config/test.cjs index 3648d2ad..b61e2ea1 100644 --- a/config/test.cjs +++ b/config/test.cjs @@ -8,6 +8,13 @@ module.exports = { clusterMeasurements: { options: { nodeAddressMap (address) { + if (process.env.TEST_MODE !== 'e2e') { + return { + host: address.substring(0, address.lastIndexOf(':')), + port: address.substring(address.lastIndexOf(':') + 1), + }; + } + return { host: 'host.docker.internal', port: address.substring(address.lastIndexOf(':') + 1), diff --git a/test/e2e/setup.ts b/test/e2e/setup.ts index 70de5446..4848619a 100644 --- a/test/e2e/setup.ts +++ b/test/e2e/setup.ts @@ -1,10 +1,11 @@ +import _ from 'lodash'; import config from 'config'; import Bluebird from 'bluebird'; import type { Knex } from 'knex'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import * as chai from 'chai'; -import { createClient } from 'redis'; +import { createClient, type RedisClientOptions } from 'redis'; import { waitProbeToConnect } from './utils.js'; import chaiOas from '../plugins/oas/index.js'; @@ -43,11 +44,18 @@ const dropAllTables = async (sql: Knex) => { }; const flushRedis = async () => { - const dbs = [ 0, 1, 2 ]; - await Promise.all(dbs.map(async (database) => { + const urls = [ + config.get('redis.standalonePersistent.url'), + config.get('redis.standaloneNonPersistent.url'), + config.get('redis.clusterMeasurements.nodes.0'), + config.get('redis.clusterMeasurements.nodes.1'), + config.get('redis.clusterMeasurements.nodes.2'), + ]; + + await Promise.all(urls.map(async (url) => { const client = createClient({ - ...config.util.toObject(config.get('redis')), - database, + url, + ..._.cloneDeep(config.get('redis.sharedOptions') as RedisClientOptions), }); await client.connect(); await client.flushDb();