Closed an0r0c closed 2 years ago
Ok while writing this a knot got resolved in my head ...
Basically the .withProviderClassesFrom("target/test-classes")
seems to trigger this behavior. Without that the hash is the same and the container is reused properly.
Actually this is what happens when you copy over stuff from some tutorials without thinking in detail about it ... Basically I don't a custom Provider Class.
.... Leaving this issue here so it might be helpful for someone else who struggle with the same issue.
Hi!
I face the issue that always a new container get's started (while the one from the prev test run is still running). For other containers (pgSQL, min.io) the withReuse feature works as expected therefore I think it is not a general problem with my local setup.
I update to version 2.1.2 today as I saw some changes regarding withReuse in that release - but nothing changed.
I start the container with the following code:
While debugging in I found out that testcontainers compares a hash on the running containers against the start command of the container you want to start to see if a container instance is found that can be re-used.
For two runs I extracted the JSON on which this hash is calculated and found the following difference:
"org.testcontainers.copied_files.hash": "21ab144e"
-> So the hash of the files copied to the container seems to be differentI analyzed further how this has is calculated and ended up in
GenericContainer.hashCopiedFiles()
there is a mapcopyToFileContainerPathMap
that contains files that are copied to the container. That map contains exactly one file that is a providers.jar. It seems this jar is dynamically generatedIs there a way to keep this "stable" between two runs so that the hash would be the same?