Closed danielmustafa closed 2 months ago
Hi, the docker-compose.yml
file contains ports "8099:8080"
which will expose 8099 on the host machine. ComposeContainer
doesn't take into account the ports section declared in the compose file because of definitions where a fixed port is used. Looking at the logs Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for URL to be accessible (http://localhost:32929/__admin/mappings should return HTTP [200])
you can confirm a random port is used instead to start Wiremock.
Also, looking at the code, WIREMOCK_PORT should be 8080
instead, current value is the fixed port 8099
on the host machine
.withExposedService(WIREMOCK_SERVICE, WIREMOCK_PORT,
Wait.forHttp("/__admin/mappings").forStatusCode(200).withReadTimeout(Duration.ofSeconds(30)))
You can see the log java.lang.IllegalStateException: Target port 8099 is not exposed
in the project that you shared.
This is working as designed, if you apply the changes I mentioned then it should work.
Module
Core
Testcontainers version
1.20.1
Using the latest Testcontainers version?
Yes
Host OS
MacOS 14.6.1 (23G93)
Host Arch
arm64
Docker version
What happened?
Hi all. Using the most basic docker-compose file in my Spring Boot (3.2.1) (jdk17) integration test, I am able to successfully run my test successfully about 80% of the time. But every so often, I get an initialization exception due to an apparent socket timeout. Very similar to this issue
docker-compose.yml:
ContainerConfiguration:
The container spins up just fine and I'm able to access the wiremock endpoints through curl. In the test logs, it seems to get stuck immediately on the wait strategy (see log output). I've tried using a wait strategy on the listening port, on an HTTP endpoint, and all seem to end up having the same problem.
I inspected the
socat
logs and observed that it repeatedly had connection refused errors, so it looks like for whatever reason it's never able to establish the proxy in the socat container:This intermittent failure is happening on my machine, my workers' machines, and in our CI environment. It's very frustrating as it's causing flakiness in our builds, when we know the tests work just fine (when the containers spin up successfully). We have other containers in the compose but it only seems to be happening to this wiremock container.
Relevant log output
Additional Information
I also tried forcing to use the latest version of socat (1.8.0.0) but it didn't make any difference
EDIT: I created a small project on a Windows machine and am able to replicate the same behavior. This project can reproduce the issue 100% of the time (at least for me). Simply run the one test case which repeats the Compose start/stop process: https://github.com/danielmustafa/tc-test