testcontainers / testcontainers/testcontainers-java
LogMessageWaitStrategy does not work for compose based restarting containers
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with core/src/main/java/org/testcontainers/containers/output/WaitingConsumer.java around line 85, where the report observes null output during container restarts. Reproduce the docker-compose scenario with services A, B, and C, then verify that Wait.forLogMessage() can observe C's expected log after its restarts without timing out.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, docker-compose, java
- Domain
- devops, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100