Pass the started container to `WaitStrategy.waitUntilReady`
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 45/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- docker, node.js, typescript
- Domain
- devtools, testing-qa
Research direction
Start with packages/testcontainers/src/wait-strategies/wait-strategy.ts and inspect every strategy in packages/testcontainers/src/wait-strategies/, then trace the listed callers in generic-container.ts, started-generic-container.ts and docker-compose-environment.ts. Check the start() and restart() paths, including how the log strategy receives startTime, and review the coordination issues before changing the shared signatures. Done means strategies receive the started container or a suitable target, callers and custom strategy examples are updated, and the startup deadline and abort signal have a defined place in the interface.
Written by the indexing model from the issue text.
Description
What happens
A wait strategy is handed the low-level pieces instead of the container:
export interface WaitStrategy {
waitUntilReady(container: Dockerode.Container, boundPorts: BoundPorts, startTime?: Date): Promise<void>;
withStartupTimeout(startupTimeoutMs: number): WaitStrategy;
isStartupTimeoutSet(): boolean;
getStartupTimeout(): number;
}
To do anything useful, an implementation has to fetch the rest itself. The six built-in strategies each call getContainerRuntimeClient() to find the host, read logs or run a command. A custom strategy needs Dockerode knowledge to do what StartedTestContainer already offers as getHost(), getMappedPort(), exec() and logs(). The documented route for custom strategies, StartupCheckStrategy.checkStartupState(dockerClient: Dockerode, containerId: string), has the same shape.
It also makes strategies awkward to reuse on a container that is already started. CouchbaseContainer rebuilds the arguments by hand to run an HTTP wait:
Wait.forHttp("/pools", PORTS.MGMT_PORT)
.forStatusCode(200)
.waitUntilReady(
client.container.getById(startedTestContainer.getId()),
BoundPorts.fromInspectResult(client.info.containerRuntime.hostIps, inspectResult)
);
Kafka and Redpanda do the same through waitForContainer.
Expected
waitUntilReady receives the container, or a narrower target interface that the started container satisfies:
interface WaitStrategy {
waitUntilReady(container: StartedTestContainer): Promise<void>;
}
- A module can write
await Wait.forHttp("/pools", port).waitUntilReady(container). - A custom strategy uses
container.getHost(),container.getMappedPort(port),container.exec(...)andcontainer.logs(). Dockerode.ContainerandBoundPortsleave the public interface.
Where
packages/testcontainers/src/wait-strategies/wait-strategy.ts- every strategy in
packages/testcontainers/src/wait-strategies/ packages/testcontainers/src/wait-strategies/wait-for-container.ts- callers in
generic-container.ts,started-generic-container.tsanddocker-compose-environment.ts
Notes
- Java:
void waitUntilReady(WaitStrategyTarget waitStrategyTarget), whereWaitStrategyTarget extends ContainerStateand the container itself is passed (getHost,getMappedPort,execInContainer,getLogs,getContainerInfo). - Go:
WaitUntilReady(ctx, target StrategyTarget), withHost,Inspect,MappedPort,Logs,Exec,StateandCopyFileFromContainer. - .NET:
IWaitUntil.UntilAsync(IContainer container). - The wait runs before
start()returns, so the started container has to exist before the wait instead of after it.restart()passes astartTimeso the log strategy ignores older output; that needs a home on the target. - Semver: this changes the interface that custom strategies implement, hence
major. - Whatever replaces the current arguments should have room for a startup deadline and an abort signal, so the interface changes once.
Dependencies
- Nothing blocks this. It can start now.
- Coordinate with #1523, #1533, #1534: small changes to the same strategy files. Land them first, since this rewrites every strategy's signature.
- Coordinate with #1532: the same files gain typed errors.
- Coordinate with #1582: the startup deadline needs a place in the new arguments.
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 290
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 22
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from testcontainers/testcontainers-node
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
testcontainers/testcontainers-node#1673 ·
Maintainers usually reply within 4 days
-
enhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
testcontainers/testcontainers-node#1539 ·
Maintainers usually reply within 4 days
-
Let `Wait.forListeningPorts()` wait on specific portsPossibly taken @artbom claimed this 29 days ago. Openenhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
testcontainers/testcontainers-node#1533 ·
Maintainers usually reply within 4 days
-
enhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
testcontainers/testcontainers-node#1531 ·
Maintainers usually reply within 4 days
-
Export the types used in public method signaturesPossibly taken @artbom claimed this 29 days ago. Openenhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
testcontainers/testcontainers-node#1528 ·
Maintainers usually reply within 4 days
All issues in testcontainers/testcontainers-node
Similar issues
-
prio:low scope:hud
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OliverRomhagen/vrigstad-joyride#953 ·
Maintainers usually reply within 1 day
-
review-followup
Difficulty 1/5 Under an hour Newbie friendliness 92/100
griffinwork40/agent-afk#5446 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
kacper-szewczyk/Ticknest#346 ·
Maintainers usually reply within 1 day
-
echarts geo: a GeoJSON URL that returns 200 with a body that is not JSON is fetched on each refreshOpenbug plugin/echarts/geo
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Yeachan-Heo/gajae-code#8230 ·
Maintainers usually reply within 1 day