-
-
Notifications
You must be signed in to change notification settings - Fork 515
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
[Bug]: Config is read too early to be modified in test code #2636
Comments
I tripped up against this too, read about using the env, tried it and saw exactly what you mentioned making env variables unusable in tests. |
Indeed. I want to definitively fix the config tests that depends a lot in the current state to make the tests deterministic. And, to the matter of this issue, look for a better mechanism to initialise the verbosity of the ryuk message. I think we could move that log entry to the place Ryuk is called for first time, so that the init function of that package does not interfere with the config.Read. Thoughts? |
Yeah, that would be better for my use case because I'm configuring Ryuk the same for all tests. |
Fix the ability to set the configuration of testcontainers using an environment variable set by a caller before the use of testcontainers. This removes the warning about disabling the reaper which is actually safe when done correctly. Optimise verbose check. Improve Config struct and field documentation. Fixes: #2701 #2636
@yiftachkarkason we released If fixed, I think we can close this one, thanks! |
Tested in v0.33.0 and it looks good! Thank you 😄 |
Testcontainers version
0.32.0
Using the latest Testcontainers version?
Yes
Host OS
MacOS
Host arch
ARM
Go version
1.22.5
Docker version
Client: Docker Engine - Community Version: 27.0.3 API version: 1.45 (downgraded from 1.46) Go version: go1.22.4 Git commit: 7d4bcd863a Built: Fri Jun 28 14:56:30 2024 OS/Arch: darwin/arm64 Context: desktop-linux Server: Docker Desktop 4.31.0 (153195) Engine: Version: 26.1.4 API version: 1.45 (minimum version 1.24) Go version: go1.21.11 Git commit: de5c9cf Built: Wed Jun 5 11:29:12 2024 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.6.33 GitCommit: d2d58213f83a351ca8f528a95fbd145f5654e957 runc: Version: 1.1.12 GitCommit: v1.1.12-0-g51d5e94 docker-init: Version: 0.19.0 GitCommit: de40ad0
Docker info
What happened?
A recent change in version 0.32.0 introduced a
config.Read()
call in the packageinit
function, which means that the environment variables and/or properties file is read very early when the program starts.In my E2E tests, I set relevant environment variables (such as disabling Ryuk for the longer tests to avoid having the containers removed while the test is still running), and this change breaks this functionality.
Currently, I can't upgrade the library past v0.31.0.
AFAICT there are 2 possible solutions:
config.Read
during the packageinit
functionconfig.Reset
function to external callers by extracting it from theinternal
directory.Thank you for you help!
Relevant log output
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: