Skip to content

Commit

Permalink
feat: add an option for skipping the port connectivity check (#163)
Browse files Browse the repository at this point in the history
* feat: add an option for skipping the connection check

* update snapshot
  • Loading branch information
n1ru4l authored Mar 24, 2020
1 parent db3c776 commit 9730433
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/dockest/src/@types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export interface DockestOpts {
logLevel: number
/** Run dockest sequentially */
runInBand: boolean
/** Skip port connectivity checks */
skipCheckConnection: boolean

jestLib: Jest

Expand Down
3 changes: 2 additions & 1 deletion packages/dockest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class Dockest {
mutables,
perfStart,
runInBand,
skipCheckConnection,
} = this.config

await bootstrap({
Expand All @@ -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 })
Expand Down
2 changes: 2 additions & 0 deletions packages/dockest/src/run/waitForServices/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('waitForServices', () => {
isInsideDockerContainer,
mutables: { runners, jestRanWithResult: false, dockerEventEmitter: new EventEmitter() as any },
runInBand,
skipCheckConnection: false,
})

expect(dockerComposeUp).toHaveBeenCalledTimes(3)
Expand Down Expand Up @@ -91,6 +92,7 @@ describe('waitForServices', () => {
isInsideDockerContainer,
mutables: { runners, jestRanWithResult: false, dockerEventEmitter: new EventEmitter() as any },
runInBand,
skipCheckConnection: false,
})

// waitForRunner
Expand Down
8 changes: 7 additions & 1 deletion packages/dockest/src/run/waitForServices/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand All @@ -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 })

Expand Down
1 change: 1 addition & 0 deletions packages/dockest/src/utils/getOpts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('getOpts', () => {
"mutables": Any<Object>,
"perfStart": Any<Number>,
"runInBand": true,
"skipCheckConnection": false,
}
`,
)
Expand Down
1 change: 1 addition & 0 deletions packages/dockest/src/utils/getOpts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ export const getOpts = (opts: Partial<DockestOpts> = {}): DockestConfig => {
logLevel,
perfStart: Date.now(),
runInBand,
skipCheckConnection: false,
}
}

0 comments on commit 9730433

Please sign in to comment.