From 922fec84f2015aeb38ea10a10829d50de840e565 Mon Sep 17 00:00:00 2001 From: Alexey Yarmosh Date: Fri, 12 Apr 2024 16:34:06 +0200 Subject: [PATCH] feat: refactor --- test/e2e/docker.ts | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/test/e2e/docker.ts b/test/e2e/docker.ts index 8754fd8c..eab51d6a 100644 --- a/test/e2e/docker.ts +++ b/test/e2e/docker.ts @@ -13,19 +13,11 @@ class DockerManager { } public async createApiContainer () { - let networkMode = 'host'; - let redisUrl = config.get('redis.url'); - let dbConnectionHost = config.get('db.connection.host'); + const networkMode = 'bridge'; + const redisUrl = config.get('redis.url').replace('localhost', 'host.docker.internal'); + const dbConnectionHost = config.get('db.connection.host').replace('localhost', 'host.docker.internal'); const processes = config.get('server.processes'); - const isLinux = await this.isLinuxHost(); - - if (!isLinux) { - networkMode = 'bridge'; - redisUrl = redisUrl.replace('localhost', 'host.docker.internal'); - dbConnectionHost = dbConnectionHost.replace('localhost', 'host.docker.internal'); - } - // docker run -e NODE_ENV=test -e TEST_MODE=e2e -e NEW_RELIC_ENABLED=false -e REDIS_URL=redis://host.docker.internal:6379 -e DB_CONNECTION_HOST=host.docker.internal --name globalping-api-e2e globalping-api-e2e const container = await this.docker.createContainer({ Image: 'globalping-api-e2e', @@ -52,15 +44,8 @@ class DockerManager { } public async createProbeContainer () { - let networkMode = 'host'; - let apiHost = 'ws://localhost:80'; - - const isLinux = await this.isLinuxHost(); - - if (!isLinux) { - networkMode = 'bridge'; - apiHost = apiHost.replace('localhost', 'host.docker.internal'); - } + const networkMode = 'bridge'; + const apiHost = 'ws://localhost:80'.replace('localhost', 'host.docker.internal'); // docker run -e API_HOST=ws://host.docker.internal:80 --name globalping-probe-e2e globalping-probe-e2e console.log({ @@ -131,14 +116,6 @@ class DockerManager { await container.start({}); } - private async isLinuxHost (): Promise { - const versionInfo = await this.docker.version(); - const platformName = versionInfo.Platform.Name.toLowerCase(); - console.log('versionInfo.Platform'); - console.log(versionInfo.Platform); - return platformName.includes('engine'); - } - private async attachLogs (container: Docker.Container) { const stream = await container.logs({ follow: true,