Pass the started container to `WaitStrategy.waitUntilReady`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 45/100
- Tipo di issue
- Refactoring
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- docker, node.js, typescript
- Ambito
- devtools, testing-qa
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 2.6k
- Fork
- 274
- Merge medio
- 1g 14h
- PR unite (30g)
- 44
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di testcontainers/testcontainers-node
-
enhancement minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
testcontainers/testcontainers-node#1539 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
testcontainers/testcontainers-node#1533 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
testcontainers/testcontainers-node#1531 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
testcontainers/testcontainers-node#1529 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
testcontainers/testcontainers-node#1528 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di testcontainers/testcontainers-node
Issue simili
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 70/100
siyuan-note/siyuan#20517 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
NaturalIntelligence/fast-xml-parser#890 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
zsviczian/obsidian-excalidraw-plugin#3000 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
pnpm/get.pnpm.io#68 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
nuxt-modules/better-auth#578 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno