[Bug]: LoggedPullImageResultCallback throws java.lang.ArithmeticException: / by zero
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 58/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- docker, java
- Ambito
- testing-qa
Direzione di ricerca
Inizia da core/src/main/java/org/testcontainers/images/LoggedPullImageResultCallback.java, in particolare dal calcolo della durata intorno alle righe 113 e 121 e dal metodo onComplete. Esamina le convenzioni esistenti dei test Core, aggiungi la copertura per un pull completato in meno di un secondo ed esegui i test Core pertinenti per confermare che il completamento non generi più ArithmeticException.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Java
- Stelle
- 8.7k
- Fork
- 1.9k
- Merge medio
- 20h 43m
- PR unite (30g)
- 4
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
- Ha un 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-java
-
[Bug]: Build fails with "Unknown cli flag: --scripts-prepend-node-path" due to outdated Spotless pluginForse già presa @dhruv9b l’ha presa 36 giorni fa. Apertatype/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
testcontainers/testcontainers-java#11997 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement]: Document why singleton containers are required under Spring's test context cachingForse già presa @zakaullah075 l’ha presa 53 giorni fa. Apertatype/enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
testcontainers/testcontainers-java#11967 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Cannot reuse Selenium BrowserWebDriverContainers under LinuxForse già presa @kdelay l’ha presa 75 giorni fa. Apertatype/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
testcontainers/testcontainers-java#11941 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: DockerDesktopClientProviderStrategy is always applicableForse già presa @seonwooj0810 l’ha presa 124 giorni fa. Apertatype/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
testcontainers/testcontainers-java#11829 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement]: cleanup document after removing junit4 supportForse già presa @SJvaca30 l’ha presa 131 giorni fa. Apertatype/enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
testcontainers/testcontainers-java#11578 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di testcontainers/testcontainers-java
Issue simili
-
Clock.MakeTime fails to validate hour, minute, and second ranges due to inert Calendar.set try-catchAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
mit-cml/appinventor-sources#4139 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Vakore/ZappierGames#81 ·
-
proposal
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
beemdevelopment/Aegis#1843 · 1 reazione ·
-
[Bug] Logo style setting missing and `classic` style not applied across multiple platforms (v3.1.0)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Stirling-Tools/Stirling-PDF#8382 · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
-
>enhancement needs:triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
elastic/elasticsearch#161191 ·
I maintainer di solito rispondono entro 1 giorno