-
Notifications
You must be signed in to change notification settings - Fork 182
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
Cannot connect to database from other processes since 1.0.0 #172
Comments
Working as designed. TestContainers generates ephmeral ports, and you must use getDatasource, getUri, or getHost/getPort |
You cannot assume static port mapping. In general this is a feature. Feel free to submit a PR to do an optional static port (IIRC testcontainers supports this but recommends against it) |
For both of the latter two, feel free to submit a PR to optionally force static ports. In general these do not work well in scenario 1, which is why we went with the default. See also https://bsideup.github.io/posts/testcontainers_fixed_ports/ |
Feel free to check out https://github.com/opentable/otj-pg-embedded/tree/FixedPort - I can't guarantee it will be merged, but I believe it is what you wanted. |
Yes, this is what we could use.
Because many of the products we develop and maintain already use this library to set a Postgres database up from the integration test launcher, which does not run in the same process the app does. I wouldn't mind staying in a 0.13.4 patched revision if we had a fix for the Monterey 12.1 bug, which would guarantee we could keep running our stack the way we currently do without adding static ports, but I can't currently run 0.13.4 in my machine without workarounds. |
I hear all your points, but that's not the direction this library is going. I see you have the following options
|
Thank you for your breaking down our options and for your help in general, it's been very informative. I understand your point of view and I believe it's completely fair to draw boundaries on where the library is going. Yeah, I've been testing out the branch you facilitated earlier. Although it was working well on my machine, I was afraid it would not work with our Jenkins pipelines because we'd run into a Docker-in-Docker scenario, but so far my tests have been successful, so I'd say it might be safe to upgrade versions for us. Thanks again for your support! I'll keep an eye on the PR in case it gets merged so we can continue using official releases. |
No worries, I'll wait for more feedback from folks, but as you can see, I think I layered that, so maintaining a fork and merging up shouldn't be too horrible, regardless of what the PR decision is. |
Describe the bug
After upgrading otj-pg-embedded to 1.0.0 we were forced to remove the setPort invocation while building the EmbeddedPostgres object. Now the database is not reachable at localhost:5432 anymore which was needed for running integration tests from another Java process
Error thrown when trying to connect:
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
To Reproduce
Expected behavior
Database is reachable from other system processes.
Screenshots
If applicable, add screenshots to help explain your problem.
Machine (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: