-
-
Notifications
You must be signed in to change notification settings - Fork 511
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
chore: support disabling reaper at the configuration level #561
Conversation
We do not want to expose how the properties are read
Codecov Report
@@ Coverage Diff @@
## main #561 +/- ##
===========================================
- Coverage 68.99% 32.42% -36.58%
===========================================
Files 22 12 -10
Lines 2174 1687 -487
===========================================
- Hits 1500 547 -953
- Misses 535 1057 +522
+ Partials 139 83 -56
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Co-authored-by: Eddú Meléndez Gonzales <[email protected]>
Just checked that the java library supports disabling the reaper at the envVars level, only. Therefore, I'm going to update this PR to remove the support at the properties level. |
TBH I do not like it. I think the configuration should be the same for both. It just makes it unnecessary difficult for developers if we add exceptions for settings. If the Resource Reaper should not be disabled, it should be mentioned explicit in the docs. |
@HofmeisterAn is the ability to set the reaper at the envVar level only the thing that you don't like? I do prefer having both styles to configure the library: the properties and the env var. |
I cannot say much about the Go implementation. My Go skills aren't that good.
I agree. |
Superseded by #941 |
What is this PR doing?
This PR comes with a breaking change, regarding how the Docker client is obtained: the method to obtain an instance of the Docker client was public API, and now it's not.
The changes that drives that breaking change are the following:
NewDockerClient
has been converted into private, as we consider exposing the Docker client is not a responsibility of this library.newDockerClient
function is not returning an instance of the testcontainers properties anymore, as the properties are now part of a global singleton, accessible from any part of the code with the functions explained below.Besides that, the main intention of this PR was/is to initialise Ryuk/the reaper just once, not allowing to do it every time that a container is requested. In the past, before these changes, it was possible to create N containers and each of them would be able to define a strategy whether to skip the reaper or not. With this changes, we define the reaper disabled once. More specifically:
.Get()
function. That's how any other code in the library is able to get the properties..Get()
method will read them.ryuk.disabled
, which accepts boolean values.TESTCONTAINERS_RYUK_DISABLED
, which accepts boolean values.And the reaper struct? It is represented by a singleton, but we have optimised it a little bit:
ryuk.disabled=false
(default), then the mutext would lock infinitely: the network will wait for its reaper, which cannot continue creating its underlying container because of the lock has not been released. For that reason we had to add a check for the container request image: if the request is for the reaper, then skip.In terms of the CI, we have created a separate pipeline that runs the same tests that the main one, but with reaper disabled. For that, we are setting up the library with a
.testcontainers.properties
file includingryuk.disabled=true
. This step, but setting the value to false, has been added to the main pipeline, where Ryuk is enabled.A side effect of this PR is that we are adding consistency to the existing tests:
terminateContainerOnEnd
testing helper func.Why is it important?
There is a few of them:
.testcontainers.properties
file, which will allow adding optimizations to container execution.Related issues
How to test this
I used a Go project using testcontainers-go, and added a
replace
entry on itsgo.mod
file to use the current workspace, so the local version is used.When running the tests on that project, I verified that: