Repository navigation
Allow .testcontainers.properties from classpath #3780
Description
Activity
Duplicate of many reports, see the last answer in #3707.
@bsideup how does your answer regarding
TESTCONTAINERS_RYUK_DISABLEDdoes have anything to do with my question about the.testcontainers.propertiesclasspath file???Reacted by Louis Torbay and soierr@membersound there are certain configuration options that are per environment, not per project.
Enabling reuse per project would also enable it on CIs. Most probably not something that you want.See #1781 (comment)
Well then probably the docs are wrong, which state it is actually possible?
https://www.testcontainers.org/features/configuration/
- testcontainers.properties on the classpath.
Reacted by Alexander Ilinykh@membersound there is nothing wrong about it. Per-project configuration can be placed in
testcontainers.propertiesfile on classpath.Well but if I put
testcontainers.reuse.enable=trueinto/src/main/resources/testcontainers.propertiesand enable reuse withjdbc:tc:mariadb:10.5.8:///test?TC_REUSABLE=true, I just get a warning the that reuse will not be enabled because it is missing in~/.testcontainer.properties.Doesn't that contradict it?
No, it does not, since
testcontainers.reuse.enableis not a per-project configuration option, but per-environment.Okay, is there any overview which properties are per-project, and which are per-env?
@membersound
TestcontainersConfigurationis the most up-to-date source of information:
testcontainers-java/core/src/main/java/org/testcontainers/utility/TestcontainersConfiguration.java
Line 46 in 0e263f2
public class TestcontainersConfiguration { You could maybe think about adding that to the docs explicit to directly gather which vars could be used from classpath.
I bet hardly anybody will look at the sourcecode in question...Reacted by Psimage, Tyler, Dmytro Dovgal, Louis Torbay, JohnBroughtonJelli, Mario Offertucci, Michał Krzywański, Paul Luong, James Peters, Jiri Hartikka and 9 more@membersound the thing is,
checks.disableandtestcontainers.reuse.enableare two exceptions to the rule of "any var can be configured with the classpath file", as they are considered advanced optimization techniques (and reuse mode even being a preview feature, not a stable solution). When it comes to advanced stuff, some level of research is expected.Reacted by kodyrecords and Xuan NguyenReacted by Leonhardt Koepsell, xav and Benjamin BrauchWhat about
TestcontainersConfiguration.getInstance().updateUserConfig("testcontainers.reuse.enable", "true");?Reacted by hector-meza, kliarist, Ryan Beall, lukasT, Xuan Nguyen, Julian Espinel, WildTigerrr, Alexey Repin, Steven Sheehy, Dmitrii Popov and 1 moreReacted by stefanCotrutaReacted by Marshtupa Bogdan, lukasT, Julian Espinel and Serzh90What about
TestcontainersConfiguration.getInstance().updateUserConfig("testcontainers.reuse.enable", "true");?Thank you so much. My team was ready to discontinue the use of TestContainers in favor of "old-school" compose files due to this issue and the configuration you provided helped me make it work.
What about
TestcontainersConfiguration.getInstance().updateUserConfig("testcontainers.reuse.enable", "true");?Thank you so much. My team was ready to discontinue the use of TestContainers in favor of "old-school" compose files due to this issue and the configuration you provided helped me make it work.
I'm happy this workaround is useful for you!
Reacted by stefanCotrutaI understand the motivations for closing this and other linked issues, but I just wanted to add that, in our case, we actually want to enable container reuse both in local builds and in CI (our use case is to run DB migrations and some codegen that depends on those migrations in the same container), but as you might expect I don't (nor should I) have access to modifying that user-level file in the CI server, and so I'm stuck.
Personally, I think that it'd be great to give people the option to choose how they set this up. If they want to set it up at the project level, even if discouraged for the common case, why prevent them from doing so? Also, it's not like enabling reuse has an immediate effect since you still need to explicitly turn it on when launching test containers (e.g. via the
TC_REUSABLE=trueJDBC URL flag), so I don't quite understand the concern.Reacted by Julian Espinel, Paweł Weselak, Geoff Sallee, Alexander Ilinykh, xav and Miguel Pontes- added a commit that references this issue
on Sep 12, 2024
I would be great if
.testcontainers.propertieswould be detected simply from classpath.With that, the
reuseoption could be simply applied to all test databases at once.It's somewhat problematic that the global reuse has to be enabled from home directory.
Because if one of my team mates checks out the project, it should be entirely configured, without having to read the some docs and eventually notice that everyone has to add his own
.testcontainersproperty in his home path for getting the same test performance.