Add a function-based wait strategy
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 56/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- docker, node.js, typescript
Direzione di ricerca
Start by reading packages/testcontainers/src/wait-strategies/wait.ts and the existing strategies in packages/testcontainers/src/wait-strategies/ to understand their polling and timeout behavior. The issue depends on #1558 for passing the container to the predicate, though it notes an internal adapter could be used first. Done means a function based strategy polls until ready, treats rejected promises as not ready, and includes the last error on timeout.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happens
There is no way to say "the container is ready when this function says so". A readiness check that the built-in strategies do not cover, such as "a query succeeds" or "the topic exists", needs a class:
- subclass
StartupCheckStrategy, which receives a raw Dockerode client and a container id and returns"PENDING" | "SUCCESS" | "FAIL", or - implement
WaitStrategyin full, including the timeout bookkeeping.
The usual alternative is to let start() return and then poll in the test with a hand-written retry loop.
Expected
A function-based strategy that is polled until it returns true, with the standard startup timeout:
const container = await new GenericContainer(image)
.withExposedPorts(5432)
.withWaitStrategy(
Wait.forPredicate(async (container) => {
const result = await container.exec(["pg_isready"]);
return result.exitCode === 0;
})
)
.start();
A rejected promise counts as "not ready yet", and the last error is included when the wait times out.
Where
packages/testcontainers/src/wait-strategies/wait.ts- a new strategy in
packages/testcontainers/src/wait-strategies/
Notes
- .NET's
IWaitUntilis a singleUntilAsync(IContainer)method added withAddCustomWaitStrategy. Go haswait.ForNop(func(ctx, target) error),wait.ForSQLandwait.ForExec. - Depends on what a strategy is given: with #1558 the predicate simply receives the container. It can be built before that by constructing the argument internally.
- Polling must use a deterministic check from the caller. This is not a place for a sleep.
Dependencies
- Blocked by #1558: the predicate should receive the container. It can be built first with an internal adapter if needed.
- 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
-
area:ui effort:S enhancement priority:P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
QuantumNous/new-api#7839 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue maintenance
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
dark-princezz/stellar-hooks#1010 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
interledger/rhyza#352 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno