Skip to content

Commit

Permalink
test: fix address mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKolarik committed Jan 8, 2025
1 parent 8316cc7 commit 1b6e758
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
7 changes: 7 additions & 0 deletions config/test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
18 changes: 13 additions & 5 deletions test/e2e/setup.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<string>('redis.standalonePersistent.url'),
config.get<string>('redis.standaloneNonPersistent.url'),
config.get<string>('redis.clusterMeasurements.nodes.0'),
config.get<string>('redis.clusterMeasurements.nodes.1'),
config.get<string>('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();
Expand Down

0 comments on commit 1b6e758

Please sign in to comment.