Skip to content
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

Allow additional waiting strategy for the Database to be available #136

Closed
dstepanov opened this issue Nov 28, 2022 · 3 comments
Closed

Comments

@dstepanov
Copy link

Feature description

Unfortunately, there is something different with timing when Rancher Desktop is used which makes Postgres (probably Oracle) container tests fail because it's reported as ready(it uses LogMessageWaitStrategy), but it still takes some time for the port to be exposed or something...

It would be nice to have some additional availability checks that can be enabled. I can see two options:

  1. Await for successful SQL query, that is the default Testcontainers check:
    https://github.com/testcontainers/testcontainers-java/blob/7ba6b1c518d8f181b5831229977c260dbff803dc/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java#L143-L175
    Unfortunately, it's overridden by Postgres and Oracle with LogMessageWaitStrategy.
    This check might be the most bulletproof but might need a custom configuration of the SQL check query.

  2. Wait for the port to be available. We can probably reuse Testcontainer's HostPortWaitStrategy.

@melix
Copy link
Collaborator

melix commented Nov 28, 2022

Relates to #123

melix added a commit that referenced this issue Nov 29, 2022
@kiview
Copy link

kiview commented Nov 30, 2022

Just chiming in with some experiences:

This check might be the most bulletproof but might need a custom configuration of the SQL check query.

One would think so, but it is explicitly flaky in the case of the default PostgreSQL image. This originates from the fact, that the PostregeSQL database restarts after bootstrapping its internal tables if the database was started without a data directory being present. This allowed for a small window of a race condition, where the JDBC query would succeed, but the database engine would proceed to perform the restart. The LogMessageWaitStrategy was introduced as a more stable criteria for readiness and from our experience, it works more reliably in the case of PostgreSQL.

Regarding the different behavior, I like to point to this comment:
testcontainers/testcontainers-java#5986 (comment)

Rancher Desktop has vastly different runtime characteristics compared to Docker Desktop and Testcontainers does not plan to support them explicitly.

That being said, for the issue at hand, using WaitAllStrategy can be a way to check for multiple indicators of readiness.

@dstepanov
Copy link
Author

@kiview Great insights! Maybe you can suggest what would be the solution to it. @melix created a PR for custom wait strategies #141

@melix melix closed this as completed in 1c60211 Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants