testcontainers / testcontainers/testcontainers-java

Container restart retried without waiting

Abierto
#942 11 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

modules/jdbc resolution/acknowledged type/bug
Lenguaje dominante
Java
Estrellas
8.7k
Forks
1.9k
Merge medio
2 d 17 h
PR fusionados (30 d)
9

Descripción

Hi, I started using TestContainers today. It simplifies the work a lot! 🎉

However, I'm facing a problem with version 1.9.1 with MySQLContainer.

When I run the tests locally it works like a charm. However, in another computer it is trying to spawn 3 instances of the container without waiting between attempts. This is happening because an exception happened before the wait strategy could be invoked.

The exception in my case is the following:

java.lang.IllegalStateException: copyFileToContainer can only be used with created / running container
	at org.testcontainers.containers.GenericContainer.copyFileToContainer(GenericContainer.java:1075)
	at org.testcontainers.containers.GenericContainer.copyFileToContainer(GenericContainer.java:1067)
	at java.util.HashMap.forEach(HashMap.java:1289)
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:262)
	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:237)
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:235)
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:220)
	at org.testcontainers.containers.GenericContainer.starting(GenericContainer.java:738)
	at org.testcontainers.containers.FailureDetectingExternalResource$1.evaluate(FailureDetectingExternalResource.java:29)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:379)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:340)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:125)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:413)

As you can see, it is thrown, from GenericContainer#tryStart, before reaching the invocation of the retry strategy.

It looks like it might be caused by the container not being started yet. So maybe it is taking some milliseconds more in that computer. So maybe executing the wait strategy before the copy operation starts might help.

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#tryStart y usa el stack trace para inspeccionar la ruta de reintento alrededor de copyFileToContainer y la estrategia de espera. Confirma el comportamiento de reintento cuando el inicio lanza una excepción antes de invocar la estrategia de espera; se considera terminado cuando los reintentos ya no generan contenedores sin esperar.

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

Evaluación

Stack tecnológico
docker, java
Área
devops, testing
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 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.