-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Improve usability of SQL init scripts with reusable containers #2127
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this. |
any news on this? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this. |
This issue has been automatically closed due to inactivity. We apologise if this is still an active problem for you, and would ask you to re-open the issue if this is the case. |
@aguibert Is this feature on the roadmap or is it being implemented in some other way? |
not sure, I wanted to get feedback from maintainers before I spent the time to implement such a feature. @bsideup do you have thoughts on this proposal? |
Any update on this topic? I am facing same problem when using |
Work on this is currently not planned, while |
Background
Recently reusable container support was added to Testcontainers, which allows significant time savings during local dev/test cycles. However, there is room for improvement in the usability of reusable containers and init scripts (specifically
JdbcDatabaseContainer
init scripts).Currently the
JdbcDatabaseContainer
class has the following method:This allows an initialization SQL script to be run after the container is started. Typically to populate some test data in the database.
Problem
When combining this mechanism with reusable containers, the init script still runs every time the tests start, even though the same DB instance is being reused. This can cause problems if the init script was not written to account for a DB instance being reused. For example, it may try to create a table that already exists from the previous run, or it may try to insert some data that is already present in the DB from the previous run.
Proposed solution
Add an overloaded method to
JdbcDatabaseContainer
that allows the user to specify whether or not their init script should be run when attaching to a reused container. For example:The text was updated successfully, but these errors were encountered: