Open ErikEngerd opened 2 weeks ago
Of course, doing defer net.Remove()
also fixes the issue, but still I think that cleanup by ryuk should already start while the tests are running.
@ErikEngerd thanks for raising this issue. Ryuk starts pruning the resources created by testcontainers when there are no more connections from the given test session. Thinking about your use case, how does Ryuk know when a network needs to be pruned based on your current run needs?
Because testcontainers APIs offer the way to manually terminate/remote resources, I do not see it as a bug, although I'd like to know if you have ideas on how to address what you are seeing in your builds.
One more question: how many Ryuk containers are started using -count=100
? Just one, or a hundred?
Testcontainers version
0.33.0
Using the latest Testcontainers version?
Yes
Host OS
Rocky linux 9.4
Host arch
x86-64
Go version
1.23.0
Docker version
Docker info
What happened?
I am running tests in go with the -count=100 option. Now, while running the tests I am monitoring the networks created with
watch docker network ls
. What I am seeing is that no cleanup is taking place between runs. The cleanup happens but only afterwards.The tests finally breaks off with an error message.
Relevant log output
Additional information
The test case is as follows:
I think testcontainers should support running tests with '-count=100' and should cleanup between test repetitions. Also, it should cleanup between different tests but I did not test that.
Even when configuring ryuk with a lower reconnection timeout (1 second) does not fix the issue. Cleanup only starts after the test has crashed.