testcontainers / testcontainers/testcontainers-java

LogMessageWaitStrategy does not work for compose based restarting containers

Aperta
#2,881 5 commenti 3 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

Hello!

The case is following:

  • testcontainers-java 1.14.3
  • docker-compose.yml with services A, B, C
  • B depends on A
  • C depends on B and A
  • withLocalCompose(true)

A starts quite quickly, B start takes ~40 seconds
While B is unavailable C keeps restarting

  • Tried Wait.forLogMessage() for A - works
  • Tried Wait.forLogMessage() for B - works
  • Tried Wait.forLogMessage() for C - Timed out waiting for log output matching <log>
  • Tried Wait.forLogMessage() for both B and C - Timed out waiting for log output matching <log>

Actually I'm interested in waiting for both of the services B and C explicitly, but only C should be valid as well.

Tried all the possible regex stuff (.*log.*, .*log.*\\s, .*log!\\s, .*log.*\n.* etc)

From my impression it seems that log polling breaks for a restarting container.
The difference between B and C here is that when starting B does not encounter broken B->A interaction since A could easily be started for the time of starting B. Hence B does not get restarted 'on error'.

As I got from debugging
https://github.com/testcontainers/testcontainers-java/blob/816b8c309ba526b4f34a9970f9f5e9918ad47d06/core/src/main/java/org/testcontainers/containers/output/WaitingConsumer.java#L85
becomes null when the container is going to start successfully, it's really strange. It contains lines from a stacktrace when the container is going to be restarted and null when it's running :suspect:

Any ideas? Thanks.

p.s. of course I see the desired log of the C in my terminal using docker logs C

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 da core/src/main/java/org/testcontainers/containers/output/WaitingConsumer.java intorno alla riga 85, dove il report rileva un output null durante i riavvii dei container. Riproduci lo scenario docker-compose con i servizi A, B e C, quindi verifica che Wait.forLogMessage() possa osservare il log previsto di C dopo i suoi riavvii senza andare in timeout.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.