-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wait strategy conflict when two mysql databases are up (Port 33060 not bound after 60000ms) #107
Comments
So that PR fixes my issue, but as an aside, @cristianrgreco is the wait strategy I've supplied there necessary? Not sure how the implicit wait strategy works for a mysql-based container. |
@rhyek the wait strategy is only necessary if the service - mysql in this case - is not ready to accept connections once its port is bound. By default testcontainers will wait for any port the service exposes to be bound. Does it not work if you remove the wait strategy from your example? |
@cristianrgreco thanks. it does work without it, but wasn't sure if it could cause any issues. Edit: This is inaccurate. Read below. |
GH auto-closes issues now when the PR is merged 🙂 Will release this shortly.. |
Available in 3.2.0, pls close the issue if all is working 🙂 |
@cristianrgreco everything works perfect now. Thanks! :-) |
@cristianrgreco, fyi and unrelated to this issue, I just tested without the log message wait strategy and I now get the same error |
@rhyek I just tested this locally. If no wait strategy is provided, testcontainers defaults to waiting for the container's host ports. MySQL exposes two, 3306 and 33060. It seems port 33060 never gets bound, so the default wait strategy will timeout. I tried specifying the log message wait strategy and it works as expected: const { DockerComposeEnvironment, Wait } = require("testcontainers");
(async () => {
const environment = await new DockerComposeEnvironment(__dirname, "docker-compose.yml")
.withBuild()
.withWaitStrategy('leadgogo_e2e_webapi_db', Wait.forLogMessage(`socket: '/var/run/mysqld/mysqld.sock' port: 3306`))
.up();
})(); Does this snippet not work for you? |
@cristianrgreco yes, that code works fine for my purposes. |
I'm working on a monorepo using
nx
. I have twodocker-compose.yaml
s: one for my local dev environment which I have permanently up usingdocker-compose up -d
and then one dedicated to e2e tests usingtestcontainers
.dev:
e2e
The e2e environment is activated in my jest test file like this:
When I have my dev docker compose up I can't run my e2e tests successfully. They always fail with the internal
testcontainers
error messagePort 33060 not bound after 60000ms
.As soon as I deactivate the dev docker compose my e2e tests will consistently pass.
I have debug logs for both situations:
with dev up
with dev down
One obvious difference is in first one you see the debug message
testcontainers DEBUG Waiting for internal port 33060 +32ms
while in the second you do not.The text was updated successfully, but these errors were encountered: