-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Detect leaked containers when running with JUnit #20297
Conversation
cc @trinodb/maintainers |
d797f4f
to
9a0a82f
Compare
Example in action - https://github.com/trinodb/trino/actions/runs/7447757866/job/20260913999 |
log.info("Checking for leaked containers"); | ||
|
||
try (DockerClient client = DockerClientFactory.instance().client()) { | ||
List<Container> containers = client.listContainersCmd() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are containers immediately removed - are we sure those are gone by now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, normally they are removed with equivalent of docker rm -f
, so immediate
With TestNG, `ManageTestResources` was attempting to prevent resource leaks, including container leaks, in tests. It relied on certain common test patterns to operate (like storing resource on instance fields). This commit attempts to provide similar functionality for JUnit. For now it's limited to containers. As an added bonus, it works regardless of how the test class is written.
9a0a82f
to
9eb75d5
Compare
Found a container leak in accumulo tests, in TestingAccumuloServer class. That one is intentional though, so added suppression mechanism. |
reportLeakedContainers adapted from trinodb/trino#20297 trinodb/trino#21280 Co-authored-by: Piotr Findeisen <piotr.findeisen@gmail.com> Co-authored-by: Jan Waś <jan.was@starburstdata.com>
reportLeakedContainers adapted from trinodb/trino#20297 trinodb/trino#21280 Co-authored-by: Piotr Findeisen <piotr.findeisen@gmail.com> Co-authored-by: Jan Waś <jan.was@starburstdata.com>
reportLeakedContainers adapted from trinodb/trino#20297 trinodb/trino#21280 Co-authored-by: Piotr Findeisen <piotr.findeisen@gmail.com> Co-authored-by: Jan Waś <jan.was@starburstdata.com>
With TestNG,
ManageTestResources
was attempting to prevent resource leaks, including container leaks, in tests. It relied on certain common test patterns to operate (like storing resource on instance fields).This commit attempts to provide similar functionality for JUnit. For now it's limited to containers. As an added bonus, it works regardless of how the test class is written.