Pass the started container to `WaitStrategy.waitUntilReady`
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 45/100
- Issue 类型
- 重构
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- docker, node.js, typescript
- 领域
- devtools, testing-qa
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- TypeScript
- 星标
- 2.6k
- 派生
- 274
- 平均合并
- 1 天 14 小时
- 30 天内合并 PR
- 44
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
testcontainers/testcontainers-node 的其他 Issue
-
enhancement minor
难度 2/5 1-3 小时 新手友好度 74/100
testcontainers/testcontainers-node#1539 ·
维护者通常 1 天内回复
-
enhancement minor
难度 2/5 1-3 小时 新手友好度 82/100
testcontainers/testcontainers-node#1533 ·
维护者通常 1 天内回复
-
enhancement minor
难度 2/5 1-3 小时 新手友好度 77/100
testcontainers/testcontainers-node#1531 ·
维护者通常 1 天内回复
-
enhancement minor
难度 2/5 1-3 小时 新手友好度 76/100
testcontainers/testcontainers-node#1529 ·
维护者通常 1 天内回复
-
enhancement minor
难度 2/5 1-3 小时 新手友好度 78/100
testcontainers/testcontainers-node#1528 ·
维护者通常 1 天内回复
查看 testcontainers/testcontainers-node 的全部 Issue
相似的 Issue
-
Add: VIVE TV未关闭approved check:passed streams:add
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
bug needs-triage
难度 2/5 1-3 小时 新手友好度 62/100
Fission-AI/OpenSpec#2084 ·
维护者通常 2 天内回复
-
Contrib indemnité de départ à la retraite : faire le pont avec le simulateur sur la page générique未关闭P1
难度 2/5 1-3 小时 新手友好度 62/100
SocialGouv/code-du-travail-numerique#7561 ·
维护者通常 1 天内回复
-
beginner bug
难度 1/5 1 小时以内 新手友好度 88/100
hiero-ledger/hiero-sdk-js#4517 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
kubernetes-sigs/headlamp#7950 ·
维护者通常 3 天内回复