Add a function-based wait strategy
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 56/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- docker, node.js, typescript
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 2.6k
- Forks
- 274
- Merge medio
- 1 d 14 h
- PR fusionados (30 d)
- 44
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de testcontainers/testcontainers-node
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
testcontainers/testcontainers-node#1539 ·
Los mantenedores suelen responder en 1 día
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
testcontainers/testcontainers-node#1533 ·
Los mantenedores suelen responder en 1 día
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
testcontainers/testcontainers-node#1531 ·
Los mantenedores suelen responder en 1 día
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
testcontainers/testcontainers-node#1529 ·
Los mantenedores suelen responder en 1 día
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
testcontainers/testcontainers-node#1528 ·
Los mantenedores suelen responder en 1 día
Todos los issues de testcontainers/testcontainers-node
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
db-ux-design-system/core-web#8461 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Cannot run an integration on windows when power shell is selected as the default profile terminalAbiertoPriority/Blocker Type/Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
wso2/product-integrator#2767 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
-
severity:low
Dificultad 1/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día