testcontainers / testcontainers/testcontainers-java

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

Aperta
#5,385 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Java
Stelle
8.7k
Fork
1.9k
Merge medio
2g 17h
PR unite (30g)
9

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia in GenericContainer.java, all’interno di tryStart, usando lo stack trace e il polling delle porte mappate introdotto da PR 4263 come punti di partenza. Riproduci un test della condizione di errore con OneShotStartupCheckStrategy o con un waitUntilContainerStarted sovrascritto, mentre il container termina durante il polling. Il lavoro è completato quando la gestione dell’avvio non va più in timeout esclusivamente perché il container termina tra due tentativi di polling delle porte mappate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
docker, java
Ambito
testing
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.