Skip to content

Commit d511fd6

Browse files
Jan Waśkokosing
authored andcommitted
Ignore stopped containers in resource leak detector
Stopped containers can be left behind when using `withStartupAttempts()`. They should only use up disk space, not other resources, and will still be cleaned up by testcontainers on exit.
1 parent 9ec2b07 commit d511fd6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

testing/trino-testing-containers/src/main/java/io/trino/testing/containers/junit/ReportLeakedContainers.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public void testPlanExecutionFinished(TestPlan testPlan)
8181

8282
List<Container> containers = dockerClient.listContainersCmd()
8383
.withLabelFilter(Map.of(DockerClientFactory.TESTCONTAINERS_SESSION_ID_LABEL, DockerClientFactory.SESSION_ID))
84+
// ignore status "exited" - for example, failed containers after using `withStartupAttempts()`
85+
.withStatusFilter(List.of("created", "restarting", "running", "paused"))
8486
.exec()
8587
.stream()
8688
.filter(container -> !ignoredIds.contains(container.getId()))

0 commit comments

Comments
 (0)