Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Pass the started container to `WaitStrategy.waitUntilReady`

オープン
#1,558 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
45/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
docker, node.js, typescript

調査の方向性

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 の本文から書いたものです。

説明

enhancement major

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(...) and container.logs().
  • Dockerode.Container and BoundPorts leave 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.ts and docker-compose-environment.ts

Notes

  • Java: void waitUntilReady(WaitStrategyTarget waitStrategyTarget), where WaitStrategyTarget extends ContainerState and the container itself is passed (getHost, getMappedPort, execInContainer, getLogs, getContainerInfo).
  • Go: WaitUntilReady(ctx, target StrategyTarget), with Host, Inspect, MappedPort, Logs, Exec, State and CopyFileFromContainer.
  • .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 a startTime so 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時間
マージ済み PR(30日)
44

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

testcontainers/testcontainers-node のほかの issue

testcontainers/testcontainers-node の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。