testcontainers / testcontainers/testcontainers-java

Mapped port polling on container startup causes race conditions with containers that terminate on startup

Abierto
#5,385 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Java
Estrellas
8.7k
Forks
1.9k
Merge medio
2 d 17 h
PR fusionados (30 d)
9

Descripción

It appears that https://github.com/testcontainers/testcontainers-java/pull/4263 introduced some flakiness in a subset of our tests. In particular, we have a few tests that test failure conditions for a container. In those tests, we either override waitUntilContainerStarted to check for a special log message or use a OneShotStartupCheckStrategy to detect when the desired state has been achieved. However, after upgrading to a version of TestContainers that includes the PR above (in this case, from 1.15.3 to 1.17.1), we started occasionally getting failures like this:

...
Caused by: org.testcontainers.shaded.org.awaitility.core.ConditionTimeoutException: Lambda expression in org.testcontainers.containers.GenericContainer: expected the predicate to return <true> but it returned <false> for input of ...
	at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at org.testcontainers.shaded.org.awaitility.core.AbstractHamcrestCondition.await(AbstractHamcrestCondition.java:86)
	at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:985)
	at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:691)
	at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:708)
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:450)
	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:340)
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:338)
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:326)
...

My belief is that, when it fails, the container terminates in between polling attempts, causing the until block to never succeed.
My expectation would be that the block to detect mapped ports should not throw an exception in this case.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza en GenericContainer.java, en tryStart, usando el stack trace y el sondeo de puertos mapeados introducido por PR 4263 como puntos de entrada. Reproduce una prueba de condición de fallo con OneShotStartupCheckStrategy o con un waitUntilContainerStarted sobrescrito mientras el contenedor termina durante el sondeo. Se considera terminado cuando el manejo del inicio ya no agota el tiempo de espera únicamente porque el contenedor termina entre los intentos de sondeo de puertos mapeados.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
docker, java
Área
testing
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.