[Bug]: LoggedPullImageResultCallback throws java.lang.ArithmeticException: / by zero
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 58/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- docker, java
- Área
- testing-qa
Línea de trabajo
Comienza en core/src/main/java/org/testcontainers/images/LoggedPullImageResultCallback.java, especialmente en el cálculo de la duración alrededor de las líneas 113 y 121 y en el método onComplete. Revisa las convenciones existentes de pruebas de Core, añade cobertura para un pull que se complete en menos de un segundo y ejecuta las pruebas relevantes de Core para confirmar que la finalización ya no lanza ArithmeticException.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Module
Core
Testcontainers version
1.21.3
Using the latest Testcontainers version?
Yes
Host OS
Linux
Host Arch
x86
Docker version
Docker Client 28.0.4
Docker Server 28.0.4
What happened?
When running tests in GitHub actions, it fails due to line 121 in LoggedPullImageResultCallback throws an java.lang.ArithmeticException: / by zero. Out of 10 times running our tests, it has failed 8 times and succeeded2. I have not been able to reproduce this in a reliable way but it seems like this would happen if a pull takes less than one full second since duration will become 0.
My first hypothesis was that this could happen if one already pulled the image in question but it seems that if the image is found locally, completed will never be set to true and therefore the line that throws the exception will never be executed.
Our current hypothesis is that there could be a race condition if a pull of an image is triggered twice. So just before the first pull invocation completes, another process triggers a pull. It's not fully found locally so we'll enter the "pull flow" but just at the last second, causing it to complete less in less than a second and trigger this issue.
If my hypothesis is correct it's hard to reliably create a way to replicate this but I think it would be worth it to be a bit more defensive in this part of the code and not throw an exception if it happens that a pull takes less than a second.
Relevant log output
OurTestClass > initializationError FAILED
org.opentest4j.AssertionFailedError: failed to start service!
at app//xx.xxxxxx.ourlibrary.integrationtests.IntegrationTestPostProcessor.postProcessTestInstance(IntegrationTestPostProcessor.java:112)
at [email protected]/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at [email protected]/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at [email protected]/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at [email protected]/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at [email protected]/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
at [email protected]/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at [email protected]/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at [email protected]/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at [email protected]/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at [email protected]/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at [email protected]/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
at [email protected]/java.util.Optional.orElseGet(Optional.java:364)
at [email protected]/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by:
java.lang.ArithmeticException: / by zero
at org.testcontainers.images.LoggedPullImageResultCallback.onComplete(LoggedPullImageResultCallback.java:120)
at org.testcontainers.images.TimeLimitedLoggedPullImageResultCallback.onComplete(TimeLimitedLoggedPullImageResultCallback.java:91)
at xx.xxxxxx.ourlibrary.integrationtests.testcontainers.ReactivePullImageResultCallback.onComplete(ReactivePullImageResultCallback.java:17)
at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrAsyncDockerCmdExec$1.onComplete(AbstrAsyncDockerCmdExec.java:51)
at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:276)
at java.base/java.lang.Thread.run(Thread.java:1583)
Additional Information
No response
- Lenguaje dominante
- Java
- Estrellas
- 8.7k
- Forks
- 1.9k
- Merge medio
- 17 h 38 min
- PR fusionados (30 d)
- 3
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
- Tiene una 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-java
-
[Bug]: Build fails with "Unknown cli flag: --scripts-prepend-node-path" due to outdated Spotless pluginPosiblemente ocupada @dhruv9b la tomó hace 34 días. Abiertotype/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
testcontainers/testcontainers-java#11997 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Enhancement]: Document why singleton containers are required under Spring's test context cachingPosiblemente ocupada @zakaullah075 la tomó hace 52 días. Abiertotype/enhancement
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
testcontainers/testcontainers-java#11967 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Bug]: Cannot reuse Selenium BrowserWebDriverContainers under LinuxPosiblemente ocupada @kdelay la tomó hace 73 días. Abiertotype/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
testcontainers/testcontainers-java#11941 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: DockerDesktopClientProviderStrategy is always applicablePosiblemente ocupada @seonwooj0810 la tomó hace 122 días. Abiertotype/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
testcontainers/testcontainers-java#11829 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Enhancement]: cleanup document after removing junit4 supportPosiblemente ocupada @SJvaca30 la tomó hace 130 días. Abiertotype/enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
testcontainers/testcontainers-java#11578 ·
Los mantenedores suelen responder en 1 día
Todos los issues de testcontainers/testcontainers-java
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
bancolombia/scaffold-clean-architecture#1002 ·
Los mantenedores suelen responder en 1 día
-
CalendarEventAttendance/get returns eventAttendanceStatus while the doc says attendanceStatusPosiblemente ocupada @chibenwa la tomó hoy. Abiertobug claude
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
linagora/tmail-backend#2697 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
apache/skywalking#14120 ·
Los mantenedores suelen responder en 1 día
-
[BUG] Case-insensitive search suggestions miss items when the JVM default locale is TurkishPosiblemente ocupada @thswlsqls la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
[Feature] 关于启动游戏进度条显示的优化Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
HMCL-dev/HMCL#6943 · 1 comentario ·
Los mantenedores suelen responder en 1 día