-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Deprecate file/volume mapping APIs #7652
Conversation
Using `Copy Files API` will make tests portable cross docker environments. Docs are removed too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While withCopyToContainer
is not a 100% replacement of all variants of using withFileSystemBind
(e.g. READ_WRITE
, or SelinuxContext
), for the intents of the general Testcontainers use cases, the deprecation makes IMO sense.
So I'd say, let's go ahead with it and see if there are any users missing these features (and don't remove the deprecated methods for some time).
Can the documentation be updated with a comparison of |
We run quite a lot of MariaDB-based tested, and some of them create and drop databases over and over again. Doing this on a partition backed by a real disk is not that fast, so we have optimized it by mounting a RAM disk as dbContainer.withFileSystemBind( RAMDISK_LOCATION + '/' + dbTypeAndVersion, "/var/lib/mysql" ); Correct me if I'm wrong, but I don't think this is doable with |
Ah, after reading testcontainers/testcontainers-go#1907 I found out that this might work: dbContainer.withCreateContainerCmdModifier(
cmd -> cmd.getHostConfig()
.withBinds( Bind.parse( RAMDISK_LOCATION + '/' + dbTypeAndVersion + ":/var/lib/mysql:rw" ) )
); Is this something that will continue working going forward? Maybe it could be mentioned in the docs somewhere in that case. |
As for cases where this might end up being worse, I was using a bind to get a handful of files in and handful of files out. The 1 line bind is now ~8 or so copy-in/copy-out. |
Yes, very much agree on this one. 👍 Even though the Copy files API is "recommended [...] for portability cross-docker environments", there are still cases like the one described above where bind-mounting is preferable. Would be great to see this mentioned in the docs, and being explicitly supported by Testcontainers. 🙇 |
This should have been included in testcontainers#7652, but was likely forgotten.
Also @eddumelendez, I think you missed at least two deprecations. This, and another one in the same class. 👇 testcontainers-java/core/src/main/java/org/testcontainers/containers/GenericContainer.java Lines 1021 to 1025 in 7bf5c49
I submitted this PR to fix it: #7895 (It would also be nice to get the other questions answered, but until then let's at least be consistent. 😄) |
The above was apparently deliberate. Let's continue the discussion in #7895. |
@slovdahl you can just use (FTR this is a good example of when "there are still cases like the one described above where bind-mounting is preferable" isn't so true and there is a better API for the job) |
Cool, TIL, thanks for sharing! Definitely need to investigate that approach. |
I'm currently using
(Let me know if this is not the right place for this discussion...) |
@big-andy-coates did you try #7652 (comment)? |
I'll take a look... |
Using
Copy Files API
will make tests portable cross docker environments.Docs are removed too.