diff --git a/.changeset/wild-buses-guess.md b/.changeset/wild-buses-guess.md new file mode 100644 index 0000000..a8fae63 --- /dev/null +++ b/.changeset/wild-buses-guess.md @@ -0,0 +1,5 @@ +--- +'prool': patch +--- + +Made the testcontainers Tempo instance startup timeout configurable via `startupTimeout`. This also introduces a shared internal container-options shape for testcontainers-backed instances, so future container adapters can reuse the same option pattern. The default timeout remains `10_000ms`. diff --git a/src/testcontainers/Instance.ts b/src/testcontainers/Instance.ts index 78efd6f..f806942 100644 --- a/src/testcontainers/Instance.ts +++ b/src/testcontainers/Instance.ts @@ -6,6 +6,7 @@ import { } from 'testcontainers' import * as Instance from '../Instance.js' import { command, type tempo as core_tempo } from '../instances/tempo.js' +import * as ContainerOptions from './containerOptions.js' export type { Instance, InstanceOptions } from '../Instance.js' @@ -25,6 +26,7 @@ export const tempo = Instance.define((parameters?: tempo.Parameters) => { containerName = `tempo.${crypto.randomUUID()}`, image = 'ghcr.io/tempoxyz/tempo:latest', log: log_, + startupTimeout, ...args } = parameters || {} @@ -80,7 +82,9 @@ export const tempo = Instance.define((parameters?: tempo.Parameters) => { promise.reject(new Error(`Failed to start: ${error.message}`)) }) }) - .withStartupTimeout(10_000) + .withStartupTimeout( + ContainerOptions.resolveStartupTimeout(startupTimeout), + ) c.start() .then((c) => { @@ -100,7 +104,8 @@ export const tempo = Instance.define((parameters?: tempo.Parameters) => { }) export declare namespace tempo { - export type Parameters = Omit & { + export type Parameters = Omit & + ContainerOptions.Parameters & { /** * Name of the container. */ diff --git a/src/testcontainers/containerOptions.ts b/src/testcontainers/containerOptions.ts new file mode 100644 index 0000000..7a7a41e --- /dev/null +++ b/src/testcontainers/containerOptions.ts @@ -0,0 +1,20 @@ +export const defaults = { + startupTimeout: 10_000, +} as const + +export type Parameters = { + /** + * Startup timeout (in milliseconds) for testcontainers readiness checks. + * + * Increase this when running in CI or environments with slow image pulls. + * + * @default 10_000 + */ + startupTimeout?: number | undefined +} + +export function resolveStartupTimeout( + startupTimeout: number | undefined, +): number { + return startupTimeout ?? defaults.startupTimeout +}