- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 531
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
[Feature]: Support a reuseWindow
for cleaning up reusable containers if no tests run within a certain duration
#2804
Comments
reuseWindow
for cleaning up reusable containers if no tests run within a certain duration
So, first, weirdly, it seems like the env var is named I think you can achieve your goal by setting both |
At the time of writing, those env vars were prefaced with I haven't tried recently, but I imagine the behavior is still the same (eg the |
I had missed that. :)
I also wanted my testcontainers to be long-running, as I'm using Apache Pulsar and it takes a long time to boot. Therefore, I modified testcontainers-go to allow reusing the reaper across test runs. You can find my changes at https://github.com/bckground/testcontainers-go/tree/reuse-reaper which I will attempt to get upstream. Simply set a session ID for your project, e.g., |
Ah cool, do you still see the reaper containers piling up with your changes? Right now If I ran the tests 20 times, I'd have 20 reaper containers spinning for an hour each 😅 Edit: I see your changes regarding the session ID: |
Problem
I run tests that require a mysql. While I'm iterating on my tests, I'd like to leverage
reuse
to only pay that boot price on the first test, and then subsequent tests can reuse the same mysql (which is close to a 6x improvement in speed).However, I also want the reaper to clean up this container once I'm done with my testing "session", so I don't have a mysql running that I forgot to manually clean up.
I'm imagining a config like
reuse: true, reuseTimeout: 5m
. Which makes it so as long as I run a test within 5m of the last test, the reaper leaves the mysql container alone, but once 5m elapses without triggering a test, the reaper cleans everything up.I thought this might be possible today with a combination of
reuse: true
andTESTCONTAINERS_RYUK_RECONNECTION_TIMEOUT=5m
, but that still cleans up my mysql after 5m from the first test (and also spawns a new reaper for every run, which quickly pile up):Solution
Add a rolling reaper cleanup window
Benefit
Users can reuse containers, but not have to worry about manually cleaning them up
Alternatives
Manually delete reusable containers
Would you like to help contributing this feature?
Yes
The text was updated successfully, but these errors were encountered: