fix: Add support for postgres 9.2 and lower#1392
fix: Add support for postgres 9.2 and lower#1392KijongHan wants to merge 1 commit intotestcontainers:developfrom
Conversation
✅ Deploy Preview for testcontainers-dotnet ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
0f7d7b9 to
4947ff3
Compare
HofmeisterAn
left a comment
There was a problem hiding this comment.
Thanks for the PR! The changes look good. However, TBH I'm not sure if I like adding support for a version that is EOL. Developers can simply override the default wait strategy or fall back to the generic container builder. But I agree that it is very difficult for developers to understand which versions are supported and which are not. This is something I've been thinking about a lot, but I haven't come up with a proper solution yet.
I don't know how to proceed from here. It's probably best to merge it so that other developers don't run into the same issue 🤔.
Note: I believe it was necessary to wait until the log messages were logged twice (for a reliable indication). I need to double-check the other language implementations.
|
I have a UntilDatabaseIsAvailable branch on my fork which would solve this issue. The I think it would be a perfect fit for this use case too (supporting PostgreSQL containers below version 9.3) and for any other potentially flaky wait strategy for database containers. Edit: I just opened #1401. Then it could be used like this: new PostgreSqlBuilder()
.WithImage("postgres:9.2")
.WithWaitStrategy(Wait.ForUnixContainer().UntilDatabaseIsAvailable(NpgsqlFactory.Instance)); |
Yeah I think your proposal there is quite reasonable, given this image is outside the LTS Im happy to close off this PR until the need arises. Appreciate your efforts! |
What does this PR do?
This PR adds support for running Postgres containers below version 9.3. Adds to the
PostgreSqlBuilder.Buildmethod to check for Postgres versions below 9.3 (which doesn't have support forpg_isreadyto check for database readiness) usingImage.MatchVersion- for these versions check for message logged in container usingUntilMessageIsLoggedhelper method for the message "PostgreSQL init process complete; ready for start up."Other strategies tried
select 1orselect version()- these were not reliable and the database was not in a state ready to accept connectionsrelated github discussion that helped determine above strategy: docker-library/postgres#146
Why is it important?
some older codebases are built on older versions of postgres, and being able to build tests using those older versions before migrating the version gives peace of mind for validating successful migration