Support for working with already running containers #506
Labels
duplicate
This issue or pull request already exists
enhancement
New feature or request
help wanted
Extra attention is needed
Is your feature request related to a problem? Please describe.
When running integration tests with containers, I would like to reuse a running container on my local machine. So as not to recreate it between every test run. So along with
StartAsync()
:I propose a
EnsureStartedAsync(Filter? filter)
Describe the solution you'd like
As of v2.0.1 it seems to me that a
TestcontainersContainer
's internally need two things.ITestcontainersConfiguration
which is hidden from public inside the buildersContainerInspectResponse
representing the running containerSo in order to accomplish my "ensure started" method I actually have everything.
The test will use
TestcontainersBuilder
to construct anITestcontainersContainer
with a configuration inside.If the container is running, I can easily do a
ListContainersAsync
andInspectContainerAsync
to get theContainerInspectResponse
. (in this case, some kind of filter could be supplied)If the container is not running, I can just call
startAsync
.Describe alternatives you've considered
So if this solution is to "specialized" or niche, an alternative could be to open up the API a bit. At the moment it is very closed for extensions.
From an package user perspective I have the following problems:
ITestcontainersConfiguration
, it is private inside the builder and inside the testcontainerTestcontainersContainer
or any of its subtypes (it takes a configuration in the constructor)ContainerInspectResponse container
ofTestcontainersContainer
is private and I can't find a way to "extend my way" to set it. Therefore I cannot represent the "running state"Additional context
I have not used this lib for a long time, so please bare with me, if I missed something obvious.
But working with this lib, I have banged my head against internal classes, and private fields in hierarchies a lot. Of cause you should not expose internal state, but is all this exactly internal?
Couldn't some of it be made public, and thereby improve how extensible this library is?
The text was updated successfully, but these errors were encountered: