From 97304339e416c192e8321658fe5935df315d3674 Mon Sep 17 00:00:00 2001 From: Laurin Quast Date: Tue, 24 Mar 2020 17:36:50 +0100 Subject: [PATCH] feat: add an option for skipping the port connectivity check (#163) * feat: add an option for skipping the connection check * update snapshot --- packages/dockest/src/@types.ts | 2 ++ packages/dockest/src/index.ts | 3 ++- packages/dockest/src/run/waitForServices/index.spec.ts | 2 ++ packages/dockest/src/run/waitForServices/index.ts | 8 +++++++- packages/dockest/src/utils/getOpts.spec.ts | 1 + packages/dockest/src/utils/getOpts.ts | 1 + 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/dockest/src/@types.ts b/packages/dockest/src/@types.ts index 94652af6..187919e3 100644 --- a/packages/dockest/src/@types.ts +++ b/packages/dockest/src/@types.ts @@ -92,6 +92,8 @@ export interface DockestOpts { logLevel: number /** Run dockest sequentially */ runInBand: boolean + /** Skip port connectivity checks */ + skipCheckConnection: boolean jestLib: Jest diff --git a/packages/dockest/src/index.ts b/packages/dockest/src/index.ts index 2180fd71..075eb8b1 100644 --- a/packages/dockest/src/index.ts +++ b/packages/dockest/src/index.ts @@ -47,6 +47,7 @@ export class Dockest { mutables, perfStart, runInBand, + skipCheckConnection, } = this.config await bootstrap({ @@ -59,7 +60,7 @@ export class Dockest { perfStart, }) - await waitForServices({ composeOpts, mutables, hostname, isInsideDockerContainer, runInBand }) + await waitForServices({ composeOpts, mutables, hostname, isInsideDockerContainer, runInBand, skipCheckConnection }) await debugMode({ debug, mutables }) const { success } = await runJest({ jestLib, jestOpts, mutables }) await teardown({ hostname, isInsideDockerContainer, mutables, perfStart }) diff --git a/packages/dockest/src/run/waitForServices/index.spec.ts b/packages/dockest/src/run/waitForServices/index.spec.ts index caf4b231..20809443 100644 --- a/packages/dockest/src/run/waitForServices/index.spec.ts +++ b/packages/dockest/src/run/waitForServices/index.spec.ts @@ -43,6 +43,7 @@ describe('waitForServices', () => { isInsideDockerContainer, mutables: { runners, jestRanWithResult: false, dockerEventEmitter: new EventEmitter() as any }, runInBand, + skipCheckConnection: false, }) expect(dockerComposeUp).toHaveBeenCalledTimes(3) @@ -91,6 +92,7 @@ describe('waitForServices', () => { isInsideDockerContainer, mutables: { runners, jestRanWithResult: false, dockerEventEmitter: new EventEmitter() as any }, runInBand, + skipCheckConnection: false, }) // waitForRunner diff --git a/packages/dockest/src/run/waitForServices/index.ts b/packages/dockest/src/run/waitForServices/index.ts index 54ad79ee..959378c1 100644 --- a/packages/dockest/src/run/waitForServices/index.ts +++ b/packages/dockest/src/run/waitForServices/index.ts @@ -18,12 +18,14 @@ export const waitForServices = async ({ isInsideDockerContainer, mutables: { runners }, runInBand, + skipCheckConnection, }: { composeOpts: DockestConfig['composeOpts'] hostname: DockestConfig['hostname'] isInsideDockerContainer: DockestConfig['isInsideDockerContainer'] mutables: DockestConfig['mutables'] runInBand: DockestConfig['runInBand'] + skipCheckConnection: DockestConfig['skipCheckConnection'] }) => { const setupPromises = [] @@ -46,7 +48,11 @@ export const waitForServices = async ({ await fixRunnerHostAccessOnLinux(runner) } - await checkConnection({ runner }) + if (skipCheckConnection) { + runner.logger.debug(`${LOG_PREFIX} Skip connection check.`) + } else { + await checkConnection({ runner }) + } await runReadinessCheck({ runner }) await runRunnerCommands({ runner }) diff --git a/packages/dockest/src/utils/getOpts.spec.ts b/packages/dockest/src/utils/getOpts.spec.ts index 86ce529a..319b6f1b 100644 --- a/packages/dockest/src/utils/getOpts.spec.ts +++ b/packages/dockest/src/utils/getOpts.spec.ts @@ -43,6 +43,7 @@ describe('getOpts', () => { "mutables": Any, "perfStart": Any, "runInBand": true, + "skipCheckConnection": false, } `, ) diff --git a/packages/dockest/src/utils/getOpts.ts b/packages/dockest/src/utils/getOpts.ts index 4ef89d20..273ab0b2 100644 --- a/packages/dockest/src/utils/getOpts.ts +++ b/packages/dockest/src/utils/getOpts.ts @@ -57,5 +57,6 @@ export const getOpts = (opts: Partial = {}): DockestConfig => { logLevel, perfStart: Date.now(), runInBand, + skipCheckConnection: false, } }