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

#105 shutdown Testcontainers after test #289

Conversation

AndreKoepke
Copy link

No description provided.

@AndreKoepke
Copy link
Author

This changes working nicely for our tests.


@Override
public void shutdown() {
shutdownCallback.run();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must be Nullsafe.

@tomix26
Copy link
Collaborator

tomix26 commented Dec 3, 2024

Thanks for your effort, but this change doesn't fit the concept of how the library works. The library's goal is to start only one database container for all tests.

So the database container you're trying to shut down may contain data for other tests. When you use @AutoConfigureEmbeddedDatabase(refresh = AFTER_CLASS), @AutoConfigureEmbeddedDatabase(refresh = AFTER_EACH_TEST_METHOD) or @FlywayTest annotation, your solution stop working.

Therefore, the database container(s) must be shut down only at the end of the test suite. This should be handled by the Testcontainers library, ideally using the Ryuk container, or as a fallback solution using a shutdown hook, though the latter isn't 100% reliable.


https://java.testcontainers.org/features/configuration/#disabling-ryuk

Note that Testcontainers will continue doing the cleanup at JVM's shutdown, unless you kill -9 your JVM process.

@tomix26 tomix26 added the status: waiting-for-feedback We need additional information before we can continue label Dec 3, 2024
@AndreKoepke
Copy link
Author

True, for whatever reasons the teardown don't work on my machine. But it seems to be a problem with my setup.

@AndreKoepke AndreKoepke closed this Dec 3, 2024
@tomix26 tomix26 added status: invalid An issue that we don't feel is valid status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-feedback We need additional information before we can continue status: invalid An issue that we don't feel is valid labels Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants